if_epair: do not transmit packets that exceed the interface MTU

While if_epair has no issues doing this we should drop those packets
anyway, because it improves the fidelity of the automated tests.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D40397
This commit is contained in:
Kristof Provost 2023-06-02 16:37:09 +02:00
parent 1bbdfb0b43
commit a9bfd080d0

View file

@ -336,6 +336,17 @@ epair_transmit(struct ifnet *ifp, struct mbuf *m)
return (0);
M_ASSERTPKTHDR(m);
/*
* We could just transmit this, but it makes testing easier if we're a
* little bit more like real hardware.
* Allow just that little bit extra for ethernet (and vlan) headers.
*/
if (m->m_pkthdr.len > (ifp->if_mtu + sizeof(struct ether_vlan_header))) {
m_freem(m);
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
return (E2BIG);
}
/*
* We are not going to use the interface en/dequeue mechanism
* on the TX side. We are called from ether_output_frame()