path: root/net/core/skbuff.c
diff options
authorDaniel Borkmann <>2016-04-16 02:27:58 +0200
committerDavid S. Miller <>2016-04-15 23:20:11 -0400
commit9241e2df4fbc648a92ea0752918e05c26255649e (patch)
treea4140463f6cdb8ac8471238b1dc59130258f559d /net/core/skbuff.c
parentcfe255600154f0072d4a8695590dbd194dfd1aeb (diff)
vlan: pull on __vlan_insert_tag error path and fix csum correction
When __vlan_insert_tag() fails from skb_vlan_push() path due to the skb_cow_head(), we need to undo the __skb_push() in the error path as well that was done earlier to move skb->data pointer to mac header. Moreover, I noticed that when in the non-error path the __skb_pull() is done and the original offset to mac header was non-zero, we fixup from a wrong skb->data offset in the checksum complete processing. So the skb_postpush_rcsum() really needs to be done before __skb_pull() where skb->data still points to the mac header start and thus operates under the same conditions as in __vlan_insert_tag(). Fixes: 93515d53b133 ("net: move vlan pop/push functions into common code") Signed-off-by: Daniel Borkmann <> Reviewed-by: Jiri Pirko <> Signed-off-by: David S. Miller <>
Diffstat (limited to 'net/core/skbuff.c')
1 files changed, 5 insertions, 2 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index d04c2d1c8c87..e561f9f07d6d 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4502,13 +4502,16 @@ int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci)
__skb_push(skb, offset);
err = __vlan_insert_tag(skb, skb->vlan_proto,
- if (err)
+ if (err) {
+ __skb_pull(skb, offset);
return err;
+ }
skb->protocol = skb->vlan_proto;
skb->mac_len += VLAN_HLEN;
- __skb_pull(skb, offset);
skb_postpush_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN);
+ __skb_pull(skb, offset);
__vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci);
return 0;