git: eeb96a7b9178 - stable/13 - lagg(4): Refactor out some lagg protocol input routines into a default one
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 10 Apr 2023 04:16:44 UTC
The branch stable/13 has been updated by zlei:
URL: https://cgit.FreeBSD.org/src/commit/?id=eeb96a7b9178aa55d855203b977564b287d6d108
commit eeb96a7b9178aa55d855203b977564b287d6d108
Author: Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2023-03-29 16:16:21 +0000
Commit: Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2023-04-10 04:15:04 +0000
lagg(4): Refactor out some lagg protocol input routines into a default one
Those input routines are identical.
Also inline two fast paths.
No functional change intended.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39251
(cherry picked from commit dbe86dd5de18fdf61e1300f6575e0f50785bf6b3)
---
sys/net/if_lagg.c | 64 ++++++++++++++++++-------------------------------------
1 file changed, 21 insertions(+), 43 deletions(-)
diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c
index cf332ea529e9..e282fde66013 100644
--- a/sys/net/if_lagg.c
+++ b/sys/net/if_lagg.c
@@ -173,8 +173,6 @@ static struct lagg_port *lagg_link_active(struct lagg_softc *,
/* Simple round robin */
static void lagg_rr_attach(struct lagg_softc *);
static int lagg_rr_start(struct lagg_softc *, struct mbuf *);
-static struct mbuf *lagg_rr_input(struct lagg_softc *, struct lagg_port *,
- struct mbuf *);
/* Active failover */
static int lagg_fail_start(struct lagg_softc *, struct mbuf *);
@@ -187,14 +185,10 @@ static void lagg_lb_detach(struct lagg_softc *);
static int lagg_lb_port_create(struct lagg_port *);
static void lagg_lb_port_destroy(struct lagg_port *);
static int lagg_lb_start(struct lagg_softc *, struct mbuf *);
-static struct mbuf *lagg_lb_input(struct lagg_softc *, struct lagg_port *,
- struct mbuf *);
static int lagg_lb_porttable(struct lagg_softc *, struct lagg_port *);
/* Broadcast */
static int lagg_bcast_start(struct lagg_softc *, struct mbuf *);
-static struct mbuf *lagg_bcast_input(struct lagg_softc *, struct lagg_port *,
- struct mbuf *);
/* 802.3ad LACP */
static void lagg_lacp_attach(struct lagg_softc *);
@@ -204,6 +198,10 @@ static struct mbuf *lagg_lacp_input(struct lagg_softc *, struct lagg_port *,
struct mbuf *);
static void lagg_lacp_lladdr(struct lagg_softc *);
+/* Default input */
+static struct mbuf *lagg_default_input(struct lagg_softc *, struct lagg_port *,
+ struct mbuf *);
+
/* lagg protocol table */
static const struct lagg_proto {
lagg_proto pr_num;
@@ -228,7 +226,7 @@ static const struct lagg_proto {
.pr_num = LAGG_PROTO_ROUNDROBIN,
.pr_attach = lagg_rr_attach,
.pr_start = lagg_rr_start,
- .pr_input = lagg_rr_input,
+ .pr_input = lagg_default_input,
},
{
.pr_num = LAGG_PROTO_FAILOVER,
@@ -240,7 +238,7 @@ static const struct lagg_proto {
.pr_attach = lagg_lb_attach,
.pr_detach = lagg_lb_detach,
.pr_start = lagg_lb_start,
- .pr_input = lagg_lb_input,
+ .pr_input = lagg_default_input,
.pr_addport = lagg_lb_port_create,
.pr_delport = lagg_lb_port_destroy,
},
@@ -262,7 +260,7 @@ static const struct lagg_proto {
{
.pr_num = LAGG_PROTO_BROADCAST,
.pr_start = lagg_bcast_start,
- .pr_input = lagg_bcast_input,
+ .pr_input = lagg_default_input,
},
};
@@ -385,14 +383,14 @@ lagg_proto_detach(struct lagg_softc *sc)
lagg_protos[pr].pr_detach(sc);
}
-static int
+static inline int
lagg_proto_start(struct lagg_softc *sc, struct mbuf *m)
{
return (lagg_protos[sc->sc_proto].pr_start(sc, m));
}
-static struct mbuf *
+static inline struct mbuf *
lagg_proto_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m)
{
@@ -2319,17 +2317,6 @@ lagg_rr_start(struct lagg_softc *sc, struct mbuf *m)
return (lagg_enqueue(lp->lp_ifp, m));
}
-static struct mbuf *
-lagg_rr_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m)
-{
- struct ifnet *ifp = sc->sc_ifp;
-
- /* Just pass in the packet to our lagg device */
- m->m_pkthdr.rcvif = ifp;
-
- return (m);
-}
-
/*
* Broadcast mode
*/
@@ -2377,16 +2364,6 @@ lagg_bcast_start(struct lagg_softc *sc, struct mbuf *m)
return (ret);
}
-static struct mbuf*
-lagg_bcast_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m)
-{
- struct ifnet *ifp = sc->sc_ifp;
-
- /* Just pass in the packet to our lagg device */
- m->m_pkthdr.rcvif = ifp;
- return (m);
-}
-
/*
* Active failover
*/
@@ -2530,17 +2507,6 @@ lagg_lb_start(struct lagg_softc *sc, struct mbuf *m)
return (lagg_enqueue(lp->lp_ifp, m));
}
-static struct mbuf *
-lagg_lb_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m)
-{
- struct ifnet *ifp = sc->sc_ifp;
-
- /* Just pass in the packet to our lagg device */
- m->m_pkthdr.rcvif = ifp;
-
- return (m);
-}
-
/*
* 802.3ad LACP
*/
@@ -2632,3 +2598,15 @@ lagg_lacp_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m)
m->m_pkthdr.rcvif = ifp;
return (m);
}
+
+/* Default input */
+static struct mbuf *
+lagg_default_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m)
+{
+ struct ifnet *ifp = sc->sc_ifp;
+
+ /* Just pass in the packet to our lagg device */
+ m->m_pkthdr.rcvif = ifp;
+
+ return (m);
+}