Skip to content

Commit efd1e8d

Browse files
kaberDavid S. Miller
authored andcommitted
[SK_BUFF]: Fix missing offset adjustment in skb_copy_expand
skb_copy_expand changes the headroom, so it needs to adjust the header offsets by the difference between the old and the new value. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3303680 commit efd1e8d

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎net/core/skbuff.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,9 @@ struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
736736
*/
737737
struct sk_buff *n = alloc_skb(newheadroom + skb->len + newtailroom,
738738
gfp_mask);
739+
int oldheadroom = skb_headroom(skb);
739740
int head_copy_len, head_copy_off;
741+
int off = 0;
740742

741743
if (!n)
742744
return NULL;
@@ -746,7 +748,7 @@ struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
746748
/* Set the tail pointer and length */
747749
skb_put(n, skb->len);
748750

749-
head_copy_len = skb_headroom(skb);
751+
head_copy_len = oldheadroom;
750752
head_copy_off = 0;
751753
if (newheadroom <= head_copy_len)
752754
head_copy_len = newheadroom;
@@ -760,6 +762,13 @@ struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
760762

761763
copy_skb_header(n, skb);
762764

765+
#ifdef NET_SKBUFF_DATA_USES_OFFSET
766+
off = newheadroom - oldheadroom;
767+
#endif
768+
n->transport_header += off;
769+
n->network_header += off;
770+
n->mac_header += off;
771+
763772
return n;
764773
}
765774

0 commit comments

Comments
 (0)