nft: Split nft core to become family independant
RFC PATCH 1/1 nft: Split nft core to become family independant
This makes nft core code independant from the family. Each family needs to implement and provide a struct nft_family_ops {}.
This split will ease the future support of bridge and arp rules manipulations.
Signed-off-by Tomasz Bursztyka <[email protected]>
--- iptables/Makefile.am | 1 + iptables/nft-ipv4.c | 322 +++++++++++++++++++ iptables/nft-ipv6.c | 230 +++++++++++++ iptables/nft-shared.c | 433 +++++++++++++++++++++++++ iptables/nft-shared.h | 64 ++++ iptables/nft.c | 867 ++------------------------------------------------ iptables/nft.h | 2 + iptables/xtables.c | 4 + 8 files changed, 1074 insertions(+), 849 deletions(-) create mode 100644 iptables/nft-ipv4.c create mode 100644 iptables/nft-ipv6.c create mode 100644 iptables/nft-shared.c create mode 100644 iptables/nft-shared.h
iptables/Makefile.am +1 -0
@@ -29,6 +29,7 @@ if HAVE_LIBMNL if HAVE_LIBNFTABLES xtables_multi_SOURCES += xtables-save.c xtables-restore.c \ xtables-standalone.c xtables.c nft.c \ + nft-shared.c nft-ipv4.c nft-ipv6.c \ xtables-config-parser.y xtables-config-syntax.l \ xtables-config.c xtables_multi_LDADD += -lmnl -lnftables
iptables/nft-ipv4.c new file +322 -0
322 lines not on this page · raw message
iptables/nft-ipv6.c new file +230 -0
230 lines not on this page · raw message
iptables/nft-shared.c new file +433 -0
433 lines not on this page · raw message
iptables/nft-shared.h new file +64 -0
64 lines not on this page · raw message
iptables/nft.c +18 -849
987 lines not on this page · raw message
iptables/nft.h +2 -0
@@ -2,12 +2,14 @@#define _NFT_H_#include "xshared.h" +#include "nft-shared.h" struct nft_handle {int family;struct mnl_socket *nl;uint32_t portid;uint32_t seq; +struct nft_family_ops *ops; };int nft_init (struct nft_handle *h);
iptables/xtables.c +4 -0
@@ -40,6 +40,7 @@#include <xtables.h> #include <fcntl.h> #include "xshared.h" +#include "nft-shared.h" #include "nft.h" #ifndef TRUE
@@ -1250,6 +1251,9 @@ int do_commandx(struct nft_handle *h, int argc, char *argv[], char **table) } h->family = family; + h->ops =nft_family_ops_lookup (family); +if (h->ops ==NULL ) +xtables_error (PARAMETER_PROBLEM ,"Unknown family" );if (command ==CMD_REPLACE && (s.naddrs !=1 || d.naddrs !=1 )) xtables_error(PARAMETER_PROBLEM, "Replacement rule does not "
Signature · 1 line
1.8.1.1