diff options
author | Phil Sutter <phil@nwl.cc> | 2020-02-21 14:55:52 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2020-02-24 12:04:30 +0100 |
commit | d0446ab11182f6ca2adc486a124895f09a220c6e (patch) | |
tree | 4ef308fcb3c979fb672db1182c39ac838223dae8 /iptables/xtables-standalone.c | |
parent | 0f40a8bc49d3f7b815336199931a82f919f37c4e (diff) |
xtables: Review nft_init()
Move common code into nft_init(), such as:
* initial zeroing nft_handle fields
* family ops lookup and assignment to 'ops' field
* setting of 'family' field
This requires minor adjustments in xtables_restore_main() so extra field
initialization doesn't happen before nft_init() call.
As a side-effect, this fixes segfaulting xtables-monitor binary when
printing rules for trace event as in that code-path 'ops' field wasn't
initialized.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/xtables-standalone.c')
-rw-r--r-- | iptables/xtables-standalone.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/iptables/xtables-standalone.c b/iptables/xtables-standalone.c index 1a28c548..022d5dd4 100644 --- a/iptables/xtables-standalone.c +++ b/iptables/xtables-standalone.c @@ -44,9 +44,7 @@ xtables_main(int family, const char *progname, int argc, char *argv[]) { int ret; char *table = "filter"; - struct nft_handle h = { - .family = family, - }; + struct nft_handle h; xtables_globals.program_name = progname; ret = xtables_init_all(&xtables_globals, family); @@ -61,7 +59,7 @@ xtables_main(int family, const char *progname, int argc, char *argv[]) init_extensions4(); #endif - if (nft_init(&h, xtables_ipv4) < 0) { + if (nft_init(&h, family, xtables_ipv4) < 0) { fprintf(stderr, "%s/%s Failed to initialize nft: %s\n", xtables_globals.program_name, xtables_globals.program_version, |