Commit 31392048 authored by Guillaume Nault's avatar Guillaume Nault Committed by Jakub Kicinski

vxlan: Pull inner IP header in vxlan_xmit_one().

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: d342894c ("vxlan: virtual extensible lan")
Signed-off-by: default avatarGuillaume Nault <gnault@redhat.com>
Link: https://patch.msgid.link/2aa75f6fa62ac9dbe4f16ad5ba75dd04a51d4b99.1718804000.git.gnault@redhat.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 8406b56a
...@@ -2339,7 +2339,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ...@@ -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 *pkey;
struct ip_tunnel_key key; struct ip_tunnel_key key;
struct vxlan_dev *vxlan = netdev_priv(dev); 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;
struct vxlan_metadata *md = &_md; struct vxlan_metadata *md = &_md;
unsigned int pkt_len = skb->len; unsigned int pkt_len = skb->len;
...@@ -2353,8 +2353,15 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ...@@ -2353,8 +2353,15 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
bool use_cache; bool use_cache;
bool udp_sum = false; bool udp_sum = false;
bool xnet = !net_eq(vxlan->net, dev_net(vxlan->dev)); bool xnet = !net_eq(vxlan->net, dev_net(vxlan->dev));
bool no_eth_encap;
__be32 vni = 0; __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); info = skb_tunnel_info(skb);
use_cache = ip_tunnel_dst_cache_usable(skb, info); use_cache = ip_tunnel_dst_cache_usable(skb, info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment