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

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