Skip to contentSkip to conversation

xtables-monitor: Fix ip6tables rule printing

PATCH In review Phil Sutter 2 participants 2 messages Aug 7, 2020 – Aug 13, 2020 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 xtables-monitor: Fix ip6tables rule printing

When printing an ip6tables rule event, false family ops are used as they are initially looked up for AF_INET and reused no matter the current rule's family. In practice, this means that nft_rule_print_save() calls the wrong rule_to_cs, save_rule and clear_cs callbacks. Therefore, if a rule specifies a source or destination address, the address is not printed.

Fix this by performing a family lookup each time rule_cb is called.

---
 iptables/xtables-monitor.c | 2 ++
 1 file changed, 2 insertions(+)
iptables/xtables-monitor.c +2 -0
index 57def83e2eea0..4008cc00d4694 100644
@@ -93,6 +93,8 @@ static int rule_cb(const struct nlmsghdr *nlh, void *data)
 	if (arg->nfproto && arg->nfproto != family)
 		goto err_free;
 
+	arg->h->ops = nft_family_ops_lookup(family);
+
 	if (arg->is_event)
 		printf(" EVENT: ");
 	switch (family) {
Signature · 1 line
2.27.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Phil Sutter

When printing an ip6tables rule event, false family ops are used as they are initially looked up for AF_INET and reused no matter the current rule's family. In practice, this means that nft_rule_print_save() calls the wrong rule_to_cs, save_rule and clear_cs callbacks. Therefore, if a rule specifies a source or destination address, the address is not printed.

Fix this by performing a family lookup each time rule_cb is called.