]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
examples: nft-set-add: update it to add a set that stores port numbers
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 30 Nov 2016 21:05:54 +0000 (22:05 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 30 Nov 2016 21:05:54 +0000 (22:05 +0100)
This patch updates the existing example to add a set that stores port
numbers. In order to interoperate with the nft tool, we use the datatype
numbers defined there.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
examples/nft-set-add.c

index e040aca327a129fc821385e096dd3b3231123003..bae6e8e68540fc8a5c539df4e8724f7b56ba70bd 100644 (file)
@@ -42,9 +42,10 @@ static struct nftnl_set *setup_set(uint8_t family, const char *table,
        nftnl_set_set_str(s, NFTNL_SET_TABLE, table);
        nftnl_set_set_str(s, NFTNL_SET_NAME, name);
        nftnl_set_set_u32(s, NFTNL_SET_FAMILY, family);
-       nftnl_set_set_u32(s, NFTNL_SET_KEY_LEN, 2);
+       nftnl_set_set_u32(s, NFTNL_SET_KEY_LEN, sizeof(uint16_t));
+       /* inet service type, see nftables/include/datatypes.h */
+       nftnl_set_set_u32(s, NFTNL_SET_KEY_TYPE, 13);
        nftnl_set_set_u32(s, NFTNL_SET_ID, 1);
-       nftnl_set_set_u32(s, NFTNL_SET_FLAGS, NFT_SET_CONSTANT);
 
        return s;
 }