Skip to contentSkip to conversation

arptables: Warn when ignoring '-p' option

PATCH In review Phil Sutter 2 participants 3 messages Apr 2 – Apr 4 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 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
index 2140a88d4a6a9..d1e352e54f97c 100644
@@ -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
index 26e91e370eb84..263dcc32e5eb1 100644
@@ -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
maintainer Acked-by on v1 1/1
#1 lore raw
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_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.

author reviewer
#2 lore raw
Quoted 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_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.

Patch applied, thanks!