netfilter: netns nf_conntrack: pass netns pointer to L4 protocol's ->error hook
authorAlexey Dobriyan <adobriyan@gmail.com>
Wed, 8 Oct 2008 09:35:05 +0000 (11:35 +0200)
committerPatrick McHardy <kaber@trash.net>
Wed, 8 Oct 2008 09:35:05 +0000 (11:35 +0200)
Again, it's deducible from skb, but we're going to use it for
nf_conntrack_checksum and statistics, so just pass it from upper layer.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
include/net/netfilter/nf_conntrack_l4proto.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_proto_dccp.c
net/netfilter/nf_conntrack_proto_tcp.c
net/netfilter/nf_conntrack_proto_udp.c
net/netfilter/nf_conntrack_proto_udplite.c

index d4376e97bae84ff30991c74e56916e2f7cd4bbbd..97723d33c950e4d7cf54bee4092164ed32162552 100644 (file)
@@ -50,7 +50,7 @@ struct nf_conntrack_l4proto
        /* Called when a conntrack entry is destroyed */
        void (*destroy)(struct nf_conn *ct);
 
-       int (*error)(struct sk_buff *skb, unsigned int dataoff,
+       int (*error)(struct net *net, struct sk_buff *skb, unsigned int dataoff,
                     enum ip_conntrack_info *ctinfo,
                     u_int8_t pf, unsigned int hooknum);
 
index daf346377b66f87f272b225ab9ab47e4ec6799fb..8c7ed5bc9590acab3f58104a92a7ee5780d1a2fa 100644 (file)
@@ -123,7 +123,7 @@ static bool icmp_new(struct nf_conn *ct, const struct sk_buff *skb,
 
 /* Returns conntrack if it dealt with ICMP, and filled in skb fields */
 static int
-icmp_error_message(struct sk_buff *skb,
+icmp_error_message(struct net *net, struct sk_buff *skb,
                 enum ip_conntrack_info *ctinfo,
                 unsigned int hooknum)
 {
@@ -155,7 +155,7 @@ icmp_error_message(struct sk_buff *skb,
 
        *ctinfo = IP_CT_RELATED;
 
-       h = nf_conntrack_find_get(&init_net, &innertuple);
+       h = nf_conntrack_find_get(net, &innertuple);
        if (!h) {
                pr_debug("icmp_error_message: no match\n");
                return -NF_ACCEPT;
@@ -172,7 +172,7 @@ icmp_error_message(struct sk_buff *skb,
 
 /* Small and modified version of icmp_rcv */
 static int
-icmp_error(struct sk_buff *skb, unsigned int dataoff,
+icmp_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
           enum ip_conntrack_info *ctinfo, u_int8_t pf, unsigned int hooknum)
 {
        const struct icmphdr *icmph;
@@ -217,7 +217,7 @@ icmp_error(struct sk_buff *skb, unsigned int dataoff,
            && icmph->type != ICMP_REDIRECT)
                return NF_ACCEPT;
 
-       return icmp_error_message(skb, ctinfo, hooknum);
+       return icmp_error_message(net, skb, ctinfo, hooknum);
 }
 
 #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
index 548cf4f15c0844997da6b107fa0ef0e90a7711ac..aabddfe212788ecf87bc4aed7e0280ac028a228c 100644 (file)
@@ -122,7 +122,8 @@ static bool icmpv6_new(struct nf_conn *ct, const struct sk_buff *skb,
 }
 
 static int
-icmpv6_error_message(struct sk_buff *skb,
+icmpv6_error_message(struct net *net,
+                    struct sk_buff *skb,
                     unsigned int icmp6off,
                     enum ip_conntrack_info *ctinfo,
                     unsigned int hooknum)
@@ -156,7 +157,7 @@ icmpv6_error_message(struct sk_buff *skb,
 
        *ctinfo = IP_CT_RELATED;
 
-       h = nf_conntrack_find_get(&init_net, &intuple);
+       h = nf_conntrack_find_get(net, &intuple);
        if (!h) {
                pr_debug("icmpv6_error: no match\n");
                return -NF_ACCEPT;
@@ -172,7 +173,7 @@ icmpv6_error_message(struct sk_buff *skb,
 }
 
 static int
-icmpv6_error(struct sk_buff *skb, unsigned int dataoff,
+icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
             enum ip_conntrack_info *ctinfo, u_int8_t pf, unsigned int hooknum)
 {
        const struct icmp6hdr *icmp6h;
@@ -197,7 +198,7 @@ icmpv6_error(struct sk_buff *skb, unsigned int dataoff,
        if (icmp6h->icmp6_type >= 128)
                return NF_ACCEPT;
 
-       return icmpv6_error_message(skb, dataoff, ctinfo, hooknum);
+       return icmpv6_error_message(net, skb, dataoff, ctinfo, hooknum);
 }
 
 #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
index 5c96d9732c7b13ce2f1cb7a45a3bedef9deccb7d..251f020c7c1045ef8eca38ffa5dc6878f49f23a9 100644 (file)
@@ -703,11 +703,13 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
        /* It may be an special packet, error, unclean...
         * inverse of the return code tells to the netfilter
         * core what to do with the packet. */
-       if (l4proto->error != NULL &&
-           (ret = l4proto->error(skb, dataoff, &ctinfo, pf, hooknum)) <= 0) {
-               NF_CT_STAT_INC_ATOMIC(error);
-               NF_CT_STAT_INC_ATOMIC(invalid);
-               return -ret;
+       if (l4proto->error != NULL) {
+               ret = l4proto->error(net, skb, dataoff, &ctinfo, pf, hooknum);
+               if (ret <= 0) {
+                       NF_CT_STAT_INC_ATOMIC(error);
+                       NF_CT_STAT_INC_ATOMIC(invalid);
+                       return -ret;
+               }
        }
 
        ct = resolve_normal_ct(net, skb, dataoff, pf, protonum,
index edc30358dc19c9b63f7811dcaf44d72698b73b30..6ead8da3e9e63f13b9a88f4e1df66ca7364df87e 100644 (file)
@@ -545,9 +545,9 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
        return NF_ACCEPT;
 }
 
-static int dccp_error(struct sk_buff *skb, unsigned int dataoff,
-                     enum ip_conntrack_info *ctinfo, u_int8_t pf,
-                     unsigned int hooknum)
+static int dccp_error(struct net *net, struct sk_buff *skb,
+                     unsigned int dataoff, enum ip_conntrack_info *ctinfo,
+                     u_int8_t pf, unsigned int hooknum)
 {
        struct dccp_hdr _dh, *dh;
        unsigned int dccp_len = skb->len - dataoff;
index 539a8202025c0cfc6bf5c8d4c448fa48288d5811..4e71de2405fb5c6d3fe31d1450e167c3177f26a6 100644 (file)
@@ -746,7 +746,8 @@ static const u8 tcp_valid_flags[(TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG) + 1] =
 };
 
 /* Protect conntrack agaist broken packets. Code taken from ipt_unclean.c.  */
-static int tcp_error(struct sk_buff *skb,
+static int tcp_error(struct net *net,
+                    struct sk_buff *skb,
                     unsigned int dataoff,
                     enum ip_conntrack_info *ctinfo,
                     u_int8_t pf,
index 2a965c4a0eac49b33a489ac5a42f840b89e88dfd..8a245beb2c9e9a2490c2f674c6081be12a5c897b 100644 (file)
@@ -89,7 +89,7 @@ static bool udp_new(struct nf_conn *ct, const struct sk_buff *skb,
        return true;
 }
 
-static int udp_error(struct sk_buff *skb, unsigned int dataoff,
+static int udp_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
                     enum ip_conntrack_info *ctinfo,
                     u_int8_t pf,
                     unsigned int hooknum)
index 4fb6c8d83a842670fb3dae9d01c9145b29d521d8..981701919a754c0f271e6fe92d3a6c7633e554b7 100644 (file)
@@ -89,7 +89,9 @@ static bool udplite_new(struct nf_conn *ct, const struct sk_buff *skb,
        return true;
 }
 
-static int udplite_error(struct sk_buff *skb, unsigned int dataoff,
+static int udplite_error(struct net *net,
+                        struct sk_buff *skb,
+                        unsigned int dataoff,
                         enum ip_conntrack_info *ctinfo,
                         u_int8_t pf,
                         unsigned int hooknum)