ether_demux: Defer stripping the Ethernet header.

This avoids having to undo it before invoking NetGraph's orphan input
hook.

Reviewed by:	ae, melifaro
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D37510
This commit is contained in:
John Baldwin 2022-11-30 14:38:51 -08:00
parent f9ce8da864
commit 79b6799423

View File

@ -890,11 +890,9 @@ ether_demux(struct ifnet *ifp, struct mbuf *m)
/*
* Reset layer specific mbuf flags to avoid confusing upper layers.
* Strip off Ethernet header.
*/
m->m_flags &= ~M_VLANTAG;
m_clrprotoflags(m);
m_adj(m, ETHER_HDR_LEN);
/*
* Dispatch frame to upper layer.
@ -922,6 +920,10 @@ ether_demux(struct ifnet *ifp, struct mbuf *m)
default:
goto discard;
}
/* Strip off Ethernet header. */
m_adj(m, ETHER_HDR_LEN);
netisr_dispatch(isr, m);
return;
@ -934,11 +936,6 @@ ether_demux(struct ifnet *ifp, struct mbuf *m)
if (ifp->if_l2com != NULL) {
KASSERT(ng_ether_input_orphan_p != NULL,
("ng_ether_input_orphan_p is NULL"));
/*
* Put back the ethernet header so netgraph has a
* consistent view of inbound packets.
*/
M_PREPEND(m, ETHER_HDR_LEN, M_NOWAIT);
(*ng_ether_input_orphan_p)(ifp, m);
return;
}