Source-Changes-HG archive

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

[src/trunk]: src/sys lagg: Register lagg_linkstate_changed to link-state chan...



details:   https://anonhg.NetBSD.org/src/rev/a74b99893434
branches:  trunk
changeset: 1023869:a74b99893434
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Thu Sep 30 03:39:39 2021 +0000

description:
lagg: Register lagg_linkstate_changed to link-state change hook

diffstat:

 sys/net/if.c                        |  14 ++------------
 sys/net/lagg/if_lagg.c              |  15 ++++++++++++---
 sys/net/lagg/if_laggproto.h         |   3 ++-
 sys/net/lagg/if_laggvar.h           |   3 +--
 sys/rump/librump/rumpnet/net_stub.c |   5 ++---
 5 files changed, 19 insertions(+), 21 deletions(-)

diffs (167 lines):

diff -r 490f5c94d223 -r a74b99893434 sys/net/if.c
--- a/sys/net/if.c      Thu Sep 30 03:35:55 2021 +0000
+++ b/sys/net/if.c      Thu Sep 30 03:39:39 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.493 2021/09/30 03:35:55 yamaguchi Exp $       */
+/*     $NetBSD: if.c,v 1.494 2021/09/30 03:39:39 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.493 2021/09/30 03:35:55 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.494 2021/09/30 03:39:39 yamaguchi Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -161,11 +161,6 @@
 #include <netinet/ip_carp.h>
 #endif
 
-#include "lagg.h"
-#if NLAGG > 0
-#include <net/lagg/if_laggvar.h>
-#endif
-
 #include <compat/sys/sockio.h>
 
 MALLOC_DEFINE(M_IFADDR, "ifaddr", "interface address");
@@ -2410,11 +2405,6 @@
        if (ifp->if_link_state_changed != NULL)
                ifp->if_link_state_changed(ifp, link_state);
 
-#if NLAGG > 0
-       if (ifp->if_type == IFT_IEEE8023ADLAG)
-               lagg_linkstate_changed(ifp);
-#endif
-
        simplehook_dohooks(ifp->if_linkstate_hooks);
 
        DOMAIN_FOREACH(dp) {
diff -r 490f5c94d223 -r a74b99893434 sys/net/lagg/if_lagg.c
--- a/sys/net/lagg/if_lagg.c    Thu Sep 30 03:35:55 2021 +0000
+++ b/sys/net/lagg/if_lagg.c    Thu Sep 30 03:39:39 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_lagg.c,v 1.6 2021/07/13 09:00:26 ozaki-r Exp $      */
+/*     $NetBSD: if_lagg.c,v 1.7 2021/09/30 03:39:39 yamaguchi Exp $    */
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter <reyk%openbsd.org@localhost>
@@ -20,7 +20,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.6 2021/07/13 09:00:26 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.7 2021/09/30 03:39:39 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -147,6 +147,7 @@
 static int     lagg_media_change(struct ifnet *);
 static void    lagg_media_status(struct ifnet *, struct ifmediareq *);
 static int     lagg_vlan_cb(struct ethercom *, uint16_t, bool);
+static void    lagg_linkstate_changed(void *);
 static struct lagg_softc *
                lagg_softc_alloc(enum lagg_iftypes);
 static void    lagg_softc_free(struct lagg_softc *);
@@ -1970,6 +1971,8 @@
        lp->lp_ifcapenable = ifp_port->if_capenable;
        lp->lp_mtu = mtu_port;
        lp->lp_prio = LAGG_PORT_PRIO;
+       lp->lp_linkstate_hook = if_linkstate_change_establish(ifp_port,
+           lagg_linkstate_changed, ifp_port);
        psref_target_init(&lp->lp_psref, lagg_port_psref_class);
 
        IFNET_LOCK(ifp_port);
@@ -2011,6 +2014,8 @@
 
 restore_lladdr:
        lagg_lladdr_unset(sc, lp, if_type);
