netfilter endian regressions
[pandora-kernel.git] / net / netfilter / nf_conntrack_core.c
index b730413..0fe1188 100644 (file)
@@ -79,7 +79,8 @@ static u_int32_t __hash_conntrack(const struct nf_conntrack_tuple *tuple,
        a = jhash2(tuple->src.u3.all, ARRAY_SIZE(tuple->src.u3.all),
                   (tuple->src.l3num << 16) | tuple->dst.protonum);
        b = jhash2(tuple->dst.u3.all, ARRAY_SIZE(tuple->dst.u3.all),
-                  (tuple->src.u.all << 16) | tuple->dst.u.all);
+                  ((__force __u16)tuple->src.u.all << 16) |
+                   (__force __u16)tuple->dst.u.all);
 
        return jhash_2words(a, b, rnd) % size;
 }
@@ -113,6 +114,36 @@ nf_ct_get_tuple(const struct sk_buff *skb,
 }
 EXPORT_SYMBOL_GPL(nf_ct_get_tuple);
 
+int nf_ct_get_tuplepr(const struct sk_buff *skb,
+                     unsigned int nhoff,
+                     u_int16_t l3num,
+                     struct nf_conntrack_tuple *tuple)
+{
+       struct nf_conntrack_l3proto *l3proto;
+       struct nf_conntrack_l4proto *l4proto;
+       unsigned int protoff;
+       u_int8_t protonum;
+       int ret;
+
+       rcu_read_lock();
+
+       l3proto = __nf_ct_l3proto_find(l3num);
+       ret = l3proto->get_l4proto(skb, nhoff, &protoff, &protonum);
+       if (ret != NF_ACCEPT) {
+               rcu_read_unlock();
+               return 0;
+       }
+
+       l4proto = __nf_ct_l4proto_find(l3num, protonum);
+
+       ret = nf_ct_get_tuple(skb, nhoff, protoff, l3num, protonum, tuple,
+                             l3proto, l4proto);
+
+       rcu_read_unlock();
+       return ret;
+}
+EXPORT_SYMBOL_GPL(nf_ct_get_tuplepr);
+
 int
 nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
                   const struct nf_conntrack_tuple *orig,
@@ -622,8 +653,9 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff **pskb)
 
        /* rcu_read_lock()ed by nf_hook_slow */
        l3proto = __nf_ct_l3proto_find((u_int16_t)pf);
-
-       if ((ret = l3proto->prepare(pskb, hooknum, &dataoff, &protonum)) <= 0) {
+       ret = l3proto->get_l4proto(*pskb, skb_network_offset(*pskb),
+                                  &dataoff, &protonum);
+       if (ret <= 0) {
                pr_debug("not prepared to track yet or error occured\n");
                NF_CT_STAT_INC_ATOMIC(error);
                NF_CT_STAT_INC_ATOMIC(invalid);
@@ -1077,7 +1109,7 @@ int __init nf_conntrack_init(void)
 
        nf_conntrack_cachep = kmem_cache_create("nf_conntrack",
                                                sizeof(struct nf_conn),
-                                               0, 0, NULL, NULL);
+                                               0, 0, NULL);
        if (!nf_conntrack_cachep) {
                printk(KERN_ERR "Unable to create nf_conn slab cache\n");
                goto err_free_hash;