[netfilter-cvslog] r3448 - trunk/iptables/libiptc
gandalf at netfilter.org
gandalf at netfilter.org
Sat Dec 18 18:18:50 CET 2004
Author: gandalf at netfilter.org
Date: 2004-12-18 18:18:49 +0100 (Sat, 18 Dec 2004)
New Revision: 3448
Modified:
trunk/iptables/libiptc/libiptc.c
Log:
Implement some optimization for finding rules to replace in TC_REPLACE_ENTRY.
Stolen from TC_DELETE_NUM_ENTRY.
Modified: trunk/iptables/libiptc/libiptc.c
===================================================================
--- trunk/iptables/libiptc/libiptc.c 2004-12-18 16:38:59 UTC (rev 3447)
+++ trunk/iptables/libiptc/libiptc.c 2004-12-18 17:18:49 UTC (rev 3448)
@@ -1,4 +1,4 @@
-/* Library which manipulates firewall rules. Version $Revision: 1.56 $ */
+/* Library which manipulates firewall rules. Version $Revision$ */
/* Architecture of firewall rules is as follows:
*
@@ -1319,11 +1319,18 @@
return 0;
}
- if (!(old = iptcc_get_rule_num(c, rulenum + 1))) {
+ if (rulenum >= c->num_rules) {
errno = E2BIG;
return 0;
}
+ /* Take advantage of the double linked list if possible. */
+ if (rulenum + 1 <= c->num_rules/2) {
+ old = iptcc_get_rule_num(c, rulenum + 1);
+ } else {
+ old = iptcc_get_rule_num_reverse(c, c->num_rules - rulenum);
+ }
+
if (!(r = iptcc_alloc_rule(c, e->next_offset))) {
errno = ENOMEM;
return 0;
More information about the netfilter-cvslog
mailing list