git: cb7a77b8ba80 - stable/12 - 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 05:08:00 UTC
The branch stable/12 has been updated by zlei:
URL: https://cgit.FreeBSD.org/src/commit/?id=cb7a77b8ba80b93f3c07937752e68a26e31451c3
commit cb7a77b8ba80b93f3c07937752e68a26e31451c3
Author: Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2023-03-29 16:16:21 +0000
Commit: Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2023-04-10 05:06:21 +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)
(cherry picked from commit eeb96a7b9178aa55d855203b977564b287d6d108)
---
sys/net/if_lagg.c | 63 ++++++++++++++++++-------------------------------------
1 file changed, 20 insertions(+), 43 deletions(-)
diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c
index c4ea1e9e7637..6a6f08b9696e 100644
--- a/sys/net/if_lagg.c
+++ b/sys/net/if_lagg.c
@@ -164,8 +164,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 *);
@@ -178,14 +176,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 *);
@@ -195,6 +189,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;
@@ -219,7 +217,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,
@@ -231,7 +229,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,
},
@@ -253,7 +251,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,
},
};
@@ -369,14 +367,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)
{
@@ -2171,17 +2169,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
*/
@@ -2232,16 +2219,6 @@ lagg_bcast_start(struct lagg_softc *sc, struct mbuf *m)
return (0);
}
-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
*/
@@ -2383,17 +2360,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
*/
@@ -2484,3 +2450,14 @@ lagg_lacp_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m)
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);
+}