From 328e42bdf55a9f243b7c4a87cc98cda8b9fe6468 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 24 Sep 2013 18:29:33 +0200 Subject: examples: nft-set-get: retrieve all sets per family Likewise other nftables objects, this patch allows you to dump the sets per family. This is possible since kernel changes (netfilter: nf_tables: allow to dump all existing sets), we can get the full list of sets per family. Signed-off-by: Pablo Neira Ayuso --- examples/nft-set-get.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'examples') diff --git a/examples/nft-set-get.c b/examples/nft-set-get.c index 7813cf0..4bc585c 100644 --- a/examples/nft-set-get.c +++ b/examples/nft-set-get.c @@ -56,8 +56,8 @@ int main(int argc, char *argv[]) struct nft_set *t = NULL; int ret; - if (argc < 3 || argc > 4) { - fprintf(stderr, "%s []\n", argv[0]); + if (argc < 2 || argc > 3) { + fprintf(stderr, "%s []\n", argv[0]); return EXIT_FAILURE; } t = nft_set_alloc(); @@ -79,14 +79,15 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - if (argc == 4 && strcmp(argv[3], "json") == 0) + if (argc == 3 && strcmp(argv[2], "json") == 0) type = NFT_SET_O_JSON; - else if (argc == 4 && strcmp(argv[3], "xml") == 0) + else if (argc == 3 && strcmp(argv[2], "xml") == 0) type = NFT_SET_O_XML; nlh = nft_set_nlmsg_build_hdr(buf, NFT_MSG_GETSET, family, NLM_F_DUMP|NLM_F_ACK, seq); - nft_set_attr_set(t, NFT_SET_ATTR_TABLE, argv[2]); + /* Use this below if you want to obtain sets per table */ +/* nft_set_attr_set(t, NFT_SET_ATTR_TABLE, argv[2]); */ nft_set_nlmsg_build_payload(nlh, t); nft_set_free(t); -- cgit v1.2.3