]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv6/reassembly.c
ipv6: almost identical frag hashing funcs combined
[linux-2.6-omap-h63xx.git] / net / ipv6 / reassembly.c
index 6ab957ec2dd6d4a64bee43cc20d754e7e85ca579..2eeadfa039cbb0e84e81efe33eaca668b93d26a7 100644 (file)
@@ -99,8 +99,8 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
  * callers should be careful not to use the hash value outside the ipfrag_lock
  * as doing so could race with ipfrag_hash_rnd being recalculated.
  */
-static unsigned int ip6qhashfn(__be32 id, struct in6_addr *saddr,
-                              struct in6_addr *daddr)
+unsigned int inet6_hash_frag(__be32 id, const struct in6_addr *saddr,
+                            const struct in6_addr *daddr, u32 rnd)
 {
        u32 a, b, c;
 
@@ -110,7 +110,7 @@ static unsigned int ip6qhashfn(__be32 id, struct in6_addr *saddr,
 
        a += JHASH_GOLDEN_RATIO;
        b += JHASH_GOLDEN_RATIO;
-       c += ip6_frags.rnd;
+       c += rnd;
        __jhash_mix(a, b, c);
 
        a += (__force u32)saddr->s6_addr32[3];
@@ -125,13 +125,14 @@ static unsigned int ip6qhashfn(__be32 id, struct in6_addr *saddr,
 
        return c & (INETFRAGS_HASHSZ - 1);
 }
+EXPORT_SYMBOL_GPL(inet6_hash_frag);
 
 static unsigned int ip6_hashfn(struct inet_frag_queue *q)
 {
        struct frag_queue *fq;
 
        fq = container_of(q, struct frag_queue, q);
-       return ip6qhashfn(fq->id, &fq->saddr, &fq->daddr);
+       return inet6_hash_frag(fq->id, &fq->saddr, &fq->daddr, ip6_frags.rnd);
 }
 
 int ip6_frag_match(struct inet_frag_queue *q, void *a)
@@ -247,7 +248,7 @@ fq_find(struct net *net, __be32 id, struct in6_addr *src, struct in6_addr *dst,
        arg.dst = dst;
 
        read_lock(&ip6_frags.lock);
-       hash = ip6qhashfn(id, src, dst);
+       hash = inet6_hash_frag(id, src, dst, ip6_frags.rnd);
 
        q = inet_frag_find(&net->ipv6.frags, &ip6_frags, &arg, hash);
        if (q == NULL)
@@ -473,8 +474,8 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
                fq->q.fragments = head;
        }
 
-       BUG_TRAP(head != NULL);
-       BUG_TRAP(FRAG6_CB(head)->offset == 0);
+       WARN_ON(head == NULL);
+       WARN_ON(FRAG6_CB(head)->offset != 0);
 
        /* Unfragmented part is taken from the first segment. */
        payload_len = ((head->data - skb_network_header(head)) -