]> err.no Git - linux-2.6/blobdiff - net/core/skbuff.c
[NET] CORE: Fix whitespace errors.
[linux-2.6] / net / core / skbuff.c
index 32f087b5233e73cbc46bdfe5f9b901affb539ef2..0583e8498f1351d2631024fd811ecdd1172da27c 100644 (file)
@@ -415,9 +415,11 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
        C(csum);
        C(local_df);
        n->cloned = 1;
+       n->hdr_len = skb->nohdr ? skb_headroom(skb) : skb->hdr_len;
        n->nohdr = 0;
        C(pkt_type);
        C(ip_summed);
+       skb_copy_queue_mapping(n, skb);
        C(priority);
 #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
        C(ipvs_property);
@@ -426,6 +428,10 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
        n->destructor = NULL;
        C(mark);
        __nf_copy(n, skb);
+#if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \
+    defined(CONFIG_NETFILTER_XT_TARGET_TRACE_MODULE)
+       C(nf_trace);
+#endif
 #ifdef CONFIG_NET_SCHED
        C(tc_index);
 #ifdef CONFIG_NET_CLS_ACT
@@ -434,8 +440,8 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
        n->tc_verd = CLR_TC_MUNGED(n->tc_verd);
        C(iif);
 #endif
-       skb_copy_secmark(n, skb);
 #endif
+       skb_copy_secmark(n, skb);
        C(truesize);
        atomic_set(&n->users, 1);
        C(head);
@@ -459,6 +465,7 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
 #endif
        new->sk         = NULL;
        new->dev        = old->dev;
+       skb_copy_queue_mapping(new, old);
        new->priority   = old->priority;
        new->protocol   = old->protocol;
        new->dst        = dst_clone(old->dst);
@@ -482,6 +489,10 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
        new->destructor = NULL;
        new->mark       = old->mark;
        __nf_copy(new, old);
+#if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \
+    defined(CONFIG_NETFILTER_XT_TARGET_TRACE_MODULE)
+       new->nf_trace   = old->nf_trace;
+#endif
 #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
        new->ipvs_property = old->ipvs_property;
 #endif
@@ -644,11 +655,10 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
 
        /* Copy only real data... and, alas, header. This should be
         * optimized for the cases when header is void. */
-       memcpy(data + nhead, skb->head,
 #ifdef NET_SKBUFF_DATA_USES_OFFSET
-               skb->tail);
+       memcpy(data + nhead, skb->head, skb->tail);
 #else
-               skb->tail - skb->head);
+       memcpy(data + nhead, skb->head, skb->tail - skb->head);
 #endif
        memcpy(data + size, skb_end_pointer(skb),
               sizeof(struct skb_shared_info));
@@ -677,6 +687,7 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
        skb->network_header   += off;
        skb->mac_header       += off;
        skb->cloned   = 0;
+       skb->hdr_len  = 0;
        skb->nohdr    = 0;
        atomic_set(&skb_shinfo(skb)->dataref, 1);
        return 0;
@@ -1045,13 +1056,13 @@ pull_pages:
 int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len)
 {
        int i, copy;
-       int end = skb_headlen(skb);
+       int start = skb_headlen(skb);
 
        if (offset > (int)skb->len - len)
                goto fault;
 
        /* Copy header. */
-       if ((copy = end - offset) > 0) {
+       if ((copy = start - offset) > 0) {
                if (copy > len)
                        copy = len;
                skb_copy_from_linear_data_offset(skb, offset, to, copy);
@@ -1062,9 +1073,11 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len)
        }
 
        for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
-               BUG_TRAP(len >= 0);
+               int end;
+
+               BUG_TRAP(start <= offset + len);
 
-               end = offset + skb_shinfo(skb)->frags[i].size;
+               end = start + skb_shinfo(skb)->frags[i].size;
                if ((copy = end - offset) > 0) {
                        u8 *vaddr;
 
@@ -1073,8 +1086,8 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len)
 
                        vaddr = kmap_skb_frag(&skb_shinfo(skb)->frags[i]);
                        memcpy(to,
-                              vaddr + skb_shinfo(skb)->frags[i].page_offset,
-                              copy);
+                              vaddr + skb_shinfo(skb)->frags[i].page_offset+
+                              offset - start, copy);
                        kunmap_skb_frag(vaddr);
 
                        if ((len -= copy) == 0)
@@ -1082,25 +1095,30 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len)
                        offset += copy;
                        to     += copy;
                }
+               start = end;
        }
 
        if (skb_shinfo(skb)->frag_list) {
                struct sk_buff *list = skb_shinfo(skb)->frag_list;
 
                for (; list; list = list->next) {
-                       BUG_TRAP(len >= 0);
+                       int end;
 
-                       end = offset + list->len;
+                       BUG_TRAP(start <= offset + len);
+
+                       end = start + list->len;
                        if ((copy = end - offset) > 0) {
                                if (copy > len)
                                        copy = len;
-                               if (skb_copy_bits(list, 0, to, copy))
+                               if (skb_copy_bits(list, offset - start,
+                                                 to, copy))
                                        goto fault;
                                if ((len -= copy) == 0)
                                        return 0;
                                offset += copy;
                                to     += copy;
                        }
+                       start = end;
                }
        }
        if (!len)
@@ -1125,12 +1143,12 @@ fault:
 int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len)
 {
        int i, copy;
-       int end = skb_headlen(skb);
+       int start = skb_headlen(skb);
 
        if (offset > (int)skb->len - len)
                goto fault;
 
-       if ((copy = end - offset) > 0) {
+       if ((copy = start - offset) > 0) {
                if (copy > len)
                        copy = len;
                skb_copy_to_linear_data_offset(skb, offset, from, copy);
@@ -1142,9 +1160,11 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len)
 
        for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
                skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
-               BUG_TRAP(len >= 0);
+               int end;
+
+               BUG_TRAP(start <= offset + len);
 
-               end = offset + frag->size;
+               end = start + frag->size;
                if ((copy = end - offset) > 0) {
                        u8 *vaddr;
 
@@ -1152,7 +1172,8 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len)
                                copy = len;
 
                        vaddr = kmap_skb_frag(frag);
-                       memcpy(vaddr + frag->page_offset, from, copy);
+                       memcpy(vaddr + frag->page_offset + offset - start,
+                              from, copy);
                        kunmap_skb_frag(vaddr);
 
                        if ((len -= copy) == 0)
@@ -1160,25 +1181,30 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len)
                        offset += copy;
                        from += copy;
                }
+               start = end;
        }
 
        if (skb_shinfo(skb)->frag_list) {
                struct sk_buff *list = skb_shinfo(skb)->frag_list;
 
                for (; list; list = list->next) {
-                       BUG_TRAP(len >= 0);
+                       int end;
 
-                       end = offset + list->len;
+                       BUG_TRAP(start <= offset + len);
+
+                       end = start + list->len;
                        if ((copy = end - offset) > 0) {
                                if (copy > len)
                                        copy = len;
-                               if (skb_store_bits(list, 0, from, copy))
+                               if (skb_store_bits(list, offset - start,
+                                                  from, copy))
                                        goto fault;
                                if ((len -= copy) == 0)
                                        return 0;
                                offset += copy;
                                from += copy;
                        }
+                       start = end;
                }
        }
        if (!len)
@@ -1195,8 +1221,8 @@ EXPORT_SYMBOL(skb_store_bits);
 __wsum skb_checksum(const struct sk_buff *skb, int offset,
                          int len, __wsum csum)
 {
-       int end = skb_headlen(skb);
-       int i, copy = end - offset;
+       int start = skb_headlen(skb);
+       int i, copy = start - offset;
        int pos = 0;
 
        /* Checksum header. */
@@ -1211,9 +1237,11 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset,
        }
 
        for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
-               BUG_TRAP(len >= 0);
+               int end;
+
+               BUG_TRAP(start <= offset + len);
 
-               end = offset + skb_shinfo(skb)->frags[i].size;
+               end = start + skb_shinfo(skb)->frags[i].size;
                if ((copy = end - offset) > 0) {
                        __wsum csum2;
                        u8 *vaddr;
@@ -1222,8 +1250,8 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset,
                        if (copy > len)
                                copy = len;
                        vaddr = kmap_skb_frag(frag);
-                       csum2 = csum_partial(vaddr + frag->page_offset,
-                                            copy, 0);
+                       csum2 = csum_partial(vaddr + frag->page_offset +
+                                            offset - start, copy, 0);
                        kunmap_skb_frag(vaddr);
                        csum = csum_block_add(csum, csum2, pos);
                        if (!(len -= copy))
@@ -1231,26 +1259,31 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset,
                        offset += copy;
                        pos    += copy;
                }
+               start = end;
        }
 
        if (skb_shinfo(skb)->frag_list) {
                struct sk_buff *list = skb_shinfo(skb)->frag_list;
 
                for (; list; list = list->next) {
-                       BUG_TRAP(len >= 0);
+                       int end;
 
-                       end = offset + list->len;
+                       BUG_TRAP(start <= offset + len);
+
+                       end = start + list->len;
                        if ((copy = end - offset) > 0) {
                                __wsum csum2;
                                if (copy > len)
                                        copy = len;
-                               csum2 = skb_checksum(list, 0, copy, 0);
+                               csum2 = skb_checksum(list, offset - start,
+                                                    copy, 0);
                                csum = csum_block_add(csum, csum2, pos);
                                if ((len -= copy) == 0)
                                        return csum;
                                offset += copy;
                                pos    += copy;
                        }
+                       start = end;
                }
        }
        BUG_ON(len);
@@ -1263,8 +1296,8 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset,
 __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
                                    u8 *to, int len, __wsum csum)
 {
-       int end = skb_headlen(skb);
-       int i, copy = end - offset;
+       int start = skb_headlen(skb);
+       int i, copy = start - offset;
        int pos = 0;
 
        /* Copy header. */
@@ -1281,9 +1314,11 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
        }
 
        for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
