Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Jun 2025 15:27:55 GMT
From:      Zhenlei Huang <zlei@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 6ce8fd1978a9 - main - ethernet: Set maximum Ethernet header length based on the capability IFCAP_VLAN_MTU
Message-ID:  <202506211527.55LFRtHW035392@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=6ce8fd1978a9526ff0dc02ed98ef797f9154ec1f

commit 6ce8fd1978a9526ff0dc02ed98ef797f9154ec1f
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2025-06-21 15:12:29 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2025-06-21 15:12:29 +0000

    ethernet: Set maximum Ethernet header length based on the capability IFCAP_VLAN_MTU
    
    Lots of Ethernet drivers fix the header length after ether_ifattach().
    Well since the net stack can conclude it based on the capability
    IFCAP_VLAN_MTU, let the net stack do it rather than individual drivers.
    
    Reviewed by:    markj, glebius
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D50846
---
 sys/net/if_ethersubr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index cb858f20f3b6..cec1c08c2614 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -987,7 +987,8 @@ ether_ifattach(struct ifnet *ifp, const u_int8_t *lla)
 	struct sockaddr_dl *sdl;
 
 	ifp->if_addrlen = ETHER_ADDR_LEN;
-	ifp->if_hdrlen = ETHER_HDR_LEN;
+	ifp->if_hdrlen = (ifp->if_capabilities & IFCAP_VLAN_MTU) != 0 ?
+	    ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN : ETHER_HDR_LEN;
 	ifp->if_mtu = ETHERMTU;
 	if_attach(ifp);
 	ifp->if_output = ether_output;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202506211527.55LFRtHW035392>