]> err.no Git - linux-2.6/blobdiff - net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc
[linux-2.6] / net / ipv4 / netfilter / nf_conntrack_l3proto_ipv4.c
index 3c562993848751d19fdc0d9b8b467b94aadae2b0..f813e02aab3022d890887f4ae4a50711305a6a2a 100644 (file)
@@ -78,21 +78,22 @@ nf_ct_ipv4_gather_frags(struct sk_buff *skb, u_int32_t user)
        return skb;
 }
 
-static int
-ipv4_prepare(struct sk_buff **pskb, unsigned int hooknum, unsigned int *dataoff,
-            u_int8_t *protonum)
+static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
+                           unsigned int *dataoff, u_int8_t *protonum)
 {
-       /* Never happen */
-       if (ip_hdr(*pskb)->frag_off & htons(IP_OFFSET)) {
-               if (net_ratelimit()) {
-                       printk(KERN_ERR "ipv4_prepare: Frag of proto %u (hook=%u)\n",
-                       ip_hdr(*pskb)->protocol, hooknum);
-               }
+       struct iphdr _iph, *iph;
+
+       iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph);
+       if (iph == NULL)
+               return -NF_DROP;
+
+       /* Conntrack defragments packets, we might still see fragments
+        * inside ICMP packets though. */
+       if (iph->frag_off & htons(IP_OFFSET))
                return -NF_DROP;
-       }
 
-       *dataoff = skb_network_offset(*pskb) + ip_hdrlen(*pskb);
-       *protonum = ip_hdr(*pskb)->protocol;
+       *dataoff = nhoff + (iph->ihl << 2);
+       *protonum = iph->protocol;
 
        return NF_ACCEPT;
 }
@@ -398,16 +399,17 @@ static struct nf_sockopt_ops so_getorigdst = {
        .get_optmin     = SO_ORIGINAL_DST,
        .get_optmax     = SO_ORIGINAL_DST+1,
        .get            = &getorigdst,
+       .owner          = THIS_MODULE,
 };
 
-struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4 = {
+struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4 __read_mostly = {
        .l3proto         = PF_INET,
        .name            = "ipv4",
        .pkt_to_tuple    = ipv4_pkt_to_tuple,
        .invert_tuple    = ipv4_invert_tuple,
        .print_tuple     = ipv4_print_tuple,
        .print_conntrack = ipv4_print_conntrack,
-       .prepare         = ipv4_prepare,
+       .get_l4proto     = ipv4_get_l4proto,
 #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
        .tuple_to_nfattr = ipv4_tuple_to_nfattr,
        .nfattr_to_tuple = ipv4_nfattr_to_tuple,
@@ -504,3 +506,9 @@ static void __exit nf_conntrack_l3proto_ipv4_fini(void)
 
 module_init(nf_conntrack_l3proto_ipv4_init);
 module_exit(nf_conntrack_l3proto_ipv4_fini);
+
+void need_ipv4_conntrack(void)
+{
+       return;
+}
+EXPORT_SYMBOL_GPL(need_ipv4_conntrack);