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

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