+       if_linkstate_change_disestablish(ifp_port,
+           lp->lp_linkstate_hook, NULL);
        psref_target_destroy(&lp->lp_psref, lagg_port_psref_class);
 
        IFNET_LOCK(ifp_port);
@@ -2063,6 +2068,9 @@
        atomic_store_release(&ifp_port->if_lagg, NULL);
        pserialize_perform(sc->sc_psz);
 
+       if_linkstate_change_disestablish(ifp_port,
+           lp->lp_linkstate_hook, NULL);
+
        lagg_proto_stopport(sc, lp);
        psref_target_destroy(&lp->lp_psref, lagg_port_psref_class);
 
@@ -2338,8 +2346,9 @@
 }
 
 void
-lagg_linkstate_changed(struct ifnet *ifp)
+lagg_linkstate_changed(void *xifp)
 {
+       struct ifnet *ifp = xifp;
        struct lagg_port *lp;
        struct psref psref;
        int s, bound;
diff -r 490f5c94d223 -r a74b99893434 sys/net/lagg/if_laggproto.h
--- a/sys/net/lagg/if_laggproto.h       Thu Sep 30 03:35:55 2021 +0000
+++ b/sys/net/lagg/if_laggproto.h       Thu Sep 30 03:39:39 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_laggproto.h,v 1.3 2021/05/24 06:24:20 yamaguchi Exp $       */
+/*     $NetBSD: if_laggproto.h,v 1.4 2021/09/30 03:39:39 yamaguchi Exp $       */
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -68,6 +68,7 @@
        struct lagg_softc       *lp_softc;      /* parent lagg */
        void                    *lp_proto_ctx;
        bool                     lp_detaching;
+       void                    *lp_linkstate_hook;
 
        uint32_t                 lp_prio;       /* port priority */
        uint32_t                 lp_flags;      /* port flags */
diff -r 490f5c94d223 -r a74b99893434 sys/net/lagg/if_laggvar.h
--- a/sys/net/lagg/if_laggvar.h Thu Sep 30 03:35:55 2021 +0000
+++ b/sys/net/lagg/if_laggvar.h Thu Sep 30 03:39:39 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_laggvar.h,v 1.2 2021/05/24 06:08:28 yamaguchi Exp $ */
+/*     $NetBSD: if_laggvar.h,v 1.3 2021/09/30 03:39:39 yamaguchi Exp $ */
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -30,7 +30,6 @@
 #define _NET_LAGG_IF_LAGGVAR_H_
 
 void           lagg_ifdetach(struct ifnet *);
-void           lagg_linkstate_changed(struct ifnet *);
 
 extern struct mbuf *
                (*lagg_input_ethernet_p)(struct ifnet *,
diff -r 490f5c94d223 -r a74b99893434 sys/rump/librump/rumpnet/net_stub.c
--- a/sys/rump/librump/rumpnet/net_stub.c       Thu Sep 30 03:35:55 2021 +0000
+++ b/sys/rump/librump/rumpnet/net_stub.c       Thu Sep 30 03:39:39 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: net_stub.c,v 1.44 2021/09/30 03:35:55 yamaguchi Exp $  */
+/*     $NetBSD: net_stub.c,v 1.45 2021/09/30 03:39:39 yamaguchi Exp $  */
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: net_stub.c,v 1.44 2021/09/30 03:35:55 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: net_stub.c,v 1.45 2021/09/30 03:39:39 yamaguchi Exp $");
 
 #include <sys/mutex.h>
 #include <sys/param.h>
@@ -110,7 +110,6 @@
 /* lagg */
 __weak_alias(lagg_ifdetach,rumpnet_stub);
 __weak_alias(lagg_input_ethernet,rumpnet_stub);
-__weak_alias(lagg_linkstate_changed,rumpnet_stub);
 
 /* altq */
 int (*altq_input)(struct mbuf *, int);



Home | Main Index | Thread Index | Old Index