Patchwork [v3] net: Fix missing meta data in skb with vlan packet

login
register
mail settings
Submitter Yuya Kusakabe
Date April 16, 2019, 1:22 a.m.
Message ID <1b8203e8-4b4b-8050-7299-f243a99e3ad5@gmail.com>
Download mbox | patch
Permalink /patch/773787/
State New
Headers show

Comments

Yuya Kusakabe - April 16, 2019, 1:22 a.m.
skb_reorder_vlan_header() should move XDP meta data with ethernet header
if XDP meta data exists.

Fixes: de8f3a83b0a0 ("bpf: add meta pointer for direct access")
Signed-off-by: Yuya Kusakabe <yuya.kusakabe@gmail.com>
Signed-off-by: Takeru Hayasaka <taketarou2@gmail.com>
Co-developed-by: Takeru Hayasaka <taketarou2@gmail.com>
---
 net/core/skbuff.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Toshiaki Makita - April 16, 2019, 4:14 a.m.
On 2019/04/16 10:22, Yuya Kusakabe wrote:
> skb_reorder_vlan_header() should move XDP meta data with ethernet header
> if XDP meta data exists.
> 
> Fixes: de8f3a83b0a0 ("bpf: add meta pointer for direct access")
> Signed-off-by: Yuya Kusakabe <yuya.kusakabe@gmail.com>
> Signed-off-by: Takeru Hayasaka <taketarou2@gmail.com>
> Co-developed-by: Takeru Hayasaka <taketarou2@gmail.com>

Reviewed-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
David Miller - April 17, 2019, 4:30 a.m.
From: Yuya Kusakabe <yuya.kusakabe@gmail.com>
Date: Tue, 16 Apr 2019 10:22:28 +0900

> skb_reorder_vlan_header() should move XDP meta data with ethernet header
> if XDP meta data exists.
> 
> Fixes: de8f3a83b0a0 ("bpf: add meta pointer for direct access")
> Signed-off-by: Yuya Kusakabe <yuya.kusakabe@gmail.com>
> Signed-off-by: Takeru Hayasaka <taketarou2@gmail.com>
> Co-developed-by: Takeru Hayasaka <taketarou2@gmail.com>

Applied and queued up for -stable, thank you.

Patch

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index ef2cd5712098..40796b8bf820 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5083,7 +5083,8 @@  EXPORT_SYMBOL_GPL(skb_gso_validate_mac_len);
 
 static struct sk_buff *skb_reorder_vlan_header(struct sk_buff *skb)
 {
-	int mac_len;
+	int mac_len, meta_len;
+	void *meta;
 
 	if (skb_cow(skb, skb_headroom(skb)) < 0) {
 		kfree_skb(skb);
@@ -5095,6 +5096,13 @@  static struct sk_buff *skb_reorder_vlan_header(struct sk_buff *skb)
 		memmove(skb_mac_header(skb) + VLAN_HLEN, skb_mac_header(skb),
 			mac_len - VLAN_HLEN - ETH_TLEN);
 	}
+
+	meta_len = skb_metadata_len(skb);
+	if (meta_len) {
+		meta = skb_metadata_end(skb) - meta_len;
+		memmove(meta + VLAN_HLEN, meta, meta_len);
+	}
+
 	skb->mac_header += VLAN_HLEN;
 	return skb;
 }