Commit 3708b4d7 authored by Harald Welte's avatar Harald Welte Committed by Stephen Hemminger

[NETFILTER]: Conntrack optimization (LIST_DELETE).

The following patch against 2.6.0-test4 (courtesy of Patrick McHardy)
optimizes the conntrack code.  In the old implementation, the hash function
was passed to the LIST_DELETE macro, which resulted in it being called
two times instead of one.
parent db4c3d53
...@@ -285,14 +285,15 @@ static void remove_expectations(struct ip_conntrack *ct, int drop_refcount) ...@@ -285,14 +285,15 @@ static void remove_expectations(struct ip_conntrack *ct, int drop_refcount)
static void static void
clean_from_lists(struct ip_conntrack *ct) clean_from_lists(struct ip_conntrack *ct)
{ {
unsigned int ho, hr;
DEBUGP("clean_from_lists(%p)\n", ct); DEBUGP("clean_from_lists(%p)\n", ct);
MUST_BE_WRITE_LOCKED(&ip_conntrack_lock); MUST_BE_WRITE_LOCKED(&ip_conntrack_lock);
LIST_DELETE(&ip_conntrack_hash
[hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple)], ho = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
&ct->tuplehash[IP_CT_DIR_ORIGINAL]); hr = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
LIST_DELETE(&ip_conntrack_hash LIST_DELETE(&ip_conntrack_hash[ho], &ct->tuplehash[IP_CT_DIR_ORIGINAL]);
[hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)], LIST_DELETE(&ip_conntrack_hash[hr], &ct->tuplehash[IP_CT_DIR_REPLY]);
&ct->tuplehash[IP_CT_DIR_REPLY]);
/* Destroy all un-established, pending expectations */ /* Destroy all un-established, pending expectations */
remove_expectations(ct, 1); remove_expectations(ct, 1);
...@@ -364,9 +365,10 @@ __ip_conntrack_find(const struct ip_conntrack_tuple *tuple, ...@@ -364,9 +365,10 @@ __ip_conntrack_find(const struct ip_conntrack_tuple *tuple,
const struct ip_conntrack *ignored_conntrack) const struct ip_conntrack *ignored_conntrack)
{ {
struct ip_conntrack_tuple_hash *h; struct ip_conntrack_tuple_hash *h;
unsigned int hash = hash_conntrack(tuple);
MUST_BE_READ_LOCKED(&ip_conntrack_lock); MUST_BE_READ_LOCKED(&ip_conntrack_lock);
h = LIST_FIND(&ip_conntrack_hash[hash_conntrack(tuple)], h = LIST_FIND(&ip_conntrack_hash[hash],
conntrack_tuple_cmp, conntrack_tuple_cmp,
struct ip_conntrack_tuple_hash *, struct ip_conntrack_tuple_hash *,
tuple, ignored_conntrack); tuple, ignored_conntrack);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment