From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
netdev@vger.kernel.org, eric.dumazet@gmail.com,
Eric Dumazet <edumazet@google.com>
Subject: [PATCH net-next 08/10] vxlan: do not assume mac header is set in tx paths
Date: Wed, 2 Sep 2026 00:33:42 +0000 [thread overview]
Message-ID: <20260902003344.1931843-9-edumazet@google.com> (raw)
In-Reply-To: <20260902003344.1931843-1-edumazet@google.com>
We should not assume mac header is set in output path.
Use skb_eth_hdr() instead of eth_hdr() in tx paths,
and remove now redundant skb_reset_mac_header() call in vxlan_xmit().
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
drivers/net/vxlan/vxlan_core.c | 24 +++++++++++-------------
drivers/net/vxlan/vxlan_mdb.c | 4 ++--
2 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 459f19f7071e5bafe9e4c57ef8819645c3da7121..a1c3bc530b97cb8617ac324b60e32b77ea23e5ee 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -1967,7 +1967,7 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request,
ns = (struct nd_msg *)(ipv6_hdr(request) + 1);
- daddr = eth_hdr(request)->h_source;
+ daddr = skb_eth_hdr(request)->h_source;
ns_olen = request->len - skb_network_offset(request) -
sizeof(struct ipv6hdr) - sizeof(*ns);
for (i = 0; i < ns_olen-1; i += (ns->opt[i+1]<<3)) {
@@ -2108,11 +2108,11 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
struct vxlan_dev *vxlan = netdev_priv(dev);
struct neighbour *n;
- if (is_multicast_ether_addr(eth_hdr(skb)->h_dest))
+ if (is_multicast_ether_addr(skb_eth_hdr(skb)->h_dest))
return false;
n = NULL;
- switch (ntohs(eth_hdr(skb)->h_proto)) {
+ switch (ntohs(skb_eth_hdr(skb)->h_proto)) {
case ETH_P_IP:
{
struct iphdr *pip;
@@ -2169,15 +2169,15 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
bool diff;
neigh_ha_snapshot(haddr, n, dev);
- diff = !ether_addr_equal_unaligned(eth_hdr(skb)->h_dest, haddr);
+ diff = !ether_addr_equal_unaligned(skb_eth_hdr(skb)->h_dest, haddr);
if (diff) {
if (skb_cow_head(skb, 0)) {
neigh_release(n);
return false;
}
- memcpy(eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest,
+ memcpy(skb_eth_hdr(skb)->h_source, skb_eth_hdr(skb)->h_dest,
dev->addr_len);
- memcpy(eth_hdr(skb)->h_dest, haddr, dev->addr_len);
+ memcpy(skb_eth_hdr(skb)->h_dest, haddr, dev->addr_len);
}
neigh_release(n);
return diff;
@@ -2296,7 +2296,7 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
}
if ((dst_vxlan->cfg.flags & VXLAN_F_LEARN) && snoop)
- vxlan_snoop(dev, &loopback, eth_hdr(skb)->h_source, 0, vni);
+ vxlan_snoop(dev, &loopback, skb_eth_hdr(skb)->h_source, 0, vni);
dev_dstats_tx_add(src_vxlan->dev, len);
vxlan_vnifilter_count(src_vxlan, vni, NULL, VXLAN_VNI_STATS_TX, len);
@@ -2513,7 +2513,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
if (vxlan->cfg.df == VXLAN_DF_SET) {
df = htons(IP_DF);
} else if (vxlan->cfg.df == VXLAN_DF_INHERIT) {
- struct ethhdr *eth = eth_hdr(skb);
+ struct ethhdr *eth = skb_eth_hdr(skb);
if (ntohs(eth->h_proto) == ETH_P_IPV6 ||
(ntohs(eth->h_proto) == ETH_P_IP &&
@@ -2747,8 +2747,6 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
info = skb_tunnel_info(skb);
- skb_reset_mac_header(skb);
-
if (vxlan->cfg.flags & VXLAN_F_COLLECT_METADATA) {
if (info && info->mode & IP_TUNNEL_INFO_BRIDGE &&
info->mode & IP_TUNNEL_INFO_TX) {
@@ -2764,7 +2762,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
}
if (vxlan->cfg.flags & VXLAN_F_PROXY) {
- eth = eth_hdr(skb);
+ eth = skb_eth_hdr(skb);
if (ntohs(eth->h_proto) == ETH_P_ARP)
return arp_reduce(dev, skb, vni);
#if IS_ENABLED(CONFIG_IPV6)
@@ -2799,7 +2797,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
rcu_read_unlock();
}
- eth = eth_hdr(skb);
+ eth = skb_eth_hdr(skb);
rcu_read_lock();
f = vxlan_find_mac_tx(vxlan, eth->h_dest, vni);
did_rsc = false;
@@ -2808,7 +2806,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
(ntohs(eth->h_proto) == ETH_P_IP ||
ntohs(eth->h_proto) == ETH_P_IPV6)) {
did_rsc = route_shortcircuit(dev, skb);
- eth = eth_hdr(skb);
+ eth = skb_eth_hdr(skb);
if (did_rsc)
f = vxlan_find_mac_tx(vxlan, eth->h_dest, vni);
}
diff --git a/drivers/net/vxlan/vxlan_mdb.c b/drivers/net/vxlan/vxlan_mdb.c
index d71e1925ecfdbd6fa7b78b38cb4168b51c85a553..2ec005c003e3c0ada7eacf1f5af9a3bf5ab433da 100644
--- a/drivers/net/vxlan/vxlan_mdb.c
+++ b/drivers/net/vxlan/vxlan_mdb.c
@@ -1619,8 +1619,8 @@ struct vxlan_mdb_entry *vxlan_mdb_entry_skb_get(struct vxlan_dev *vxlan,
struct vxlan_mdb_entry *mdb_entry;
struct vxlan_mdb_entry_key group;
- if (!is_multicast_ether_addr(eth_hdr(skb)->h_dest) ||
- is_broadcast_ether_addr(eth_hdr(skb)->h_dest))
+ if (!is_multicast_ether_addr(skb_eth_hdr(skb)->h_dest) ||
+ is_broadcast_ether_addr(skb_eth_hdr(skb)->h_dest))
return NULL;
/* When not in collect metadata mode, 'src_vni' is zero, but MDB
--
2.55.0.966.g6673acef38-goog
next prev parent reply other threads:[~2026-09-02 0:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 0:33 [PATCH net-next 00/10] net: remove skb mac_header assumptions in TX paths (I) Eric Dumazet
2026-09-02 0:33 ` [PATCH net-next 01/10] bonding: do not assume mac header is set in ALB/TLB tx paths Eric Dumazet
2026-09-02 0:33 ` [PATCH net-next 02/10] atlantic: do not assume mac header is set in aq_ndev_start_xmit() Eric Dumazet
2026-09-02 0:33 ` [PATCH net-next 03/10] ibmveth: do not assume mac header is set in ibmveth_start_xmit() Eric Dumazet
2026-09-02 0:33 ` [PATCH net-next 04/10] net: mediatek: do not assume mac header is set in mtk_start_xmit() Eric Dumazet
2026-09-02 0:33 ` [PATCH net-next 05/10] netvsc: do not assume mac header is set in netvsc_start_xmit() Eric Dumazet
2026-09-02 0:33 ` [PATCH net-next 06/10] macsec: do not assume mac header is set in macsec_encrypt_finish() Eric Dumazet
2026-09-02 0:33 ` [PATCH net-next 07/10] macvlan: do not assume mac header is set in macvlan_broadcast() Eric Dumazet
2026-09-02 0:33 ` Eric Dumazet [this message]
2026-09-02 0:33 ` [PATCH net-next 09/10] cdc_mbim: do not assume mac header is set in cdc_mbim_tx_fixup() Eric Dumazet
2026-09-02 0:33 ` [PATCH net-next 10/10] ice: do not assume mac header is set in tx paths Eric Dumazet
2026-09-02 11:22 ` [PATCH net-next 00/10] net: remove skb mac_header assumptions in TX paths (I) Eric Dumazet
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=20260902003344.1931843-9-edumazet@google.com \
--to=edumazet@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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