diff options
Diffstat (limited to 'src/netlink.c')
-rw-r--r-- | src/netlink.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/netlink.c b/src/netlink.c index 9fc0b171..46897e43 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -534,7 +534,7 @@ enum nft_data_types dtype_map_to_kernel(const struct datatype *dtype) } } -const struct datatype *dtype_map_from_kernel(enum nft_data_types type) +static const struct datatype *dtype_map_from_kernel(enum nft_data_types type) { switch (type) { case NFT_DATA_VERDICT: @@ -581,10 +581,10 @@ struct set *netlink_delinearize_set(struct netlink_ctx *ctx, const struct nftnl_set *nls) { const struct nftnl_udata *ud[NFTNL_UDATA_SET_MAX + 1] = {}; - uint32_t flags, key, data, data_len, objtype = 0; enum byteorder keybyteorder = BYTEORDER_INVALID; enum byteorder databyteorder = BYTEORDER_INVALID; - const struct datatype *keytype, *datatype; + const struct datatype *keytype, *datatype = NULL; + uint32_t flags, key, objtype = 0; bool automerge = false; const char *udata; struct set *set; @@ -618,6 +618,8 @@ struct set *netlink_delinearize_set(struct netlink_ctx *ctx, flags = nftnl_set_get_u32(nls, NFTNL_SET_FLAGS); if (set_is_datamap(flags)) { + uint32_t data; + data = nftnl_set_get_u32(nls, NFTNL_SET_DATA_TYPE); datatype = dtype_map_from_kernel(data); if (datatype == NULL) { @@ -626,8 +628,7 @@ struct set *netlink_delinearize_set(struct netlink_ctx *ctx, data); return NULL; } - } else - datatype = NULL; + } if (set_is_objmap(flags)) { objtype = nftnl_set_get_u32(nls, NFTNL_SET_OBJ_TYPE); @@ -650,16 +651,13 @@ struct set *netlink_delinearize_set(struct netlink_ctx *ctx, set->objtype = objtype; + set->data = NULL; if (datatype) - set->datatype = datatype_get(set_datatype_alloc(datatype, - databyteorder)); - else - set->datatype = NULL; - - if (nftnl_set_is_set(nls, NFTNL_SET_DATA_LEN)) { - data_len = nftnl_set_get_u32(nls, NFTNL_SET_DATA_LEN); - set->datalen = data_len * BITS_PER_BYTE; - } + set->data = constant_expr_alloc(&netlink_location, + set_datatype_alloc(datatype, databyteorder), + databyteorder, + nftnl_set_get_u32(nls, NFTNL_SET_DATA_LEN) * BITS_PER_BYTE, + NULL); if (nftnl_set_is_set(nls, NFTNL_SET_TIMEOUT)) set->timeout = nftnl_set_get_u64(nls, NFTNL_SET_TIMEOUT); @@ -847,10 +845,10 @@ int netlink_delinearize_setelem(struct nftnl_set_elem *nlse, goto out; data = netlink_alloc_data(&netlink_location, &nld, - set->datatype->type == TYPE_VERDICT ? + set->data->dtype->type == TYPE_VERDICT ? NFT_REG_VERDICT : NFT_REG_1); - datatype_set(data, set->datatype); - data->byteorder = set->datatype->byteorder; + datatype_set(data, set->data->dtype); + data->byteorder = set->data->byteorder; if (data->byteorder == BYTEORDER_HOST_ENDIAN) mpz_switch_byteorder(data->value, data->len / BITS_PER_BYTE); |