-               BUG_TRAP(len >= 0);
+               int end;
+
+               BUG_TRAP(start <= offset + len);
 
-               end = offset + skb_shinfo(skb)->frags[i].size;
+               end = start + skb_shinfo(skb)->frags[i].size;
                if ((copy = end - offset) > 0) {
                        __wsum csum2;
                        u8 *vaddr;
@@ -1293,8 +1328,9 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
                                copy = len;
                        vaddr = kmap_skb_frag(frag);
                        csum2 = csum_partial_copy_nocheck(vaddr +
-                                                         frag->page_offset,
-                                                         to, copy, 0);
+                                                         frag->page_offset +
+                                                         offset - start, to,
+                                                         copy, 0);
                        kunmap_skb_frag(vaddr);
                        csum = csum_block_add(csum, csum2, pos);
                        if (!(len -= copy))
@@ -1303,6 +1339,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
                        to     += copy;
                        pos    += copy;
                }
+               start = end;
        }
 
        if (skb_shinfo(skb)->frag_list) {
@@ -1310,13 +1347,16 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
 
                for (; list; list = list->next) {
                        __wsum csum2;
-                       BUG_TRAP(len >= 0);
+                       int end;
 
-                       end = offset + list->len;
+                       BUG_TRAP(start <= offset + len);
+
+                       end = start + list->len;
                        if ((copy = end - offset) > 0) {
                                if (copy > len)
                                        copy = len;
-                               csum2 = skb_copy_and_csum_bits(list, 0,
+                               csum2 = skb_copy_and_csum_bits(list,
+                                                              offset - start,
                                                               to, copy, 0);
                                csum = csum_block_add(csum, csum2, pos);
                                if ((len -= copy) == 0)
@@ -1325,6 +1365,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
                                to     += copy;
                                pos    += copy;
                        }
+                       start = end;
                }
        }
        BUG_ON(len);
@@ -1677,6 +1718,11 @@ next_skb:
                st->stepped_offset += frag->size;
        }
 
+       if (st->frag_data) {
+               kunmap_skb_frag(st->frag_data);
+               st->frag_data = NULL;
+       }
+
        if (st->cur_skb->next) {
                st->cur_skb = st->cur_skb->next;
                st->frag_idx = 0;
@@ -1896,6 +1942,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features)
                tail = nskb;
 
                nskb->dev = skb->dev;
+               skb_copy_queue_mapping(nskb, skb);
                nskb->priority = skb->priority;
                nskb->protocol = skb->protocol;
                nskb->dst = dst_clone(skb->dst);
@@ -1996,8 +2043,8 @@ void __init skb_init(void)
 int
 skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
 {
-       int end = skb_headlen(skb);
-       int i, copy = end - offset;
+       int start = skb_headlen(skb);
+       int i, copy = start - offset;
        int elt = 0;
 
        if (copy > 0) {
@@ -2013,39 +2060,45 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
        }
 
        for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
-               BUG_TRAP(len >= 0);
+               int end;
 
-               end = offset + skb_shinfo(skb)->frags[i].size;
+               BUG_TRAP(start <= offset + len);
+
+               end = start + skb_shinfo(skb)->frags[i].size;
                if ((copy = end - offset) > 0) {
                        skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
 
                        if (copy > len)
                                copy = len;
                        sg[elt].page = frag->page;
-                       sg[elt].offset = frag->page_offset;
+                       sg[elt].offset = frag->page_offset+offset-start;
                        sg[elt].length = copy;
                        elt++;
                        if (!(len -= copy))
                                return elt;
                        offset += copy;
                }
+               start = end;
        }
 
        if (skb_shinfo(skb)->frag_list) {
                struct sk_buff *list = skb_shinfo(skb)->frag_list;
 
                for (; list; list = list->next) {
-                       BUG_TRAP(len >= 0);
+                       int end;
+
+                       BUG_TRAP(start <= offset + len);
 
-                       end = offset + list->len;
+                       end = start + list->len;
                        if ((copy = end - offset) > 0) {
                                if (copy > len)
                                        copy = len;
-                               elt += skb_to_sgvec(list, sg+elt, 0, copy);
+                               elt += skb_to_sgvec(list, sg+elt, offset - start, copy);
                                if ((len -= copy) == 0)
                                        return elt;
                                offset += copy;
                        }
+                       start = end;
                }
        }
        BUG_ON(len);
@@ -2171,7 +2224,6 @@ EXPORT_SYMBOL(pskb_copy);
 EXPORT_SYMBOL(pskb_expand_head);
 EXPORT_SYMBOL(skb_checksum);
 EXPORT_SYMBOL(skb_clone);
-EXPORT_SYMBOL(skb_clone_fraglist);
 EXPORT_SYMBOL(skb_copy);
 EXPORT_SYMBOL(skb_copy_and_csum_bits);
 EXPORT_SYMBOL(skb_copy_and_csum_dev);