Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Replace ifnet::if_agriprivate with ifnet::if_lagg



details:   https://anonhg.NetBSD.org/src/rev/13faf0cc03a2
branches:  trunk
changeset: 987503:13faf0cc03a2
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Thu Sep 30 03:15:25 2021 +0000

description:
Replace ifnet::if_agriprivate with ifnet::if_lagg

agr(4) and lagg(4) can not be used on the same interface so that
if_agrprivate and if_lagg are not used at the same time.
For resolve this wasteful, if_lagg is used in not only lagg(4)
but also agr(4).

After this modification, if_lagg has 3 states:
1. if_lagg == NULL
   - Both agr(4) and lagg(4) are not running on the interface
2. if_lagg != NULL && ifp->if_type != IFT_IEEE8023ADLAG
   - agr(4) is running on the I/F
3. if_lagg != NULL && ifp->if_type == IFT_IEEE8023ADLAG
   - lagg(4) is running on the I/F

diffstat:

 sys/net/agr/ieee8023ad_lacp.c   |   6 +++---
 sys/net/agr/ieee8023ad_marker.c |   6 +++---
 sys/net/agr/if_agr.c            |  20 ++++++++++----------
 sys/net/if.c                    |   6 +++---
 sys/net/if.h                    |   5 ++---
 sys/net/if_ethersubr.c          |  18 +++++++++++++-----
 6 files changed, 34 insertions(+), 27 deletions(-)

diffs (246 lines):

diff -r 4d6c2cca0577 -r 13faf0cc03a2 sys/net/agr/ieee8023ad_lacp.c
--- a/sys/net/agr/ieee8023ad_lacp.c     Thu Sep 30 02:00:19 2021 +0000
+++ b/sys/net/agr/ieee8023ad_lacp.c     Thu Sep 30 03:15:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ieee8023ad_lacp.c,v 1.11 2020/01/29 04:30:41 thorpej Exp $     */
+/*     $NetBSD: ieee8023ad_lacp.c,v 1.12 2021/09/30 03:15:25 yamaguchi Exp $   */
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ieee8023ad_lacp.c,v 1.11 2020/01/29 04:30:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee8023ad_lacp.c,v 1.12 2021/09/30 03:15:25 yamaguchi Exp $");
 
 #include <sys/param.h>
 #include <sys/callout.h>
@@ -97,7 +97,7 @@
        struct lacp_port *lp;
        int error = 0;
 
-       port = ifp->if_agrprivate; /* XXX race with agr_remport. */
+       port = ifp->if_lagg; /* XXX race with agr_remport. */
        if (__predict_false(port->port_flags & AGRPORT_DETACHING)) {
                goto bad;
        }
diff -r 4d6c2cca0577 -r 13faf0cc03a2 sys/net/agr/ieee8023ad_marker.c
--- a/sys/net/agr/ieee8023ad_marker.c   Thu Sep 30 02:00:19 2021 +0000
+++ b/sys/net/agr/ieee8023ad_marker.c   Thu Sep 30 03:15:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ieee8023ad_marker.c,v 1.4 2007/02/22 06:20:16 thorpej Exp $    */
+/*     $NetBSD: ieee8023ad_marker.c,v 1.5 2021/09/30 03:15:25 yamaguchi Exp $  */
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ieee8023ad_marker.c,v 1.4 2007/02/22 06:20:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee8023ad_marker.c,v 1.5 2021/09/30 03:15:25 yamaguchi Exp $");
 
 #include <sys/param.h>
 #include <sys/callout.h>
@@ -60,7 +60,7 @@
        struct agr_port *port;
        int error = 0;
 
