Skip to content

Commit

Permalink
ethernet: Retire M_HASFCS
Browse files Browse the repository at this point in the history
The mbuf flag M_HASFCS was introduced for drivers to indicate the net
stack that packets include FCS (Frame Check Sequence). In principle, to
be efficient, FCS should always be processed by hardware, firmware, or
at last sort the driver. Well, Ethernet specifies that damaged frames
should be discarded, thus only good ones will be passed up to the net
stack, then it makes no senses for the net stack to see FCS just to trim
it.

The last consumer of the flag M_HASFCS has been removed since change [1].
It is time to retire it.

1. 105a4f7 ng_atmllc: remove

Reviewed by:	kp
MFC after:	never
Differential Revision:	https://reviews.freebsd.org/D42391
  • Loading branch information
gmshake committed Jul 4, 2024
1 parent b1dd067 commit 0916445
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 15 deletions.
4 changes: 0 additions & 4 deletions sys/net/debugnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,6 @@ debugnet_input_one(struct ifnet *ifp, struct mbuf *m)
m->m_len, m->m_pkthdr.len);
goto done;
}
if ((m->m_flags & M_HASFCS) != 0) {
m_adj(m, -ETHER_CRC_LEN);
m->m_flags &= ~M_HASFCS;
}
eh = mtod(m, struct ether_header *);
etype = ntohs(eh->ether_type);
if ((m->m_flags & M_VLANTAG) != 0 || etype == ETHERTYPE_VLAN) {
Expand Down
1 change: 0 additions & 1 deletion sys/net/ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
/*
* Ethernet-specific mbuf flags.
*/
#define M_HASFCS M_PROTO5 /* FCS included at end of frame */
#define M_BRIDGE_INJECT M_PROTO6 /* if_bridge-injected frame */

/*
Expand Down
10 changes: 0 additions & 10 deletions sys/net/if_ethersubr.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,16 +588,6 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m)
*/
ETHER_BPF_MTAP(ifp, m);

/*
* If the CRC is still on the packet, trim it off. We do this once
* and once only in case we are re-entered. Nothing else on the
* Ethernet receive path expects to see the FCS.
*/
if (m->m_flags & M_HASFCS) {
m_adj(m, -ETHER_CRC_LEN);
m->m_flags &= ~M_HASFCS;
}

if (!(ifp->if_capenable & IFCAP_HWSTATS))
if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len);

Expand Down

0 comments on commit 0916445

Please sign in to comment.