Skip to content

Commit 3139204

Browse files
Guillaume Naultkuba-moo
authored andcommitted
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: d342894 ("vxlan: virtual extensible lan") Signed-off-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/2aa75f6fa62ac9dbe4f16ad5ba75dd04a51d4b99.1718804000.git.gnault@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 8406b56 commit 3139204

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/net/vxlan/vxlan_core.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2339,7 +2339,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
23392339
struct ip_tunnel_key *pkey;
23402340
struct ip_tunnel_key key;
23412341
struct vxlan_dev *vxlan = netdev_priv(dev);
2342-
const struct iphdr *old_iph = ip_hdr(skb);
2342+
const struct iphdr *old_iph;
23432343
struct vxlan_metadata _md;
23442344
struct vxlan_metadata *md = &_md;
23452345
unsigned int pkt_len = skb->len;
@@ -2353,8 +2353,15 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
23532353
bool use_cache;
23542354
bool udp_sum = false;
23552355
bool xnet = !net_eq(vxlan->net, dev_net(vxlan->dev));
2356+
bool no_eth_encap;
23562357
__be32 vni = 0;
23572358

2359+
no_eth_encap = flags & VXLAN_F_GPE && skb->protocol != htons(ETH_P_TEB);
2360+
if (!skb_vlan_inet_prepare(skb, no_eth_encap))
2361+
goto drop;
2362+
2363+
old_iph = ip_hdr(skb);
2364+
23582365
info = skb_tunnel_info(skb);
23592366
use_cache = ip_tunnel_dst_cache_usable(skb, info);
23602367

0 commit comments

Comments
 (0)