arptables: Warn when ignoring '-p' option
Phil Sutter
reviewerPATCH 1/1 arptables: Warn when ignoring '-p' option
Legacy arptables has been silently ignoring this flag (plus mandatory argument) since day 1. Retain compatibility to that behaviour but inform users that a part of their rule does nothing.
Since arp is the only family which didn't provide a proto_parse callback, implement one for the sole purpose of printing the warning. As a side-effect, caller no longer has to check callback's existence.
--- iptables/nft-arp.c | 8 ++++++++ iptables/xshared.c | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-)
iptables/nft-arp.c +8 -0
@@ -452,6 +452,13 @@ static int get16_and_mask(const char *from, uint16_t *to,return ret; } +static void nft_arp_proto_parse_warn (struct iptables_command_state *cs, +struct xtables_args *args) +{ +fprintf (stderr, +"Warning: Ignoring '-p' option not supported by arptables\n" ); +} +static void nft_arp_post_parse (int command,struct iptables_command_state *cs,struct xtables_args *args)
@@ -831,6 +838,7 @@ struct nft_family_ops nft_family_ops_arp = { .save_chain = nft_arp_save_chain, .rule_parse = &nft_ruleparse_ops_arp, .cmd_parse = { + .proto_parse = nft_arp_proto_parse_warn, .post_parse = nft_arp_post_parse, .option_name = nft_arp_option_name, .option_invert = nft_arp_option_invert,
iptables/xshared.c +1 -2
@@ -1657,8 +1657,7 @@ void do_parse(int argc, char *argv[], cs->protocol = optarg;/* This needs to happen here to parse extensions */ -if (p->ops->proto_parse) - p->ops->proto_parse (cs, args); + p->ops->proto_parse (cs, args);break ;case 's' :
Signature · 1 line
2.51.0
Quoted 9 lines · Phil Sutter
Legacy arptables has been silently ignoring this flag (plus mandatory argument) since day 1. Retain compatibility to that behaviour but inform users that a part of their rule does nothing.
Since arp is the only family which didn't provide a
proto_parsecallback, implement one for the sole purpose of printing the warning. As a side-effect, caller no longer has to check callback's existence.Signed-off-by Phil Sutter <[email protected]>
Phil Sutter
reviewerQuoted 5 lines · Pablo Neira Ayuso
Quoted 4 lines · Phil Sutter
Legacy arptables has been silently ignoring this flag (plus mandatory argument) since day 1. Retain compatibility to that behaviour but inform users that a part of their rule does nothing.
Quoted 7 lines
Quoted 5 lines
Since arp is the only family which didn't provide a
proto_parsecallback, implement one for the sole purpose of printing the warning. As a side-effect, caller no longer has to check callback's existence.Signed-off-by Phil Sutter <[email protected]>
Patch applied, thanks!