diff options
-rw-r--r-- | net/netfilter/nf_conntrack_netlink.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 746140264b2d..5cb8d3027b18 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -645,25 +645,23 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) | |||
645 | struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh); | 645 | struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh); |
646 | u_int8_t l3proto = nfmsg->nfgen_family; | 646 | u_int8_t l3proto = nfmsg->nfgen_family; |
647 | 647 | ||
648 | rcu_read_lock(); | 648 | spin_lock_bh(&nf_conntrack_lock); |
649 | last = (struct nf_conn *)cb->args[1]; | 649 | last = (struct nf_conn *)cb->args[1]; |
650 | for (; cb->args[0] < net->ct.htable_size; cb->args[0]++) { | 650 | for (; cb->args[0] < net->ct.htable_size; cb->args[0]++) { |
651 | restart: | 651 | restart: |
652 | hlist_nulls_for_each_entry_rcu(h, n, &net->ct.hash[cb->args[0]], | 652 | hlist_nulls_for_each_entry(h, n, &net->ct.hash[cb->args[0]], |
653 | hnnode) { | 653 | hnnode) { |
654 | if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL) | 654 | if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL) |
655 | continue; | 655 | continue; |
656 | ct = nf_ct_tuplehash_to_ctrack(h); | 656 | ct = nf_ct_tuplehash_to_ctrack(h); |
657 | if (!atomic_inc_not_zero(&ct->ct_general.use)) | ||
658 | continue; | ||
659 | /* Dump entries of a given L3 protocol number. | 657 | /* Dump entries of a given L3 protocol number. |
660 | * If it is not specified, ie. l3proto == 0, | 658 | * If it is not specified, ie. l3proto == 0, |
661 | * then dump everything. */ | 659 | * then dump everything. */ |
662 | if (l3proto && nf_ct_l3num(ct) != l3proto) | 660 | if (l3proto && nf_ct_l3num(ct) != l3proto) |
663 | goto releasect; | 661 | continue; |
664 | if (cb->args[1]) { | 662 | if (cb->args[1]) { |
665 | if (ct != last) | 663 | if (ct != last) |
666 | goto releasect; | 664 | continue; |
667 | cb->args[1] = 0; | 665 | cb->args[1] = 0; |
668 | } | 666 | } |
669 | if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid, | 667 | if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid, |
@@ -681,8 +679,6 @@ restart: | |||
681 | if (acct) | 679 | if (acct) |
682 | memset(acct, 0, sizeof(struct nf_conn_counter[IP_CT_DIR_MAX])); | 680 | memset(acct, 0, sizeof(struct nf_conn_counter[IP_CT_DIR_MAX])); |
683 | } | 681 | } |
684 | releasect: | ||
685 | nf_ct_put(ct); | ||
686 | } | 682 | } |
687 | if (cb->args[1]) { | 683 | if (cb->args[1]) { |
688 | cb->args[1] = 0; | 684 | cb->args[1] = 0; |
@@ -690,7 +686,7 @@ releasect: | |||
690 | } | 686 | } |
691 | } | 687 | } |
692 | out: | 688 | out: |
693 | rcu_read_unlock(); | 689 | spin_unlock_bh(&nf_conntrack_lock); |
694 | if (last) | 690 | if (last) |
695 | nf_ct_put(last); | 691 | nf_ct_put(last); |
696 | 692 | ||