[NETFILTER]: nf_conntrack_expect: avoid useless list walking

Don't walk the list when unexpecting an expectation, we already
have a reference and the timer check is enough to guarantee
that it still is on the list.

This comment suggests that it was copied there by mistake from
expectation eviction:

/* choose the oldest expectation to evict */

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Patrick McHardy 2007-07-07 22:32:03 -07:00 коммит произвёл David S. Miller
Родитель d4156e8cd9
Коммит 4e1d4e6c5a
1 изменённых файлов: 3 добавлений и 10 удалений

Просмотреть файл

@ -165,17 +165,10 @@ static inline int expect_matches(const struct nf_conntrack_expect *a,
/* Generally a bad idea to call this: could have matched already. */ /* Generally a bad idea to call this: could have matched already. */
void nf_ct_unexpect_related(struct nf_conntrack_expect *exp) void nf_ct_unexpect_related(struct nf_conntrack_expect *exp)
{ {
struct nf_conntrack_expect *i;
write_lock_bh(&nf_conntrack_lock); write_lock_bh(&nf_conntrack_lock);
/* choose the oldest expectation to evict */ if (del_timer(&exp->timeout)) {
list_for_each_entry_reverse(i, &nf_ct_expect_list, list) { nf_ct_unlink_expect(exp);
if (expect_matches(i, exp) && del_timer(&i->timeout)) { nf_ct_expect_put(exp);
nf_ct_unlink_expect(i);
write_unlock_bh(&nf_conntrack_lock);
nf_ct_expect_put(i);
return;
}
} }
write_unlock_bh(&nf_conntrack_lock); write_unlock_bh(&nf_conntrack_lock);
} }