diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-09-24 18:29:33 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-09-24 18:29:33 +0200 |
commit | 328e42bdf55a9f243b7c4a87cc98cda8b9fe6468 (patch) | |
tree | 4e5e38f85be741ba8c5faf4c7de0a3f47587a401 | |
parent | c8b98054b6597903b36d097d248402f00acfcf9d (diff) |
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 <pablo@netfilter.org>
-rw-r--r-- | examples/nft-set-get.c | 11 |
1 files changed, 6 insertions, 5 deletions
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 <family> <table> [<json|xml>]\n", argv[0]); + if (argc < 2 || argc > 3) { + fprintf(stderr, "%s <family> [<json|xml>]\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); |