Blame SOURCES/0006-libxtables-Fix-unsupported-extension-warning-corner-.patch

a1bd1a
From 18fda96510a8e518e22523843050b824fa97cf2c Mon Sep 17 00:00:00 2001
a1bd1a
From: Phil Sutter <phil@nwl.cc>
a1bd1a
Date: Thu, 30 Jun 2022 18:04:39 +0200
a1bd1a
Subject: [PATCH] libxtables: Fix unsupported extension warning corner case
a1bd1a
a1bd1a
Some extensions are not supported in revision 0 by user space anymore,
a1bd1a
for those the warning in xtables_compatible_revision() does not print as
a1bd1a
no revision 0 is tried.
a1bd1a
a1bd1a
To fix this, one has to track if none of the user space supported
a1bd1a
revisions were accepted by the kernel. Therefore add respective logic to
a1bd1a
xtables_find_{target,match}().
a1bd1a
a1bd1a
Note that this does not lead to duplicated warnings for unsupported
a1bd1a
extensions that have a revision 0 because xtables_compatible_revision()
a1bd1a
returns true for them to allow for extension's help output.
a1bd1a
a1bd1a
For the record, these ip6tables extensions are affected: set/SET,
a1bd1a
socket, tos/TOS, TPROXY and SNAT. In addition to that, TEE is affected
a1bd1a
for both families.
a1bd1a
a1bd1a
Fixes: 17534cb18ed0a ("Improve error messages for unsupported extensions")
a1bd1a
Signed-off-by: Phil Sutter <phil@nwl.cc>
a1bd1a
(cherry picked from commit 552c4a2f9e5706fef5f7abb27d1492a78bbb2a37)
a1bd1a
---
a1bd1a
 libxtables/xtables.c | 14 ++++++++++++++
a1bd1a
 1 file changed, 14 insertions(+)
a1bd1a
a1bd1a
diff --git a/libxtables/xtables.c b/libxtables/xtables.c
a1bd1a
index 96fd783a066cf..7abc63bcfd83e 100644
a1bd1a
--- a/libxtables/xtables.c
a1bd1a
+++ b/libxtables/xtables.c
a1bd1a
@@ -773,6 +773,7 @@ xtables_find_match(const char *name, enum xtables_tryload tryload,
a1bd1a
 	struct xtables_match *ptr;
a1bd1a
 	const char *icmp6 = "icmp6";
a1bd1a
 	bool found = false;
a1bd1a
+	bool seen = false;
a1bd1a
 
a1bd1a
 	if (strlen(name) >= XT_EXTENSION_MAXNAMELEN)
a1bd1a
 		xtables_error(PARAMETER_PROBLEM,
a1bd1a
@@ -791,6 +792,7 @@ xtables_find_match(const char *name, enum xtables_tryload tryload,
a1bd1a
 		if (extension_cmp(name, (*dptr)->name, (*dptr)->family)) {
a1bd1a
 			ptr = *dptr;
a1bd1a
 			*dptr = (*dptr)->next;
a1bd1a
+			seen = true;
a1bd1a
 			if (!found &&
a1bd1a
 			    xtables_fully_register_pending_match(ptr, prev)) {
a1bd1a
 				found = true;
a1bd1a
@@ -804,6 +806,11 @@ xtables_find_match(const char *name, enum xtables_tryload tryload,
a1bd1a
 		dptr = &((*dptr)->next);
a1bd1a
 	}
a1bd1a
 
a1bd1a
+	if (seen && !found)
a1bd1a
+		fprintf(stderr,
a1bd1a
+			"Warning: Extension %s is not supported, missing kernel module?\n",
a1bd1a
+			name);
a1bd1a
+
a1bd1a
 	for (ptr = xtables_matches; ptr; ptr = ptr->next) {
a1bd1a
 		if (extension_cmp(name, ptr->name, ptr->family)) {
a1bd1a
 			struct xtables_match *clone;
a1bd1a
@@ -896,6 +903,7 @@ xtables_find_target(const char *name, enum xtables_tryload tryload)
a1bd1a
 	struct xtables_target **dptr;
a1bd1a
 	struct xtables_target *ptr;
a1bd1a
 	bool found = false;
a1bd1a
+	bool seen = false;
a1bd1a
 
a1bd1a
 	/* Standard target? */
a1bd1a
 	if (strcmp(name, "") == 0
a1bd1a
@@ -914,6 +922,7 @@ xtables_find_target(const char *name, enum xtables_tryload tryload)
a1bd1a
 		if (extension_cmp(name, (*dptr)->name, (*dptr)->family)) {
a1bd1a
 			ptr = *dptr;
a1bd1a
 			*dptr = (*dptr)->next;
a1bd1a
+			seen = true;
a1bd1a
 			if (!found &&
a1bd1a
 			    xtables_fully_register_pending_target(ptr, prev)) {
a1bd1a
 				found = true;
a1bd1a
@@ -927,6 +936,11 @@ xtables_find_target(const char *name, enum xtables_tryload tryload)
a1bd1a
 		dptr = &((*dptr)->next);
a1bd1a
 	}
a1bd1a
 
a1bd1a
+	if (seen && !found)
a1bd1a
+		fprintf(stderr,
a1bd1a
+			"Warning: Extension %s is not supported, missing kernel module?\n",
a1bd1a
+			name);
a1bd1a
+
a1bd1a
 	for (ptr = xtables_targets; ptr; ptr = ptr->next) {
a1bd1a
 		if (extension_cmp(name, ptr->name, ptr->family)) {
a1bd1a
 			struct xtables_target *clone;
a1bd1a
-- 
a1bd1a
2.34.1
a1bd1a