git: 48227d1c6db8 - main - epair: Avoid loading m_flags into a short
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Mar 2023 17:52:50 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=48227d1c6db8fceaceebbf8578612302d64ca170 commit 48227d1c6db8fceaceebbf8578612302d64ca170 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2023-03-06 14:39:17 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2023-03-06 17:39:11 +0000 epair: Avoid loading m_flags into a short The m_flags field of struct mbuf is 24 bits wide and so gets truncated in a couple of places in the epair code. Instead of preserving the entire flag set, just remember whether M_BCAST or M_MCAST is set. MFC after: 1 week Sponsored by: Klara, Inc. --- sys/net/if_epair.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index 81538c0cb157..3fa4c47a0bca 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -239,7 +239,7 @@ epair_menq(struct mbuf *m, struct epair_softc *osc) struct ifnet *ifp, *oifp; int len, ret; int ridx; - short mflags; + bool mcast; /* * I know this looks weird. We pass the "other sc" as we need that one @@ -252,7 +252,7 @@ epair_menq(struct mbuf *m, struct epair_softc *osc) /* Save values as once the mbuf is queued, it's not ours anymore. */ len = m->m_pkthdr.len; - mflags = m->m_flags; + mcast = (m->m_flags & (M_BCAST | M_MCAST)) != 0; struct epair_queue *q = epair_select_queue(osc, m); @@ -273,7 +273,7 @@ epair_menq(struct mbuf *m, struct epair_softc *osc) * the logic another time. */ if_inc_counter(ifp, IFCOUNTER_OBYTES, len); - if (mflags & (M_BCAST|M_MCAST)) + if (mcast) if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); /* Someone else received the packet. */ if_inc_counter(oifp, IFCOUNTER_IPACKETS, 1); @@ -325,7 +325,7 @@ epair_transmit(struct ifnet *ifp, struct mbuf *m) struct ifnet *oifp; #ifdef ALTQ int len; - short mflags; + bool mcast; #endif if (m == NULL) @@ -366,7 +366,7 @@ epair_transmit(struct ifnet *ifp, struct mbuf *m) #ifdef ALTQ len = m->m_pkthdr.len; - mflags = m->m_flags; + mcast = (m->m_flags & (M_BCAST | M_MCAST)) != 0; int error = 0; /* Support ALTQ via the classic if_start() path. */ @@ -378,7 +378,7 @@ epair_transmit(struct ifnet *ifp, struct mbuf *m) IF_UNLOCK(&ifp->if_snd); if (!error) { if_inc_counter(ifp, IFCOUNTER_OBYTES, len); - if (mflags & (M_BCAST|M_MCAST)) + if (mcast) if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); epair_start(ifp); }