diff options
author | Phil Sutter <phil@nwl.cc> | 2021-12-24 14:55:28 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2022-01-12 14:08:54 +0100 |
commit | e4f5185d8f29a8d5b62159cb361648acd55da2a6 (patch) | |
tree | 2e0443867c84101570d9790a2f9ca81991f7d766 /iptables/nft-ipv4.c | |
parent | ded7b57977f3fa619975f752a342046225b56935 (diff) |
nft: Move proto_parse and post_parse callbacks to xshared
They are not nft-variant-specific and may therefore be shared with
legacy.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/nft-ipv4.c')
-rw-r--r-- | iptables/nft-ipv4.c | 59 |
1 files changed, 2 insertions, 57 deletions
diff --git a/iptables/nft-ipv4.c b/iptables/nft-ipv4.c index 07da0a7e..f374d468 100644 --- a/iptables/nft-ipv4.c +++ b/iptables/nft-ipv4.c @@ -274,61 +274,6 @@ static void nft_ipv4_save_rule(const void *data, unsigned int format) &cs->fw, format); } -static void nft_ipv4_proto_parse(struct iptables_command_state *cs, - struct xtables_args *args) -{ - cs->fw.ip.proto = args->proto; - cs->fw.ip.invflags = args->invflags; -} - -static void nft_ipv4_post_parse(int command, - struct iptables_command_state *cs, - struct xtables_args *args) -{ - cs->fw.ip.flags = args->flags; - /* We already set invflags in proto_parse, but we need to refresh it - * to include new parsed options. - */ - cs->fw.ip.invflags = args->invflags; - - memcpy(cs->fw.ip.iniface, args->iniface, IFNAMSIZ); - memcpy(cs->fw.ip.iniface_mask, - args->iniface_mask, IFNAMSIZ*sizeof(unsigned char)); - - memcpy(cs->fw.ip.outiface, args->outiface, IFNAMSIZ); - memcpy(cs->fw.ip.outiface_mask, - args->outiface_mask, IFNAMSIZ*sizeof(unsigned char)); - - if (args->goto_set) - cs->fw.ip.flags |= IPT_F_GOTO; - - cs->counters.pcnt = args->pcnt_cnt; - cs->counters.bcnt = args->bcnt_cnt; - - if (command & (CMD_REPLACE | CMD_INSERT | - CMD_DELETE | CMD_APPEND | CMD_CHECK)) { - if (!(cs->options & OPT_DESTINATION)) - args->dhostnetworkmask = "0.0.0.0/0"; - if (!(cs->options & OPT_SOURCE)) - args->shostnetworkmask = "0.0.0.0/0"; - } - - if (args->shostnetworkmask) - xtables_ipparse_multiple(args->shostnetworkmask, - &args->s.addr.v4, &args->s.mask.v4, - &args->s.naddrs); - if (args->dhostnetworkmask) - xtables_ipparse_multiple(args->dhostnetworkmask, - &args->d.addr.v4, &args->d.mask.v4, - &args->d.naddrs); - - if ((args->s.naddrs > 1 || args->d.naddrs > 1) && - (cs->fw.ip.invflags & (IPT_INV_SRCIP | IPT_INV_DSTIP))) - xtables_error(PARAMETER_PROBLEM, - "! not allowed with multiple" - " source or destination IP addresses"); -} - static void xlate_ipv4_addr(const char *selector, const struct in_addr *addr, const struct in_addr *mask, bool inv, struct xt_xlate *xl) @@ -511,8 +456,8 @@ struct nft_family_ops nft_family_ops_ipv4 = { .save_rule = nft_ipv4_save_rule, .save_chain = nft_ipv46_save_chain, .cmd_parse = { - .proto_parse = nft_ipv4_proto_parse, - .post_parse = nft_ipv4_post_parse, + .proto_parse = ipv4_proto_parse, + .post_parse = ipv4_post_parse, }, .parse_target = nft_ipv46_parse_target, .rule_to_cs = nft_rule_to_iptables_command_state, |