From a9bfd080d09a915055af51103defb5c38b94a236 Mon Sep 17 00:00:00 2001 From: Kristof Provost Date: Fri, 2 Jun 2023 16:37:09 +0200 Subject: 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 --- sys/net/if_epair.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'sys') diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index aee5a76a046b..56bfdfbd610f 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -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() -- cgit v1.3