Blame SOURCES/0044-xtables-monitor-Fix-ip6tables-rule-printing.patch

ec5e2e
From 538acaef0d8424bd61047e6f1b81e3bc8bd421ec Mon Sep 17 00:00:00 2001
ec5e2e
From: Phil Sutter <phil@nwl.cc>
ec5e2e
Date: Fri, 7 Aug 2020 16:42:07 +0200
ec5e2e
Subject: [PATCH] xtables-monitor: Fix ip6tables rule printing
ec5e2e
ec5e2e
When printing an ip6tables rule event, false family ops are used as they
ec5e2e
are initially looked up for AF_INET and reused no matter the current
ec5e2e
rule's family. In practice, this means that nft_rule_print_save() calls
ec5e2e
the wrong rule_to_cs, save_rule and clear_cs callbacks. Therefore, if a
ec5e2e
rule specifies a source or destination address, the address is not
ec5e2e
printed.
ec5e2e
ec5e2e
Fix this by performing a family lookup each time rule_cb is called.
ec5e2e
ec5e2e
Signed-off-by: Phil Sutter <phil@nwl.cc>
ec5e2e
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
ec5e2e
(cherry picked from commit ca69b0290dc509d72118f0a054a5c740cb913875)
ec5e2e
Signed-off-by: Phil Sutter <psutter@redhat.com>
ec5e2e
---
ec5e2e
 iptables/xtables-monitor.c | 2 ++
ec5e2e
 1 file changed, 2 insertions(+)
ec5e2e
ec5e2e
diff --git a/iptables/xtables-monitor.c b/iptables/xtables-monitor.c
ec5e2e
index c2b31dbaa0795..92962a2a95f48 100644
ec5e2e
--- a/iptables/xtables-monitor.c
ec5e2e
+++ b/iptables/xtables-monitor.c
ec5e2e
@@ -93,6 +93,8 @@ static int rule_cb(const struct nlmsghdr *nlh, void *data)
ec5e2e
 	if (arg->nfproto && arg->nfproto != family)
ec5e2e
 		goto err_free;
ec5e2e
 
ec5e2e
+	arg->h->ops = nft_family_ops_lookup(family);
ec5e2e
+
ec5e2e
 	if (arg->is_event)
ec5e2e
 		printf(" EVENT: ");
ec5e2e
 	switch (family) {
ec5e2e
-- 
ec5e2e
2.31.1
ec5e2e