netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v3] vxlan: Pull inner IP header in vxlan_xmit_one().
@ 2024-06-19 13:34 Guillaume Nault
  2024-06-22  0:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Nault @ 2024-06-19 13:34 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet; +Cc: netdev, stephen

Ensure the inner IP header is part of the skb's linear data before
setting old_iph. Otherwise, on a non-linear skb, old_iph could point
outside of the packet data.

Unlike classical VXLAN, which always encapsulates Ethernet packets,
VXLAN-GPE can transport IP packets directly. In that case, we need to
look at skb->protocol to figure out if an Ethernet header is present.

Fixes: d342894c5d2f ("vxlan: virtual extensible lan")
Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
v2:
  * Handle the case of VXLAN-GPE carrying Ethernet frames (Paolo)
  * s/fragmented skb/non-linear skb/ (Eric)

v3:
  * Fix the skb->protocol test.
  * Rebase on top of latest net tree: use the new
    skb_vlan_inet_prepare() boolean parameter to avoid pulling the size
    of an Ethernet header when there is none.

 drivers/net/vxlan/vxlan_core.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 567cb3faab70..ba59e92ab941 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -2339,7 +2339,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
 	struct ip_tunnel_key *pkey;
 	struct ip_tunnel_key key;
 	struct vxlan_dev *vxlan = netdev_priv(dev);
-	const struct iphdr *old_iph = ip_hdr(skb);
+	const struct iphdr *old_iph;
 	struct vxlan_metadata _md;
 	struct vxlan_metadata *md = &_md;
 	unsigned int pkt_len = skb->len;
@@ -2353,8 +2353,15 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
 	bool use_cache;
 	bool udp_sum = false;
 	bool xnet = !net_eq(vxlan->net, dev_net(vxlan->dev));
+	bool no_eth_encap;
 	__be32 vni = 0;
 
+	no_eth_encap = flags & VXLAN_F_GPE && skb->protocol != htons(ETH_P_TEB);
+	if (!skb_vlan_inet_prepare(skb, no_eth_encap))
+		goto drop;
+
+	old_iph = ip_hdr(skb);
+
 	info = skb_tunnel_info(skb);
 	use_cache = ip_tunnel_dst_cache_usable(skb, info);
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net v3] vxlan: Pull inner IP header in vxlan_xmit_one().
  2024-06-19 13:34 [PATCH net v3] vxlan: Pull inner IP header in vxlan_xmit_one() Guillaume Nault
@ 2024-06-22  0:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-22  0:50 UTC (permalink / raw)
  To: Guillaume Nault; +Cc: davem, kuba, pabeni, edumazet, netdev, stephen

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 19 Jun 2024 15:34:57 +0200 you wrote:
> Ensure the inner IP header is part of the skb's linear data before
> setting old_iph. Otherwise, on a non-linear skb, old_iph could point
> outside of the packet data.
> 
> Unlike classical VXLAN, which always encapsulates Ethernet packets,
> VXLAN-GPE can transport IP packets directly. In that case, we need to
> look at skb->protocol to figure out if an Ethernet header is present.
> 
> [...]

Here is the summary with links:
  - [net,v3] vxlan: Pull inner IP header in vxlan_xmit_one().
    https://git.kernel.org/netdev/net/c/31392048f55f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-22  0:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19 13:34 [PATCH net v3] vxlan: Pull inner IP header in vxlan_xmit_one() Guillaume Nault
2024-06-22  0:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).