Skip to content

Commit 76f12e6

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: ctnetlink: remove expired entries first
When dumping conntrack table to userspace via ctnetlink, check if the ct has already expired before doing any of the 'skip' checks. This expires dead entries faster. /proc handler also removes outdated entries first. Reported-by: Vitaly Zuevsky <[email protected]> Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent ebb966d commit 76f12e6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/netfilter/nf_conntrack_netlink.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,8 +1195,6 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
11951195
}
11961196
hlist_nulls_for_each_entry(h, n, &nf_conntrack_hash[cb->args[0]],
11971197
hnnode) {
1198-
if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL)
1199-
continue;
12001198
ct = nf_ct_tuplehash_to_ctrack(h);
12011199
if (nf_ct_is_expired(ct)) {
12021200
if (i < ARRAY_SIZE(nf_ct_evict) &&
@@ -1208,6 +1206,9 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
12081206
if (!net_eq(net, nf_ct_net(ct)))
12091207
continue;
12101208

1209+
if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL)
1210+
continue;
1211+
12111212
if (cb->args[1]) {
12121213
if (ct != last)
12131214
continue;

0 commit comments

Comments
 (0)