]> err.no Git - linux-2.6/commitdiff
netfilter: nf_conntrack: add nf_ct_kill()
authorPatrick McHardy <kaber@trash.net>
Mon, 9 Jun 2008 22:59:06 +0000 (15:59 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 9 Jun 2008 22:59:06 +0000 (15:59 -0700)
Encapsulate the common

if (del_timer(&ct->timeout))
ct->timeout.function((unsigned long)ct)

sequence in a new function.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/netfilter/nf_conntrack.h
net/ipv4/netfilter/nf_conntrack_proto_icmp.c
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_conntrack_netlink.c
net/netfilter/nf_conntrack_proto_dccp.c
net/netfilter/nf_conntrack_proto_tcp.c

index 2dbd6c015b947da0f1b21cc4d14201241e6bc8d9..fc19ab23eeaafea6efa29b544dc5be26af3df1e2 100644 (file)
@@ -223,6 +223,8 @@ static inline void nf_ct_refresh(struct nf_conn *ct,
        __nf_ct_refresh_acct(ct, 0, skb, extra_jiffies, 0);
 }
 
+extern void nf_ct_kill(struct nf_conn *ct);
+
 /* These are for NAT.  Icky. */
 /* Update TCP window tracking data when NAT mangles the packet */
 extern void nf_conntrack_tcp_update(const struct sk_buff *skb,
index 78ab19accace2ee84e282c534250920fad82ebce..0e21a46184fb06d09c9e1c0092a26d40b1a7587d 100644 (file)
@@ -87,9 +87,8 @@ static int icmp_packet(struct nf_conn *ct,
           means this will only run once even if count hits zero twice
           (theoretically possible with SMP) */
        if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY) {
-               if (atomic_dec_and_test(&ct->proto.icmp.count)
-                   && del_timer(&ct->timeout))
-                       ct->timeout.function((unsigned long)ct);
+               if (atomic_dec_and_test(&ct->proto.icmp.count))
+                       nf_ct_kill(ct);
        } else {
                atomic_inc(&ct->proto.icmp.count);
                nf_conntrack_event_cache(IPCT_PROTOINFO_VOLATILE, skb);
index ee713b03e9ec81f252dc0b45a499a2769583ba55..fe081b90e05ebf7c4d573b09c4fca7e0c716d392 100644 (file)
@@ -89,9 +89,8 @@ static int icmpv6_packet(struct nf_conn *ct,
           means this will only run once even if count hits zero twice
           (theoretically possible with SMP) */
        if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY) {
-               if (atomic_dec_and_test(&ct->proto.icmp.count)
-                   && del_timer(&ct->timeout))
-                       ct->timeout.function((unsigned long)ct);
+               if (atomic_dec_and_test(&ct->proto.icmp.count))
+                       nf_ct_kill(ct);
        } else {
                atomic_inc(&ct->proto.icmp.count);
                nf_conntrack_event_cache(IPCT_PROTOINFO_VOLATILE, skb);
index c4b1799da5d76ac98920527e9fe85d30866ff9c8..79b07c35eb872a80fe7b6f464584ca05a38769cb 100644 (file)
@@ -848,6 +848,13 @@ acct:
 }
 EXPORT_SYMBOL_GPL(__nf_ct_refresh_acct);
 
+void nf_ct_kill(struct nf_conn *ct)
+{
+       if (del_timer(&ct->timeout))
+               ct->timeout.function((unsigned long)ct);
+}
+EXPORT_SYMBOL_GPL(nf_ct_kill);
+
 #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
 
 #include <linux/netfilter/nfnetlink.h>
index 13918c1fbf6675a05fc2822ae7042af649a39227..ab655f660dfa225f95ec24bbc2bed73b4c1baa7a 100644 (file)
@@ -812,9 +812,8 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
                        return -ENOENT;
                }
        }
-       if (del_timer(&ct->timeout))
-               ct->timeout.function((unsigned long)ct);
 
+       nf_ct_kill(ct);
        nf_ct_put(ct);
 
        return 0;
index afb4a1861d2c3708f6ae606de3095a75e0fc76c3..223742f371f9a4d1cc3e56f88ac843c2bc545045 100644 (file)
@@ -475,8 +475,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
        if (type == DCCP_PKT_RESET &&
            !test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
                /* Tear down connection immediately if only reply is a RESET */
-               if (del_timer(&ct->timeout))
-                       ct->timeout.function((unsigned long)ct);
+               nf_ct_kill(ct);
                return NF_ACCEPT;
        }
 
index ba94004fe323182b6a527507548a1e54e1099321..c4aa11e01405ae704b3f3f45403d98e92dd6b10a 100644 (file)
@@ -843,8 +843,7 @@ static int tcp_packet(struct nf_conn *ct,
                        /* Attempt to reopen a closed/aborted connection.
                         * Delete this connection and look up again. */
                        write_unlock_bh(&tcp_lock);
-                       if (del_timer(&ct->timeout))
-                               ct->timeout.function((unsigned long)ct);
+                       nf_ct_kill(ct);
                        return -NF_REPEAT;
                }
                /* Fall through */
@@ -877,8 +876,7 @@ static int tcp_packet(struct nf_conn *ct,
                        if (LOG_INVALID(IPPROTO_TCP))
                                nf_log_packet(pf, 0, skb, NULL, NULL, NULL,
                                          "nf_ct_tcp: killing out of sync session ");
-                       if (del_timer(&ct->timeout))
-                               ct->timeout.function((unsigned long)ct);
+                       nf_ct_kill(ct);
                        return -NF_DROP;
                }
                ct->proto.tcp.last_index = index;
@@ -961,8 +959,7 @@ static int tcp_packet(struct nf_conn *ct,
                   problem case, so we can delete the conntrack
                   immediately.  --RR */
                if (th->rst) {
-                       if (del_timer(&ct->timeout))
-                               ct->timeout.function((unsigned long)ct);
+                       nf_ct_kill(ct);
                        return NF_ACCEPT;
                }
        } else if (!test_bit(IPS_ASSURED_BIT, &ct->status)