* [PATCH net-next v2 0/5] net: remove dev_validate_header() and net_device::min_header_len
@ 2026-11-29 16:30 Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 1/5] net: ipa: remove ethernet-specific artifacts from modem netdev setup Willem de Bruijn
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Willem de Bruijn @ 2026-11-29 16:30 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, horms, elder,
Willem de Bruijn
Remove unused link-layer header validation plumbing, clean up the
remaining af_packet users, and drop net_device::min_header_len.
Mostly cleanup, with two user-visible changes:
- Patch 3: on devices that set hard_header_len but have no link layer
header (e.g., PPP), SOCK_RAW sends, with or without a TX_RING, now
always have skb->network_header at the start of the packet. Before,
only short packets sent without a TX_RING did.
- Patch 4: on SOCK_DGRAM, the VLAN TCI of non-offloaded tags is now
reported on all Ethernet devices, including those with
hard_header_len != ETH_HLEN, and omitted (without setting
TP_STATUS_VLAN_VALID) on non-Ethernet devices.
1. Drop stale Ethernet fields (including min_header_len) in IPA modem.
2. Remove header_ops->validate and dev_validate_header().
3. Reset network header on all headerless devices via dev_has_header().
4. Use ARPHRD_ETHER / ARPHRD_LOOPBACK and ETH_HLEN in vlan_get_tci().
5. Remove unused net_device::min_header_len.
Testing (under vng):
- tools/testing/selftests/net: psock_snd.sh, psock_tpacket, and
txring_overwrite.
- Custom tests for short/zero header validation (SOCK_RAW, SOCK_DGRAM,
SOCK_PACKET, TX_RING), SOCK_PACKET retry device swap via userfaultfd
(tun -> veth), non-offloaded outgoing VLAN TCI capture (AUXDATA with
non-zero TCI, TCI 0, TP_STATUS_COPY, and tun; TPACKET_V2; TPACKET_V3),
and SOCK_RAW network header offset over PPP (40B/100B IPv4, with and
without TX_RING).
Link: https://patch.msgid.link/willemdebruijn.kernel.251660d5aa3e@gmail.com
Changes
v1 -> v2
- rebase on net-next
- cover letter: add Link: to the thread where this cleanup was
proposed
- cover letter: correct the summary of the network header change
- cover letter: update the summary of the VLAN change and the list
of custom tests to match v2
- patch 1/5: add Acked-by from Alex Elder
- patch 1/5: replace <linux/etherdevice.h> with <linux/if_ether.h>
for ETH_P_MAP and ETH_MIN_MTU
- patch 2/5: compare against live READ_ONCE(dev->hard_header_len) in
all three af_packet callers instead of the snapshotted value. In
packet_sendmsg_spkt() the snapshot could come from a different
device than the one transmitted on (Sashiko)
- drop v1 patch 3/6 ("packet: validate TX header length before skb
allocation"): not needed to remove min_header_len. This keeps the
TX header length checks against the live hard_header_len, after
the skb is built, which also addresses the Sashiko report on that
patch
- patch 3/5: no code change; clarify commit message (needed_headroom
vs hard_header_len, scope of the 6in4 workaround, why
tpacket_fill_skb() is changed as well, and list hdlc_null_ops as a
second header_ops without ->create)
- patch 4/5: have vlan_get_tci() return bool so callers only set
TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID when a VLAN
header is extracted, avoiding false VLAN flags on TP_STATUS_COPY
skbs (zeroed sll_hatype; Sashiko), non-Ethernet devices, and
truncated frames
- patch 4/5: update commit message to match
v1: https://lore.kernel.org/netdev/20261124170551.1874487-1-willemdebruijn.kernel@gmail.com/
Willem de Bruijn (5):
net: ipa: remove ethernet-specific artifacts from modem netdev setup
net: remove header_ops->validate and dev_validate_header()
packet: reset network header on all headerless devices
packet: use Ethernet header length in vlan_get_tci()
net: remove unused net_device::min_header_len
.../networking/net_cachelines/net_device.rst | 1 -
drivers/net/ipa/ipa_modem.c | 5 +-
drivers/net/loopback.c | 1 -
include/linux/netdevice.h | 18 -----
net/ethernet/eth.c | 1 -
net/packet/af_packet.c | 78 +++++++++----------
6 files changed, 36 insertions(+), 68 deletions(-)
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next v2 1/5] net: ipa: remove ethernet-specific artifacts from modem netdev setup
2026-11-29 16:30 [PATCH net-next v2 0/5] net: remove dev_validate_header() and net_device::min_header_len Willem de Bruijn
@ 2026-11-29 16:30 ` Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 2/5] net: remove header_ops->validate and dev_validate_header() Willem de Bruijn
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Willem de Bruijn @ 2026-11-29 16:30 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, horms, elder,
Willem de Bruijn, Alex Elder
Commit 75944b040bbc ("net: ipa: open-code ether_setup()") open-coded
ether_setup(), including fields that do not apply to this headerless
ARPHRD_RAWIP device:
- min_header_len = ETH_HLEN, while hard_header_len is 0
- an Ethernet broadcast address, while addr_len is 0
- clearing IFF_BROADCAST | IFF_MULTICAST, which are never set
Remove these and replace the etherdevice.h include with if_ether.h for
ETH_P_MAP and ETH_MIN_MTU.
With min_header_len left at 0, the device behaves like other headerless
devices (such as tun and rmnet) in af_packet's vlan_get_tci(), where
min_header_len == hard_header_len instead of returning early on the
mismatch. Normal IPA traffic uses ETH_P_MAP rather than a VLAN
ethertype, so it is unaffected.
Cc: Alex Elder <elder@kernel.org>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Acked-by: Alex Elder <elder@riscstar.com>
---
drivers/net/ipa/ipa_modem.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/ipa/ipa_modem.c b/drivers/net/ipa/ipa_modem.c
index d84c1dbd3b1a..d7892fcb0ef4 100644
--- a/drivers/net/ipa/ipa_modem.c
+++ b/drivers/net/ipa/ipa_modem.c
@@ -5,8 +5,8 @@
*/
#include <linux/errno.h>
-#include <linux/etherdevice.h>
#include <linux/if_arp.h>
+#include <linux/if_ether.h>
#include <linux/if_rmnet.h>
#include <linux/netdevice.h>
#include <linux/pm_runtime.h>
@@ -223,15 +223,12 @@ static void ipa_modem_netdev_setup(struct net_device *netdev)
netdev->header_ops = NULL;
netdev->type = ARPHRD_RAWIP;
netdev->hard_header_len = 0;
- netdev->min_header_len = ETH_HLEN;
netdev->min_mtu = ETH_MIN_MTU;
netdev->max_mtu = IPA_MTU;
netdev->mtu = netdev->max_mtu;
netdev->addr_len = 0;
netdev->tx_queue_len = DEFAULT_TX_QUEUE_LEN;
- netdev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST);
netdev->priv_flags |= IFF_TX_SKB_SHARING;
- eth_broadcast_addr(netdev->broadcast);
/* The endpoint is configured for QMAP */
netdev->needed_headroom = sizeof(struct rmnet_map_header);
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v2 2/5] net: remove header_ops->validate and dev_validate_header()
2026-11-29 16:30 [PATCH net-next v2 0/5] net: remove dev_validate_header() and net_device::min_header_len Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 1/5] net: ipa: remove ethernet-specific artifacts from modem netdev setup Willem de Bruijn
@ 2026-11-29 16:30 ` Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 3/5] packet: reset network header on all headerless devices Willem de Bruijn
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Willem de Bruijn @ 2026-11-29 16:30 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, horms, elder,
Willem de Bruijn
header_ops->validate was added in commit 2793a23aacbd ("net: validate
variable length ll headers") for AX.25, its only implementation. AX.25
was removed in commit dd8d4bc28ad7 ("net: remove ax25 and amateur radio
(hamradio) subsystem"), and the CAP_SYS_RAWIO bypass in
dev_validate_header() was removed in commit 3b9a324e646d ("net: remove
CAP_SYS_RAWIO zero-padding in dev_validate_header").
With both gone, dev_validate_header() only checks
len >= dev->hard_header_len. Remove header_ops->validate and
dev_validate_header(), and replace the only callers in af_packet with
direct checks against READ_ONCE(dev->hard_header_len).
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
include/linux/netdevice.h | 16 ----------------
net/packet/af_packet.c | 6 +++---
2 files changed, 3 insertions(+), 19 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 694b6d29f680..930899a7a577 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -326,7 +326,6 @@ struct header_ops {
void (*cache_update)(struct hh_cache *hh,
const struct net_device *dev,
const unsigned char *haddr);
- bool (*validate)(const char *ll_header, unsigned int len);
__be16 (*parse_protocol)(const struct sk_buff *skb);
};
@@ -3587,21 +3586,6 @@ static inline __be16 dev_parse_header_protocol(const struct sk_buff *skb)
return dev->header_ops->parse_protocol(skb);
}
-/* ll_header must have at least hard_header_len allocated */
-static inline bool dev_validate_header(const struct net_device *dev,
- char *ll_header, int len)
-{
- if (likely(len >= dev->hard_header_len))
- return true;
- if (len < dev->min_header_len)
- return false;
-
- if (dev->header_ops && dev->header_ops->validate)
- return dev->header_ops->validate(ll_header, len);
-
- return false;
-}
-
static inline bool dev_has_header(const struct net_device *dev)
{
return dev->header_ops && dev->header_ops->create;
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 037b4e55ca3d..0ea3036bee24 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2080,7 +2080,7 @@ static int packet_sendmsg_spkt(struct socket *sock, struct msghdr *msg,
goto retry;
}
- if (!dev_validate_header(dev, skb->data, len) || !skb->len) {
+ if (len < READ_ONCE(dev->hard_header_len) || !skb->len) {
err = -EINVAL;
goto out_unlock;
}
@@ -2664,7 +2664,7 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
err = skb_store_bits(skb, 0, data, hdrlen);
if (unlikely(err))
return err;
- if (!dev_validate_header(dev, skb->data, hdrlen))
+ if (hdrlen < READ_ONCE(dev->hard_header_len))
return -EINVAL;
data += hdrlen;
@@ -3136,7 +3136,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
goto out_free;
if ((sock->type == SOCK_RAW &&
- !dev_validate_header(dev, skb->data, len)) || !skb->len) {
+ len < READ_ONCE(dev->hard_header_len)) || !skb->len) {
err = -EINVAL;
goto out_free;
}
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v2 3/5] packet: reset network header on all headerless devices
2026-11-29 16:30 [PATCH net-next v2 0/5] net: remove dev_validate_header() and net_device::min_header_len Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 1/5] net: ipa: remove ethernet-specific artifacts from modem netdev setup Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 2/5] net: remove header_ops->validate and dev_validate_header() Willem de Bruijn
@ 2026-11-29 16:30 ` Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 4/5] packet: use Ethernet header length in vlan_get_tci() Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 5/5] net: remove unused net_device::min_header_len Willem de Bruijn
4 siblings, 0 replies; 6+ messages in thread
From: Willem de Bruijn @ 2026-11-29 16:30 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, horms, elder,
Willem de Bruijn
Devices without a userspace-visible link layer header (!dev_has_header())
should leave hard_header_len at 0 and use needed_headroom for headers
prepended in ndo_start_xmit(), but some still set hard_header_len > 0
instead (e.g., PPP, mctp-usb, routed br2684, and previously sit). On
SOCK_RAW sends, af_packet reserves hard_header_len and leaves
skb->network_header pointing that many bytes into the L3 header.
Commit 88a8121dc1d3 ("af_packet: fix raw sockets over 6in4 tunnel")
added a workaround in packet_snd() only for short IPv6 packets on 6in4
tunnels, explicitly noting that it was temporary and left to be cleaned
up in net-next. That heuristic misses longer packets and misfires on
non-Ethernet devices with a link layer header where min_header_len is 0.
Replace it with !dev_has_header(dev) in packet_snd(). Apply the same in
tpacket_fill_skb(), which has the same problem but never had the
workaround, so that SOCK_RAW sends behave the same with and without a
TX ring.
For consistency, also switch packet_sendmsg_spkt() from dev->header_ops
to dev_has_header(dev). This has no effect today: the only header_ops
without ->create are ip_tunnel_header_ops and hdlc_null_ops, and all
devices using them have hard_header_len 0.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
net/packet/af_packet.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 0ea3036bee24..4ff7a2cc11e5 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2054,7 +2054,7 @@ static int packet_sendmsg_spkt(struct socket *sock, struct msghdr *msg,
if (!skb) {
size_t reserved = LL_RESERVED_SPACE_EX(dev, hard_header_len);
int tlen = dev->needed_tailroom;
- unsigned int hhlen = dev->header_ops ? hard_header_len : 0;
+ unsigned int hhlen = dev_has_header(dev) ? hard_header_len : 0;
rcu_read_unlock();
skb = sock_wmalloc(sk, len + reserved + tlen, 0, GFP_KERNEL);
@@ -2661,6 +2661,8 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
skb_push(skb, hard_header_len);
skb_put(skb, copylen - hard_header_len);
+ if (!dev_has_header(dev))
+ skb_reset_network_header(skb);
err = skb_store_bits(skb, 0, data, hdrlen);
if (unlikely(err))
return err;
@@ -3125,8 +3127,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
goto out_free;
} else if (reserve) {
skb_reserve(skb, -reserve);
- if (len < reserve + sizeof(struct ipv6hdr) &&
- dev->min_header_len != hard_header_len)
+ if (!dev_has_header(dev))
skb_reset_network_header(skb);
}
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v2 4/5] packet: use Ethernet header length in vlan_get_tci()
2026-11-29 16:30 [PATCH net-next v2 0/5] net: remove dev_validate_header() and net_device::min_header_len Willem de Bruijn
` (2 preceding siblings ...)
2026-11-29 16:30 ` [PATCH net-next v2 3/5] packet: reset network header on all headerless devices Willem de Bruijn
@ 2026-11-29 16:30 ` Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 5/5] net: remove unused net_device::min_header_len Willem de Bruijn
4 siblings, 0 replies; 6+ messages in thread
From: Willem de Bruijn @ 2026-11-29 16:30 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, horms, elder,
Willem de Bruijn
vlan_get_tci() uses dev->min_header_len to locate the outer 802.1Q/AD
header on SOCK_DGRAM captures, with an is_vlan_dev() fallback that has
been obsolete since commit 447cbe95ebb9 ("vlan: fix skb_under_panic and
races when toggling HW VLAN offload") stopped adding VLAN_HLEN to
vlandev->hard_header_len.
Only Ethernet and loopback devices set min_header_len (to ETH_HLEN).
Check ARPHRD_ETHER / ARPHRD_LOOPBACK and read at ETH_HLEN directly
instead, removing the last min_header_len reader and letting
packet_recvmsg() use sll->sll_hatype without an RCU device lookup.
Have vlan_get_tci() return whether a VLAN header was extracted, so
callers only set TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID when
the TCI is valid. This avoids setting false VLAN flags on non-Ethernet
devices, truncated frames, and TP_STATUS_COPY skbs queued by
tpacket_rcv() whose sockaddr_ll (including sll_hatype) is zeroed.
This changes the reported VLAN metadata in three cases:
- Ethernet devices with hard_header_len != ETH_HLEN (e.g., smsc95xx,
rndis_host) previously failed the min_header_len == hard_header_len
test and reported TCI 0. They now report the actual TCI.
- Non-Ethernet devices and frames without an extractable VLAN header
previously still set TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID:
headerless devices (e.g., tun, rmnet) matched 0 == 0 and read payload
bytes at offset 0 as TCI, while other non-Ethernet devices and
truncated frames reported TCI 0. They now omit VLAN metadata and flags.
- packet_recvmsg() previously omitted the VLAN fields if the device
had been unregistered since the packet was queued. It now fills
them from the queued skb.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
net/packet/af_packet.c | 65 ++++++++++++++++++------------------------
1 file changed, 28 insertions(+), 37 deletions(-)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 4ff7a2cc11e5..7b02fd6b63eb 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -547,34 +547,25 @@ static void *packet_current_frame(struct packet_sock *po,
return packet_lookup_frame(po, rb, rb->head, status);
}
-static u16 vlan_get_tci(const struct sk_buff *skb, struct net_device *dev)
+static bool vlan_get_tci(const struct sk_buff *skb, unsigned short type,
+ u16 *tci)
{
struct vlan_hdr vhdr, *vh;
- unsigned int header_len;
- if (!dev)
- return 0;
+ if (type != ARPHRD_ETHER && type != ARPHRD_LOOPBACK)
+ return false;
/* In the SOCK_DGRAM scenario, skb data starts at the network
* protocol, which is after the VLAN headers. The outer VLAN
- * header is at the hard_header_len offset in non-variable
- * length link layer headers. If it's a VLAN device, the
- * min_header_len should be used to exclude the VLAN header
- * size.
+ * header is at the ETH_HLEN offset from the MAC header.
*/
- if (dev->min_header_len == dev->hard_header_len)
- header_len = dev->hard_header_len;
- else if (is_vlan_dev(dev))
- header_len = dev->min_header_len;
- else
- return 0;
-
- vh = skb_header_pointer(skb, skb_mac_offset(skb) + header_len,
+ vh = skb_header_pointer(skb, skb_mac_offset(skb) + ETH_HLEN,
sizeof(vhdr), &vhdr);
if (unlikely(!vh))
- return 0;
+ return false;
- return ntohs(vh->h_vlan_TCI);
+ *tci = ntohs(vh->h_vlan_TCI);
+ return true;
}
static __be16 vlan_get_protocol_dgram(const struct sk_buff *skb)
@@ -1025,13 +1016,17 @@ static void prb_fill_vlan_info(struct tpacket_kbdq_core *pkc,
struct tpacket3_hdr *ppd)
{
struct packet_sock *po = container_of(pkc, struct packet_sock, rx_ring.prb_bdqc);
+ u16 tci;
if (skb_vlan_tag_present(pkc->skb)) {
ppd->hv1.tp_vlan_tci = skb_vlan_tag_get(pkc->skb);
ppd->hv1.tp_vlan_tpid = ntohs(pkc->skb->vlan_proto);
ppd->tp_status = TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
- } else if (unlikely(po->sk.sk_type == SOCK_DGRAM && eth_type_vlan(pkc->skb->protocol))) {
- ppd->hv1.tp_vlan_tci = vlan_get_tci(pkc->skb, pkc->skb->dev);
+ } else if (unlikely(po->sk.sk_type == SOCK_DGRAM &&
+ eth_type_vlan(pkc->skb->protocol) &&
+ vlan_get_tci(pkc->skb, pkc->skb->dev->type,
+ &tci))) {
+ ppd->hv1.tp_vlan_tci = tci;
ppd->hv1.tp_vlan_tpid = ntohs(pkc->skb->protocol);
ppd->tp_status = TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
} else {
@@ -2294,6 +2289,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
__u32 ts_status;
unsigned int slot_id = 0;
int vnet_hdr_sz = 0;
+ u16 tci;
/* struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT.
* We may add members to them until current aligned size without forcing
@@ -2474,8 +2470,10 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
h.h2->tp_vlan_tci = skb_vlan_tag_get(skb);
h.h2->tp_vlan_tpid = ntohs(skb->vlan_proto);
status |= TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
- } else if (unlikely(sk->sk_type == SOCK_DGRAM && eth_type_vlan(skb->protocol))) {
- h.h2->tp_vlan_tci = vlan_get_tci(skb, skb->dev);
+ } else if (unlikely(sk->sk_type == SOCK_DGRAM &&
+ eth_type_vlan(skb->protocol) &&
+ vlan_get_tci(skb, dev->type, &tci))) {
+ h.h2->tp_vlan_tci = tci;
h.h2->tp_vlan_tpid = ntohs(skb->protocol);
status |= TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
} else {
@@ -3622,7 +3620,9 @@ static int packet_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
}
if (packet_sock_flag(pkt_sk(sk), PACKET_SOCK_AUXDATA)) {
+ const struct sockaddr_ll *sll = &PACKET_SKB_CB(skb)->sa.ll;
struct tpacket_auxdata aux;
+ u16 tci;
aux.tp_status = TP_STATUS_USER;
if (skb->ip_summed == CHECKSUM_PARTIAL)
@@ -3641,21 +3641,12 @@ static int packet_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
aux.tp_vlan_tci = skb_vlan_tag_get(skb);
aux.tp_vlan_tpid = ntohs(skb->vlan_proto);
aux.tp_status |= TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
- } else if (unlikely(sock->type == SOCK_DGRAM && eth_type_vlan(skb->protocol))) {
- struct sockaddr_ll *sll = &PACKET_SKB_CB(skb)->sa.ll;
- struct net_device *dev;
-
- rcu_read_lock();
- dev = dev_get_by_index_rcu(sock_net(sk), sll->sll_ifindex);
- if (dev) {
- aux.tp_vlan_tci = vlan_get_tci(skb, dev);
- aux.tp_vlan_tpid = ntohs(skb->protocol);
- aux.tp_status |= TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
- } else {
- aux.tp_vlan_tci = 0;
- aux.tp_vlan_tpid = 0;
- }
- rcu_read_unlock();
+ } else if (unlikely(sock->type == SOCK_DGRAM &&
+ eth_type_vlan(skb->protocol) &&
+ vlan_get_tci(skb, sll->sll_hatype, &tci))) {
+ aux.tp_vlan_tci = tci;
+ aux.tp_vlan_tpid = ntohs(skb->protocol);
+ aux.tp_status |= TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
} else {
aux.tp_vlan_tci = 0;
aux.tp_vlan_tpid = 0;
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v2 5/5] net: remove unused net_device::min_header_len
2026-11-29 16:30 [PATCH net-next v2 0/5] net: remove dev_validate_header() and net_device::min_header_len Willem de Bruijn
` (3 preceding siblings ...)
2026-11-29 16:30 ` [PATCH net-next v2 4/5] packet: use Ethernet header length in vlan_get_tci() Willem de Bruijn
@ 2026-11-29 16:30 ` Willem de Bruijn
4 siblings, 0 replies; 6+ messages in thread
From: Willem de Bruijn @ 2026-11-29 16:30 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, horms, elder,
Willem de Bruijn
dev->min_header_len was introduced in commit 217e6fa24ce2 ("net:
introduce device min_header_len") for dev_validate_header() when
header_ops->validate and the CAP_SYS_RAWIO bypass could accept frames
shorter than hard_header_len.
Now that dev_validate_header() and the remaining workarounds in
af_packet have been removed, dev->min_header_len has no readers left.
Remove the field from struct net_device along with its remaining
assignments in ether_setup() and loopback setup.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
Documentation/networking/net_cachelines/net_device.rst | 1 -
drivers/net/loopback.c | 1 -
include/linux/netdevice.h | 2 --
net/ethernet/eth.c | 1 -
4 files changed, 5 deletions(-)
diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Documentation/networking/net_cachelines/net_device.rst
index 7620d3fcb8dc..f73ea0069432 100644
--- a/Documentation/networking/net_cachelines/net_device.rst
+++ b/Documentation/networking/net_cachelines/net_device.rst
@@ -46,7 +46,6 @@ netdev_features_t gso_partial_features read_mostly
unsigned_int min_mtu
unsigned_int max_mtu
unsigned_short type
-unsigned_char min_header_len
unsigned_char name_assign_type
int group
struct net_device_stats stats
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 1e6d1b7d71ba..6fdf00c223b9 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -173,7 +173,6 @@ static void gen_lo_setup(struct net_device *dev,
{
dev->mtu = mtu;
dev->hard_header_len = ETH_HLEN; /* 14 */
- dev->min_header_len = ETH_HLEN; /* 14 */
dev->addr_len = ETH_ALEN; /* 6 */
dev->type = ARPHRD_LOOPBACK; /* 0x0001*/
dev->flags = IFF_LOOPBACK;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 930899a7a577..2a1b3f48bed5 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1929,7 +1929,6 @@ enum netdev_reg_state {
* @max_mtu: Interface Maximum MTU value
* @type: Interface hardware type
* @hard_header_len: Maximum hardware header length.
- * @min_header_len: Minimum hardware header length
*
* @needed_headroom: Extra headroom the hardware may need, but not in all
* cases can this be guaranteed
@@ -2292,7 +2291,6 @@ struct net_device {
unsigned int min_mtu;
unsigned int max_mtu;
unsigned short type;
- unsigned char min_header_len;
unsigned char name_assign_type;
int group;
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 39aab0f8035a..db39527d4704 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -330,7 +330,6 @@ void ether_setup(struct net_device *dev)
dev->header_ops = ð_header_ops;
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
- dev->min_header_len = ETH_HLEN;
dev->mtu = ETH_DATA_LEN;
dev->min_mtu = ETH_MIN_MTU;
dev->max_mtu = ETH_DATA_LEN;
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-29 16:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 16:30 [PATCH net-next v2 0/5] net: remove dev_validate_header() and net_device::min_header_len Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 1/5] net: ipa: remove ethernet-specific artifacts from modem netdev setup Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 2/5] net: remove header_ops->validate and dev_validate_header() Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 3/5] packet: reset network header on all headerless devices Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 4/5] packet: use Ethernet header length in vlan_get_tci() Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 5/5] net: remove unused net_device::min_header_len Willem de Bruijn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox