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

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