From 6156ba34018dddd59cb6737cfd5a69a0cbc5eaa4 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Thu, 30 Jan 2020 01:16:56 +0100 Subject: src: Add support for NFTNL_SET_DESC_CONCAT To support arbitrary range concatenations, the kernel needs to know how long each field in the concatenation is. The new libnftnl NFTNL_SET_DESC_CONCAT set attribute describes this as an array of lengths, in bytes, of concatenated fields. While evaluating concatenated expressions, export the datatype size into the new field_len array, and hand the data over via libnftnl. Similarly, when data is passed back from libnftnl, parse it into the set description. When set data is cloned, we now need to copy the additional fields in set_clone(), too. This change depends on the libnftnl patch with title: set: Add support for NFTA_SET_DESC_CONCAT attributes v4: No changes v3: Rework to use set description data instead of a stand-alone attribute v2: No changes Signed-off-by: Stefano Brivio Signed-off-by: Pablo Neira Ayuso --- src/netlink.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/netlink.c') diff --git a/src/netlink.c b/src/netlink.c index a9ccebaf..791943b4 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -773,6 +773,17 @@ struct set *netlink_delinearize_set(struct netlink_ctx *ctx, if (nftnl_set_is_set(nls, NFTNL_SET_DESC_SIZE)) set->desc.size = nftnl_set_get_u32(nls, NFTNL_SET_DESC_SIZE); + if (nftnl_set_is_set(nls, NFTNL_SET_DESC_CONCAT)) { + uint32_t len = NFT_REG32_COUNT; + const uint8_t *data; + + data = nftnl_set_get_data(nls, NFTNL_SET_DESC_CONCAT, &len); + if (data) { + memcpy(set->desc.field_len, data, len); + set->desc.field_count = len; + } + } + return set; } -- cgit v1.2.3