Blame SOURCES/0039-extensions-libipt_icmp-Fix-translation-of-type-any.patch

87db66
From 6adcdca2aaf8cba6ee452c88f41ad8695bebdcfc Mon Sep 17 00:00:00 2001
87db66
From: Phil Sutter <phil@nwl.cc>
87db66
Date: Tue, 6 Oct 2020 19:07:19 +0200
87db66
Subject: [PATCH] extensions: libipt_icmp: Fix translation of type 'any'
87db66
87db66
By itself, '-m icmp --icmp-type any' is a noop, it matches any icmp
87db66
types. Yet nft_ipv4_xlate() does not emit an 'ip protocol' match if
87db66
there's an extension with same name present in the rule. Luckily, legacy
87db66
iptables demands icmp match to be prepended by '-p icmp', so we can
87db66
assume this is present and just emit the 'ip protocol' match from icmp
87db66
xlate callback.
87db66
87db66
Fixes: aa158ca0fda65 ("extensions: libipt_icmp: Add translation to nft")
87db66
Signed-off-by: Phil Sutter <phil@nwl.cc>
87db66
Reviewed-by: Florian Westphal <fw@strlen.de>
87db66
(cherry picked from commit ad4b17b98bbedf93d2182a4dc9a37e9cf3adfe1b)
87db66
Signed-off-by: Phil Sutter <psutter@redhat.com>
87db66
---
87db66
 extensions/libipt_icmp.c      | 5 +++++
87db66
 extensions/libipt_icmp.txlate | 3 +++
87db66
 2 files changed, 8 insertions(+)
87db66
87db66
diff --git a/extensions/libipt_icmp.c b/extensions/libipt_icmp.c
87db66
index e76257c54708c..e5e236613f39f 100644
87db66
--- a/extensions/libipt_icmp.c
87db66
+++ b/extensions/libipt_icmp.c
87db66
@@ -256,6 +256,11 @@ static int icmp_xlate(struct xt_xlate *xl,
87db66
 		if (!type_xlate_print(xl, info->type, info->code[0],
87db66
 				      info->code[1]))
87db66
 			return 0;
87db66
+	} else {
87db66
+		/* '-m icmp --icmp-type any' is a noop by itself,
87db66
+		 * but it eats a (mandatory) previous '-p icmp' so
87db66
+		 * emit it here */
87db66
+		xt_xlate_add(xl, "ip protocol icmp");
87db66
 	}
87db66
 	return 1;
87db66
 }
87db66
diff --git a/extensions/libipt_icmp.txlate b/extensions/libipt_icmp.txlate
87db66
index 434f8cc4eb1ae..a2aec8e26df75 100644
87db66
--- a/extensions/libipt_icmp.txlate
87db66
+++ b/extensions/libipt_icmp.txlate
87db66
@@ -6,3 +6,6 @@ nft add rule ip filter INPUT icmp type destination-unreachable counter accept
87db66
 
87db66
 iptables-translate -t filter -A INPUT -m icmp ! --icmp-type 3 -j ACCEPT
87db66
 nft add rule ip filter INPUT icmp type != destination-unreachable counter accept
87db66
+
87db66
+iptables-translate -t filter -A INPUT -m icmp --icmp-type any -j ACCEPT
87db66
+nft add rule ip filter INPUT ip protocol icmp counter accept
87db66
-- 
87db66
2.28.0
87db66