From: huangxuesen <hxseverything@gmail.com>
To: davem@davemloft.net
Cc: bpf@vger.kernel.org, daniel@iogearbox.net,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
huangxuesen <huangxuesen@kuaishou.com>,
chengzhiyong <chengzhiyong@kuaishou.com>,
wangli <wangli09@kuaishou.com>
Subject: [PATCH] bpf: in bpf_skb_adjust_room correct inner protocol for vxlan
Date: Mon, 8 Feb 2021 19:38:10 +0800 [thread overview]
Message-ID: <20210208113810.11118-1-hxseverything@gmail.com> (raw)
From: huangxuesen <huangxuesen@kuaishou.com>
When pushing vxlan tunnel header, set inner protocol as ETH_P_TEB in skb
to avoid HW device disabling udp tunnel segmentation offload, just like
vxlan_build_skb does.
Drivers for NIC may invoke vxlan_features_check to check the
inner_protocol in skb for vxlan packets to decide whether to disable
NETIF_F_GSO_MASK. Currently it sets inner_protocol as the original
skb->protocol, that will make mlx5_core disable TSO and lead to huge
performance degradation.
Signed-off-by: huangxuesen <huangxuesen@kuaishou.com>
Signed-off-by: chengzhiyong <chengzhiyong@kuaishou.com>
Signed-off-by: wangli <wangli09@kuaishou.com>
---
net/core/filter.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index 255aeee72402..f8d3ba3fe10f 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3466,7 +3466,12 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff,
skb->inner_mac_header = inner_net - inner_mac_len;
skb->inner_network_header = inner_net;
skb->inner_transport_header = inner_trans;
- skb_set_inner_protocol(skb, skb->protocol);
+
+ if (flags & BPF_F_ADJ_ROOM_ENCAP_L4_UDP &&
+ inner_mac_len == ETH_HLEN)
+ skb_set_inner_protocol(skb, htons(ETH_P_TEB));
+ else
+ skb_set_inner_protocol(skb, skb->protocol);
skb->encapsulation = 1;
skb_set_network_header(skb, mac_len);
--
2.28.0
next reply other threads:[~2021-02-08 11:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-08 11:38 huangxuesen [this message]
2021-02-08 13:06 ` [PATCH] bpf: in bpf_skb_adjust_room correct inner protocol for vxlan Willem de Bruijn
2021-02-09 10:41 ` 黄学森
2021-02-09 13:48 ` Willem de Bruijn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210208113810.11118-1-hxseverything@gmail.com \
--to=hxseverything@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=chengzhiyong@kuaishou.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=huangxuesen@kuaishou.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=wangli09@kuaishou.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox