git: 758fea562555 - stable/13 - lagg(4): Do not enter net epoch recursively

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Mon, 10 Apr 2023 04:16:45 UTC
The branch stable/13 has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=758fea562555ab90979b4bd269aa2cd084de63bb

commit 758fea562555ab90979b4bd269aa2cd084de63bb
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2023-03-29 16:25:16 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2023-04-10 04:15:04 +0000

    lagg(4): Do not enter net epoch recursively
    
    This saves a little resources.
    
    No functional change intended.
    
    Reviewed by:    kp
    Fixes:          b8a6e03fac92 Widen NET_EPOCH coverage
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D39267
    
    (cherry picked from commit d4a80d21b3d32a2de02d1820cc1f38dba1f127cb)
---
 sys/net/if_lagg.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c
index e282fde66013..8a62286db81b 100644
--- a/sys/net/if_lagg.c
+++ b/sys/net/if_lagg.c
@@ -2006,18 +2006,15 @@ lagg_setflags(struct lagg_port *lp, int status)
 static int
 lagg_transmit_ethernet(struct ifnet *ifp, struct mbuf *m)
 {
-	struct epoch_tracker et;
 	struct lagg_softc *sc = (struct lagg_softc *)ifp->if_softc;
-	int error;
 
+	NET_EPOCH_ASSERT();
 #if defined(KERN_TLS) || defined(RATELIMIT)
 	if (m->m_pkthdr.csum_flags & CSUM_SND_TAG)
 		MPASS(m->m_pkthdr.snd_tag->ifp == ifp);
 #endif
-	NET_EPOCH_ENTER(et);
 	/* We need a Tx algorithm and at least one port */
 	if (sc->sc_proto == LAGG_PROTO_NONE || sc->sc_count == 0) {
-		NET_EPOCH_EXIT(et);
 		m_freem(m);
 		if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
 		return (ENXIO);
@@ -2025,26 +2022,21 @@ lagg_transmit_ethernet(struct ifnet *ifp, struct mbuf *m)
 
 	ETHER_BPF_MTAP(ifp, m);
 
-	error = lagg_proto_start(sc, m);
-	NET_EPOCH_EXIT(et);
-	return (error);
+	return (lagg_proto_start(sc, m));
 }
 
 static int
 lagg_transmit_infiniband(struct ifnet *ifp, struct mbuf *m)
 {
-	struct epoch_tracker et;
 	struct lagg_softc *sc = (struct lagg_softc *)ifp->if_softc;
-	int error;
 
+	NET_EPOCH_ASSERT();
 #if defined(KERN_TLS) || defined(RATELIMIT)
 	if (m->m_pkthdr.csum_flags & CSUM_SND_TAG)
 		MPASS(m->m_pkthdr.snd_tag->ifp == ifp);
 #endif
-	NET_EPOCH_ENTER(et);
 	/* We need a Tx algorithm and at least one port */
 	if (sc->sc_proto == LAGG_PROTO_NONE || sc->sc_count == 0) {
-		NET_EPOCH_EXIT(et);
 		m_freem(m);
 		if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
 		return (ENXIO);
@@ -2052,9 +2044,7 @@ lagg_transmit_infiniband(struct ifnet *ifp, struct mbuf *m)
 
 	INFINIBAND_BPF_MTAP(ifp, m);
 
-	error = lagg_proto_start(sc, m);
-	NET_EPOCH_EXIT(et);
-	return (error);
+	return (lagg_proto_start(sc, m));
 }
 
 /*
@@ -2068,16 +2058,14 @@ lagg_qflush(struct ifnet *ifp __unused)
 static struct mbuf *
 lagg_input_ethernet(struct ifnet *ifp, struct mbuf *m)
 {
-	struct epoch_tracker et;
 	struct lagg_port *lp = ifp->if_lagg;
 	struct lagg_softc *sc = lp->lp_softc;
 	struct ifnet *scifp = sc->sc_ifp;
 
-	NET_EPOCH_ENTER(et);
+	NET_EPOCH_ASSERT();
 	if ((scifp->if_drv_flags & IFF_DRV_RUNNING) == 0 ||
 	    lp->lp_detaching != 0 ||
 	    sc->sc_proto == LAGG_PROTO_NONE) {
-		NET_EPOCH_EXIT(et);
 		m_freem(m);
 		return (NULL);
 	}
@@ -2090,7 +2078,6 @@ lagg_input_ethernet(struct ifnet *ifp, struct mbuf *m)
 		m = NULL;
 	}
 
-	NET_EPOCH_EXIT(et);
 	return (m);
 }