aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@eurodev.net>2005-08-09 23:06:42 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2005-08-29 18:40:25 -0400
commitff21d5774b4a186c98be6398eacde75d896db804 (patch)
treef2b1da2cec09742fd9b5e90479e2ebb2068ea1e8 /net
parent28b19d99ac6d92e4fb2fe34144c495019a638a64 (diff)
[NETFILTER]: fix list traversal order in ctnetlink
Currently conntracks are inserted after the head. That means that conntracks are sorted from the biggest to the smallest id. This happens because we use list_prepend (list_add) instead list_add_tail. This can result in problems during the list iteration. list_for_each(i, &ip_conntrack_hash[cb->args[0]]) { h = (struct ip_conntrack_tuple_hash *) i; if (DIRECTION(h) != IP_CT_DIR_ORIGINAL) continue; ct = tuplehash_to_ctrack(h); if (ct->id <= *id) continue; In that case just the first conntrack in the bucket will be dumped. To fix this, we iterate the list from the tail to the head via list_for_each_prev. Same thing for the list of expectations. Signed-off-by: Pablo Neira Ayuso <pablo@eurodev.net> Signed-off-by: Harald Welte <laforge@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netlink.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c
index e3ba449e3e1d..1221a9c8bac2 100644
--- a/net/ipv4/netfilter/ip_conntrack_netlink.c
+++ b/net/ipv4/netfilter/ip_conntrack_netlink.c
@@ -404,7 +404,7 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
404 404
405 read_lock_bh(&ip_conntrack_lock); 405 read_lock_bh(&ip_conntrack_lock);
406 for (; cb->args[0] < ip_conntrack_htable_size; cb->args[0]++, *id = 0) { 406 for (; cb->args[0] < ip_conntrack_htable_size; cb->args[0]++, *id = 0) {
407 list_for_each(i, &ip_conntrack_hash[cb->args[0]]) { 407 list_for_each_prev(i, &ip_conntrack_hash[cb->args[0]]) {
408 h = (struct ip_conntrack_tuple_hash *) i; 408 h = (struct ip_conntrack_tuple_hash *) i;
409 if (DIRECTION(h) != IP_CT_DIR_ORIGINAL) 409 if (DIRECTION(h) != IP_CT_DIR_ORIGINAL)
410 continue; 410 continue;
@@ -441,7 +441,7 @@ ctnetlink_dump_table_w(struct sk_buff *skb, struct netlink_callback *cb)
441 441
442 write_lock_bh(&ip_conntrack_lock); 442 write_lock_bh(&ip_conntrack_lock);
443 for (; cb->args[0] < ip_conntrack_htable_size; cb->args[0]++, *id = 0) { 443 for (; cb->args[0] < ip_conntrack_htable_size; cb->args[0]++, *id = 0) {
444 list_for_each(i, &ip_conntrack_hash[cb->args[0]]) { 444 list_for_each_prev(i, &ip_conntrack_hash[cb->args[0]]) {
445 h = (struct ip_conntrack_tuple_hash *) i; 445 h = (struct ip_conntrack_tuple_hash *) i;
446 if (DIRECTION(h) != IP_CT_DIR_ORIGINAL) 446 if (DIRECTION(h) != IP_CT_DIR_ORIGINAL)
447 continue; 447 continue;
@@ -1214,7 +1214,7 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
1214 DEBUGP("entered %s, last id=%llu\n", __FUNCTION__, *id); 1214 DEBUGP("entered %s, last id=%llu\n", __FUNCTION__, *id);
1215 1215
1216 read_lock_bh(&ip_conntrack_lock); 1216 read_lock_bh(&ip_conntrack_lock);
1217 list_for_each(i, &ip_conntrack_expect_list) { 1217 list_for_each_prev(i, &ip_conntrack_expect_list) {
1218 exp = (struct ip_conntrack_expect *) i; 1218 exp = (struct ip_conntrack_expect *) i;
1219 if (exp->id <= *id) 1219 if (exp->id <= *id)
1220 continue; 1220 continue;