git: a9bfd080d09a - main - if_epair: do not transmit packets that exceed the interface MTU
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 06 Jun 2023 08:52:27 UTC
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=a9bfd080d09a915055af51103defb5c38b94a236 commit a9bfd080d09a915055af51103defb5c38b94a236 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2023-06-02 14:37:09 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2023-06-06 08:00:48 +0000 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(+) 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()