]> err.no Git - linux-2.6/blobdiff - net/ipv6/netfilter/nf_conntrack_reasm.c
[8021Q]: vlan_ioctl_handler: fix return value
[linux-2.6] / net / ipv6 / netfilter / nf_conntrack_reasm.c
index 490e7e151f2d450eef8b993955946e4ec9a12e0a..25442a8c1ba82fec69f40226f31487d4b4adfddb 100644 (file)
 #include <linux/kernel.h>
 #include <linux/module.h>
 
-#if 0
-#define DEBUGP printk
-#else
-#define DEBUGP(format, args...)
-#endif
-
 #define NF_CT_FRAG6_HIGH_THRESH 262144 /* == 256*1024 */
 #define NF_CT_FRAG6_LOW_THRESH 196608  /* == 192*1024 */
 #define NF_CT_FRAG6_TIMEOUT IPV6_FRAG_TIMEOUT
@@ -343,7 +337,7 @@ nf_ct_frag6_create(unsigned int hash, __be32 id, struct in6_addr *src,                                 str
        struct nf_ct_frag6_queue *fq;
 
        if ((fq = frag_alloc_queue()) == NULL) {
-               DEBUGP("Can't alloc new queue\n");
+               pr_debug("Can't alloc new queue\n");
                goto oom;
        }
 
@@ -353,9 +347,7 @@ nf_ct_frag6_create(unsigned int hash, __be32 id, struct in6_addr *src,                                 str
        ipv6_addr_copy(&fq->saddr, src);
        ipv6_addr_copy(&fq->daddr, dst);
 
-       init_timer(&fq->timer);
-       fq->timer.function = nf_ct_frag6_expire;
-       fq->timer.data = (long) fq;
+       setup_timer(&fq->timer, nf_ct_frag6_expire, (unsigned long)fq);
        spin_lock_init(&fq->lock);
        atomic_set(&fq->refcnt, 1);
 
@@ -395,7 +387,7 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
        int offset, end;
 
        if (fq->last_in & COMPLETE) {
-               DEBUGP("Allready completed\n");
+               pr_debug("Allready completed\n");
                goto err;
        }
 
@@ -404,7 +396,7 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
                        ((u8 *)(fhdr + 1) - (u8 *)(ipv6_hdr(skb) + 1)));
 
        if ((unsigned int)end > IPV6_MAXPLEN) {
-               DEBUGP("offset is too large.\n");
+               pr_debug("offset is too large.\n");
                return -1;
        }
 
@@ -422,7 +414,7 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
                 */
                if (end < fq->len ||
                    ((fq->last_in & LAST_IN) && end != fq->len)) {
-                       DEBUGP("already received last fragment\n");
+                       pr_debug("already received last fragment\n");
                        goto err;
                }
                fq->last_in |= LAST_IN;
@@ -435,13 +427,13 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
                        /* RFC2460 says always send parameter problem in
                         * this case. -DaveM
                         */
-                       DEBUGP("the end of this fragment is not rounded to 8 bytes.\n");
+                       pr_debug("end of fragment not rounded to 8 bytes.\n");
                        return -1;
                }
                if (end > fq->len) {
                        /* Some bits beyond end -> corruption. */
                        if (fq->last_in & LAST_IN) {
-                               DEBUGP("last packet already reached.\n");
+                               pr_debug("last packet already reached.\n");
                                goto err;
                        }
                        fq->len = end;
@@ -453,11 +445,11 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
 
        /* Point into the IP datagram 'data' part. */
        if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) {
-               DEBUGP("queue: message is too short.\n");
+               pr_debug("queue: message is too short.\n");
                goto err;
        }
        if (pskb_trim_rcsum(skb, end - offset)) {
-               DEBUGP("Can't trim\n");
+               pr_debug("Can't trim\n");
                goto err;
        }
 
@@ -482,11 +474,11 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
                if (i > 0) {
                        offset += i;
                        if (end <= offset) {
-                               DEBUGP("overlap\n");
+                               pr_debug("overlap\n");
                                goto err;
                        }
                        if (!pskb_pull(skb, i)) {
-                               DEBUGP("Can't pull\n");
+                               pr_debug("Can't pull\n");
                                goto err;
                        }
                        if (skb->ip_summed != CHECKSUM_UNNECESSARY)
@@ -505,7 +497,7 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
                        /* Eat head of the next overlapped fragment
                         * and leave the loop. The next ones cannot overlap.
                         */
-                       DEBUGP("Eat head of the overlapped parts.: %d", i);
+                       pr_debug("Eat head of the overlapped parts.: %d", i);
                        if (!pskb_pull(next, i))
                                goto err;
 
@@ -588,13 +580,13 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev)
                       sizeof(struct ipv6hdr) + fq->len -
                       sizeof(struct frag_hdr));
        if (payload_len > IPV6_MAXPLEN) {
-               DEBUGP("payload len is too large.\n");
+               pr_debug("payload len is too large.\n");
                goto out_oversize;
        }
 
        /* Head of list must not be cloned. */
        if (skb_cloned(head) && pskb_expand_head(head, 0, 0, GFP_ATOMIC)) {
-               DEBUGP("skb is cloned but can't expand head");
+               pr_debug("skb is cloned but can't expand head");
                goto out_oom;
        }
 
