• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 2dbb49d15fb44ddd521a734eca3be3f940b7c1ba Mon Sep 17 00:00:00 2001
2From: Phil Sutter <phil@nwl.cc>
3Date: Fri, 11 Feb 2022 17:39:24 +0100
4Subject: libxtables: Register only the highest revision extension
5
6When fully registering extensions, ignore all consecutive ones with same
7name and family value. Since commit b3ac87038f4e4 ("libxtables: Make
8sure extensions register in revision order"), one may safely assume the
9list of pending extensions has highest revision numbers first. Since
10iptables is only interested in the highest revision the kernel supports,
11registration and compatibility checks may be skipped once the first
12matching extension in pending list has validated.
13
14Conflict: NA
15Reference: https://git.netfilter.org/iptables/commit/?id=2dbb49d15fb44ddd521a734eca3be3f940b7c1ba
16Signed-off-by: Phil Sutter <phil@nwl.cc>
17---
18 libxtables/xtables.c | 10 ++++++++--
19 1 file changed, 8 insertions(+), 2 deletions(-)
20
21diff --git a/libxtables/xtables.c b/libxtables/xtables.c
22index 50fd6a44..b34d62ac 100644
23--- a/libxtables/xtables.c
24+++ b/libxtables/xtables.c
25@@ -697,6 +697,7 @@ xtables_find_match(const char *name, enum xtables_tryload tryload,
26 	struct xtables_match **dptr;
27 	struct xtables_match *ptr;
28 	const char *icmp6 = "icmp6";
29+	bool found = false;
30
31 	if (strlen(name) >= XT_EXTENSION_MAXNAMELEN)
32 		xtables_error(PARAMETER_PROBLEM,
33@@ -715,7 +716,9 @@ xtables_find_match(const char *name, enum xtables_tryload tryload,
34 		if (extension_cmp(name, (*dptr)->name, (*dptr)->family)) {
35 			ptr = *dptr;
36 			*dptr = (*dptr)->next;
37-			if (xtables_fully_register_pending_match(ptr, prev)) {
38+			if (!found &&
39+			    xtables_fully_register_pending_match(ptr, prev)) {
40+				found = true;
41 				prev = ptr;
42 				continue;
43 			} else if (prev) {
44@@ -817,6 +820,7 @@ xtables_find_target(const char *name, enum xtables_tryload tryload)
45 	struct xtables_target *prev = NULL;
46 	struct xtables_target **dptr;
47 	struct xtables_target *ptr;
48+	bool found = false;
49
50 	/* Standard target? */
51 	if (strcmp(name, "") == 0
52@@ -831,7 +835,9 @@ xtables_find_target(const char *name, enum xtables_tryload tryload)
53 		if (extension_cmp(name, (*dptr)->name, (*dptr)->family)) {
54 			ptr = *dptr;
55 			*dptr = (*dptr)->next;
56-			if (xtables_fully_register_pending_target(ptr, prev)) {
57+			if (!found &&
58+			    xtables_fully_register_pending_target(ptr, prev)) {
59+				found = true;
60 				prev = ptr;
61 				continue;
62 			} else if (prev) {
63--
64cgit v1.2.3
65