-       port = ifp->if_agrprivate; /* XXX race with agr_remport. */
+       port = ifp->if_lagg; /* XXX race with agr_remport. */
        KASSERT(port);
        if (__predict_false(port->port_flags & AGRPORT_DETACHING)) {
                goto bad;
diff -r 4d6c2cca0577 -r 13faf0cc03a2 sys/net/agr/if_agr.c
--- a/sys/net/agr/if_agr.c      Thu Sep 30 02:00:19 2021 +0000
+++ b/sys/net/agr/if_agr.c      Thu Sep 30 03:15:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_agr.c,v 1.52 2021/08/02 12:56:25 andvar Exp $       */
+/*     $NetBSD: if_agr.c,v 1.53 2021/09/30 03:15:25 yamaguchi Exp $    */
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.52 2021/08/02 12:56:25 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.53 2021/09/30 03:15:25 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -151,7 +151,7 @@
        struct agr_port *port;
        struct ifnet *ifp;
 
-       port = ifp_port->if_agrprivate;
+       port = ifp_port->if_lagg;
        KASSERT(port);
        ifp = port->port_agrifp;
        if ((port->port_flags & AGRPORT_COLLECTING) == 0) {
@@ -234,7 +234,7 @@
 {
        struct ifnet *ifp = port->port_ifp;
 
-       KASSERT(ifp->if_agrprivate == (void *)port);
+       KASSERT(ifp->if_lagg == (void *)port);
        KASSERT(ifp->if_ioctl == agr_ioctl_filter);
 
        return (*port->port_ioctl)(ifp, cmd, arg);
@@ -542,7 +542,7 @@
                goto out;
        }
 
-       if (ifp_port->if_agrprivate) {
+       if (ifp_port->if_lagg) {
                error = EBUSY;
                goto out;
        }
@@ -623,7 +623,7 @@
        AGR_LOCK(sc);
 
        port->port_ifp = ifp_port;
-       ifp_port->if_agrprivate = port;
+       ifp_port->if_lagg = port;
        port->port_agrifp = ifp;
        TAILQ_INSERT_TAIL(&sc->sc_ports, port, port_q);
        sc->sc_nports++;
@@ -686,12 +686,12 @@
        struct agr_port *port;
        int error = 0;
 
-       if (ifp_port->if_agrprivate == NULL) {
+       if (ifp_port->if_lagg == NULL) {
                error = ENOENT;
                return error;
        }
 
-       port = ifp_port->if_agrprivate;
+       port = ifp_port->if_lagg;
        if (port->port_agrifp != ifp) {
                error = EINVAL;
                return error;
@@ -786,7 +786,7 @@
 
        AGR_LOCK(sc);
        if ((port->port_flags & AGRPORT_ATTACHED)) {
-               ifp_port->if_agrprivate = NULL;
+               ifp_port->if_lagg = NULL;
 
                TAILQ_REMOVE(&sc->sc_ports, port, port_q);
                sc->sc_nports--;
@@ -823,7 +823,7 @@
 static int
 agr_ioctl_filter(struct ifnet *ifp, u_long cmd, void *arg)
 {
-       struct agr_port *port = ifp->if_agrprivate;
+       struct agr_port *port = ifp->if_lagg;
        int error;
 
        KASSERT(port);
diff -r 4d6c2cca0577 -r 13faf0cc03a2 sys/net/if.c
--- a/sys/net/if.c      Thu Sep 30 02:00:19 2021 +0000
+++ b/sys/net/if.c      Thu Sep 30 03:15:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.490 2021/09/21 14:57:26 christos Exp $        */
+/*     $NetBSD: if.c,v 1.491 2021/09/30 03:15:25 yamaguchi Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.490 2021/09/21 14:57:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.491 2021/09/30 03:15:25 yamaguchi Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -2408,7 +2408,7 @@
 #endif
 
 #if NLAGG > 0
-       if (ifp->if_lagg != NULL)
+       if (ifp->if_type == IFT_IEEE8023ADLAG)
                lagg_linkstate_changed(ifp);
 #endif
 
diff -r 4d6c2cca0577 -r 13faf0cc03a2 sys/net/if.h
--- a/sys/net/if.h      Thu Sep 30 02:00:19 2021 +0000
+++ b/sys/net/if.h      Thu Sep 30 03:15:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.h,v 1.292 2021/08/09 20:49:10 andvar Exp $  */
+/*     $NetBSD: if.h,v 1.293 2021/09/30 03:15:25 yamaguchi Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -380,8 +380,7 @@
                                        /* a: */
        struct mowner   *if_mowner;     /* ?: who owns mbufs for this interface */
 
-       void            *if_agrprivate; /* ?: used only when #if NAGR > 0 */
-       void            *if_lagg;       /* ?: used only when #if NLAGG > 0 */
+       void            *if_lagg;       /* :: lagg or agr structure */
        void            *if_npf_private;/* ?: associated NPF context */
 
        /*
diff -r 4d6c2cca0577 -r 13faf0cc03a2 sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Thu Sep 30 02:00:19 2021 +0000
+++ b/sys/net/if_ethersubr.c    Thu Sep 30 03:15:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ethersubr.c,v 1.293 2021/05/17 04:07:43 yamaguchi Exp $     */
+/*     $NetBSD: if_ethersubr.c,v 1.294 2021/09/30 03:15:25 yamaguchi Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.293 2021/05/17 04:07:43 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.294 2021/09/30 03:15:25 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -651,6 +651,9 @@
        size_t ehlen;
        static int earlypkts;
        int isr = 0;
+#if NAGR > 0
+       void *agrprivate;
+#endif
 
        KASSERT(!cpu_intr_p());
        KASSERT((m->m_flags & M_PKTHDR) != 0);
@@ -753,7 +756,12 @@
        }
 
 #if NAGR > 0
-       if (ifp->if_agrprivate &&
+       if (ifp->if_type != IFT_IEEE8023ADLAG) {
+               agrprivate = ifp->if_lagg;
+       } else {
+               agrprivate = NULL;
+       }
+       if (agrprivate != NULL &&
            __predict_true(etype != ETHERTYPE_SLOWPROTOCOLS)) {
                m->m_flags &= ~M_PROMISC;
                agr_input(ifp, m);
@@ -843,14 +851,14 @@
                switch (subtype) {
 #if NAGR > 0
                case SLOWPROTOCOLS_SUBTYPE_LACP:
-                       if (ifp->if_agrprivate) {
+                       if (agrprivate != NULL) {
                                ieee8023ad_lacp_input(ifp, m);
                                return;
                        }
                        break;
 
                case SLOWPROTOCOLS_SUBTYPE_MARKER:
-                       if (ifp->if_agrprivate) {
+                       if (agrprivate != NULL) {
                                ieee8023ad_marker_input(ifp, m);
                                return;
                        }



Home | Main Index | Thread Index | Old Index