From 90f84108cf61891f6bc60d2f93cb25e05a47a661 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 14 Nov 2023 20:18:12 +0100 Subject: xshared: Introduce xt_cmd_parse_ops::option_invert Replace the awkward inverse_for_options array with basically a few switch() statements clearly identifying the relation between option and inverse values and relieve callers from having to find the option flag bit's position. Signed-off-by: Phil Sutter --- iptables/nft-arp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'iptables/nft-arp.c') diff --git a/iptables/nft-arp.c b/iptables/nft-arp.c index 6f8e1952..c009dd83 100644 --- a/iptables/nft-arp.c +++ b/iptables/nft-arp.c @@ -832,6 +832,19 @@ static const char *nft_arp_option_name(int option) } } +static int nft_arp_option_invert(int option) +{ + switch (option) { + case OPT_S_MAC: return IPT_INV_SRCDEVADDR; + case OPT_D_MAC: return IPT_INV_TGTDEVADDR; + case OPT_H_LENGTH: return IPT_INV_ARPHLN; + case OPT_OPCODE: return IPT_INV_ARPOP; + case OPT_H_TYPE: return IPT_INV_ARPHRD; + case OPT_P_TYPE: return IPT_INV_PROTO; + default: return ip46t_option_invert(option); + } +} + struct nft_family_ops nft_family_ops_arp = { .add = nft_arp_add, .is_same = nft_arp_is_same, @@ -844,6 +857,7 @@ struct nft_family_ops nft_family_ops_arp = { .cmd_parse = { .post_parse = nft_arp_post_parse, .option_name = nft_arp_option_name, + .option_invert = nft_arp_option_invert, }, .rule_to_cs = nft_rule_to_iptables_command_state, .init_cs = nft_arp_init_cs, -- cgit v1.2.3