@@ -606,7 +598,7 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev)
                int i, plen = 0;
 
                if ((clone = alloc_skb(0, GFP_ATOMIC)) == NULL) {
-                       DEBUGP("Can't alloc skb\n");
+                       pr_debug("Can't alloc skb\n");
                        goto out_oom;
                }
                clone->next = head->next;
@@ -630,8 +622,8 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev)
        skb_network_header(head)[fq->nhoffset] = skb_transport_header(head)[0];
        memmove(head->head + sizeof(struct frag_hdr), head->head,
                (head->data - head->head) - sizeof(struct frag_hdr));
-       head->mac.raw += sizeof(struct frag_hdr);
-       head->nh.raw += sizeof(struct frag_hdr);
+       head->mac_header += sizeof(struct frag_hdr);
+       head->network_header += sizeof(struct frag_hdr);
 
        skb_shinfo(head)->frag_list = head->next;
        skb_reset_transport_header(head);
@@ -707,8 +699,9 @@ static int
 find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
 {
        u8 nexthdr = ipv6_hdr(skb)->nexthdr;
-       u8 prev_nhoff = (u8 *)&ipv6_hdr(skb)->nexthdr - skb->data;
-       int start = (u8 *)(ipv6_hdr(skb) + 1) - skb->data;
+       const int netoff = skb_network_offset(skb);
+       u8 prev_nhoff = netoff + offsetof(struct ipv6hdr, nexthdr);
+       int start = netoff + sizeof(struct ipv6hdr);
        int len = skb->len - start;
        u8 prevhdr = NEXTHDR_IPV6;
 
@@ -720,11 +713,11 @@ find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
                        return -1;
                }
                if (len < (int)sizeof(struct ipv6_opt_hdr)) {
-                       DEBUGP("too short\n");
+                       pr_debug("too short\n");
                        return -1;
                }
                if (nexthdr == NEXTHDR_NONE) {
-                       DEBUGP("next header is none\n");
+                       pr_debug("next header is none\n");
                        return -1;
                }
                if (skb_copy_bits(skb, start, &hdr, sizeof(hdr)))
@@ -765,7 +758,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
 
        /* Jumbo payload inhibits frag. header */
        if (ipv6_hdr(skb)->payload_len == 0) {
-               DEBUGP("payload len = 0\n");
+               pr_debug("payload len = 0\n");
                return skb;
        }
 
@@ -774,14 +767,14 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
 
        clone = skb_clone(skb, GFP_ATOMIC);
        if (clone == NULL) {
-               DEBUGP("Can't clone skb\n");
+               pr_debug("Can't clone skb\n");
                return skb;
        }
 
        NFCT_FRAG6_CB(clone)->orig = skb;
 
        if (!pskb_may_pull(clone, fhoff + sizeof(*fhdr))) {
-               DEBUGP("message is too short.\n");
+               pr_debug("message is too short.\n");
                goto ret_orig;
        }
 
@@ -790,7 +783,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
        fhdr = (struct frag_hdr *)skb_transport_header(clone);
 
        if (!(fhdr->frag_off & htons(0xFFF9))) {
-               DEBUGP("Invalid fragment offset\n");
+               pr_debug("Invalid fragment offset\n");
                /* It is not a fragmented frame */
                goto ret_orig;
        }
@@ -800,7 +793,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
 
        fq = fq_find(fhdr->identification, &hdr->saddr, &hdr->daddr);
        if (fq == NULL) {
-               DEBUGP("Can't find and can't create new queue\n");
+               pr_debug("Can't find and can't create new queue\n");
                goto ret_orig;
        }
 
@@ -808,7 +801,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
 
        if (nf_ct_frag6_queue(fq, clone, fhdr, nhoff) < 0) {
                spin_unlock(&fq->lock);
-               DEBUGP("Can't insert skb to queue\n");
+               pr_debug("Can't insert skb to queue\n");
                fq_put(fq, NULL);
                goto ret_orig;
        }
@@ -816,7 +809,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
        if (fq->last_in == (FIRST_IN|LAST_IN) && fq->meat == fq->len) {
                ret_skb = nf_ct_frag6_reasm(fq, dev);
                if (ret_skb == NULL)
-                       DEBUGP("Can't reassemble fragmented packets\n");
+                       pr_debug("Can't reassemble fragmented packets\n");
        }
        spin_unlock(&fq->lock);
 
@@ -869,8 +862,7 @@ int nf_ct_frag6_init(void)
        nf_ct_frag6_hash_rnd = (u32) ((num_physpages ^ (num_physpages>>7)) ^
                                   (jiffies ^ (jiffies >> 6)));
 
-       init_timer(&nf_ct_frag6_secret_timer);
-       nf_ct_frag6_secret_timer.function = nf_ct_frag6_secret_rebuild;
+       setup_timer(&nf_ct_frag6_secret_timer, nf_ct_frag6_secret_rebuild, 0);
        nf_ct_frag6_secret_timer.expires = jiffies
                                           + nf_ct_frag6_secret_interval;
        add_timer(&nf_ct_frag6_secret_timer);