]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxtables: Register multiple extensions in ascending order
authorPhil Sutter <phil@nwl.cc>
Tue, 22 Sep 2020 18:01:15 +0000 (20:01 +0200)
committerPhil Sutter <phil@nwl.cc>
Wed, 7 Oct 2020 10:38:45 +0000 (12:38 +0200)
The newly introduced ordered insert algorithm in
xtables_register_{match,target}() works best if extensions of same name
are passed in ascending revisions. Since this is the case in about all
extensions' arrays, iterate over them from beginning to end.

Signed-off-by: Phil Sutter <phil@nwl.cc>
libxtables/xtables.c

index 10d4e703285004eff960c9969e5ce9a82830a13e..7152c6576cd63d5bf98330574dbb21e3ae16fb24 100644 (file)
@@ -1141,9 +1141,10 @@ static bool xtables_fully_register_pending_match(struct xtables_match *me,
 
 void xtables_register_matches(struct xtables_match *match, unsigned int n)
 {
-       do {
-               xtables_register_match(&match[--n]);
-       } while (n > 0);
+       int i;
+
+       for (i = 0; i < n; i++)
+               xtables_register_match(&match[i]);
 }
 
 void xtables_register_target(struct xtables_target *me)
@@ -1269,9 +1270,10 @@ static bool xtables_fully_register_pending_target(struct xtables_target *me,
 
 void xtables_register_targets(struct xtables_target *target, unsigned int n)
 {
-       do {
-               xtables_register_target(&target[--n]);
-       } while (n > 0);
+       int i;
+
+       for (i = 0; i < n; i++)
+               xtables_register_target(&target[i]);
 }
 
 /* receives a list of xtables_rule_match, release them */