]> git.hungrycats.org Git - linux/commit
net: add eth_type_trans_careful()
authorEric Dumazet <edumazet@kernel.org>
Wed, 28 Oct 2026 12:26:59 +0000 (13:26 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 29 Oct 2026 16:11:20 +0000 (09:11 -0700)
commit2519a6fe7a8bba57a961eb804e43e7df35ac40fe
tree52d75d1b71235d40cd2f0ed9387028e99f9f1607
parentb7ff0e7a9ae3df2f123807a7e670bc348b1e1b9d
net: add eth_type_trans_careful()

eth_type_trans() assumes ETH_HLEN bytes are present in skb->head.
NIC drivers always provide this, and they should keep using the fast
version.

Devices looping skbs from their transmit path back to their receive
path get skbs built by the stack instead. Their link-layer header
might have been popped by tc actions (act_vlan pop_eth, act_ife decode)
or OVS actions (pop_eth + pop_mpls / pop_nsh), leaving fewer than
ETH_HLEN bytes in the linear part. eth_type_trans() then hits
the BUG() in __skb_pull().

Add eth_type_trans_careful(), which first pulls the Ethernet header,
and returns a drop reason on failure, so that the few devices exposed
to this can drop such packets.

Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Aaron Conole <aconole@redhat.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
Tested-by: Jamal Hadi Salim <jhs@mojatatu.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261028122703.2093730-2-edumazet@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/etherdevice.h