if_epair: delete mbuf tags

Remove all (non-persistent) tags when we transmit a packet. Real network
interfaces do not carry any tags either, and leaving tags attached can
produce unexpected results.

Reviewed by:	bz, glebius
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32663
This commit is contained in:
Kristof Provost 2021-10-26 09:57:56 +02:00
parent 8a727c3df8
commit 62d2dcafb7

View File

@ -196,6 +196,19 @@ struct epair_dpcpu {
};
DPCPU_DEFINE(struct epair_dpcpu, epair_dpcpu);
static void
epair_clear_mbuf(struct mbuf *m)
{
/* Remove any CSUM_SND_TAG as ether_input will barf. */
if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) {
m_snd_tag_rele(m->m_pkthdr.snd_tag);
m->m_pkthdr.snd_tag = NULL;
m->m_pkthdr.csum_flags &= ~CSUM_SND_TAG;
}
m_tag_delete_nonpersistent(m);
}
static void
epair_dpcpu_init(void)
{
@ -435,6 +448,8 @@ epair_start_locked(struct ifnet *ifp)
}
DPRINTF("packet %s -> %s\n", ifp->if_xname, oifp->if_xname);
epair_clear_mbuf(m);
/*
* Add a reference so the interface cannot go while the
* packet is in transit as we rely on rcvif to stay valid.
@ -556,6 +571,9 @@ epair_transmit_locked(struct ifnet *ifp, struct mbuf *m)
(void)epair_add_ifp_for_draining(ifp);
return (error);
}
epair_clear_mbuf(m);
sc = oifp->if_softc;
/*
* Add a reference so the interface cannot go while the