examples: add nft-ruleset-get
PATCH 1/2 examples: add nft-ruleset-get
This example prints the ruleset, using the ruleset API of nftables.
The kernel patch [b63108a] (netfilter: nf_tables: allow to dump sets with NFPROTO_UNSPEC) is required.
Signed-off-by Arturo Borrero Gonzalez <[email protected]>
--- examples/Makefile.am | 4 examples/nft-ruleset-get.c | 388 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 392 insertions(+) create mode 100644 examples/nft-ruleset-get.c
examples/Makefile.am +4 -0
@@ -25,6 +25,7 @@ check_PROGRAMS = nft-table-add \ nft-set-elem-add \ nft-set-elem-get \ nft-set-elem-del \ + nft-ruleset-get \ nft-compat-get nft_table_add_SOURCES = nft-table-add.c
@@ -102,5 +103,8 @@ nft_set_elem_del_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} nft_set_elem_get_SOURCES = nft-set-elem-get.c nft_set_elem_get_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} +nft_ruleset_get_SOURCES = nft-ruleset-get.c +nft_ruleset_get_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + nft_compat_get_SOURCES = nft-compat-get.c nft_compat_get_LDADD = ../src/libnftables.la ${LIBMNL_LIBS}
examples/nft-ruleset-get.c new file +388 -0
388 lines not on this page · raw message
PATCH 2/2 examples: nft-set-get: retrieve all sets
Other nftables objects are allowed to be dumped with NFPROTO_UNSPEC. With sets is also possible since kernel patch [b63108a] (netfilter: nf_tables:
allow to dump sets with NFPROTO_UNSPEC).
Signed-off-by Arturo Borrero Gonzalez <[email protected]>
--- examples/nft-set-get.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
examples/nft-set-get.c +3 -1
@@ -74,8 +74,10 @@ int main(int argc, char *argv[]) family =NFPROTO_BRIDGE ; else if (strcmp(argv[1], "arp") == 0) family =NFPROTO_ARP ; + else if (strcmp(argv[1], "any") == 0) + family =NFPROTO_UNSPEC ; else { -fprintf (stderr,"Unknown family: ip, ip6, bridge, arp\n" ); +fprintf (stderr,"Unknown family: ip, ip6, bridge, arp, any\n" );exit (EXIT_FAILURE ); }