Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys bridge: Register bridge_calc_link_state to link-state ch...
details: https://anonhg.NetBSD.org/src/rev/490f5c94d223
branches: trunk
changeset: 1023868:490f5c94d223
user: yamaguchi <yamaguchi%NetBSD.org@localhost>
date: Thu Sep 30 03:35:55 2021 +0000
description:
bridge: Register bridge_calc_link_state to link-state change hook
diffstat:
sys/net/if.c | 9 ++-------
sys/net/if_bridge.c | 15 +++++++++++----
sys/net/if_bridgevar.h | 11 ++++++-----
sys/rump/librump/rumpnet/net_stub.c | 5 ++---
4 files changed, 21 insertions(+), 19 deletions(-)
diffs (140 lines):
diff -r 568cee0c694b -r 490f5c94d223 sys/net/if.c
--- a/sys/net/if.c Thu Sep 30 03:23:48 2021 +0000
+++ b/sys/net/if.c Thu Sep 30 03:35:55 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.492 2021/09/30 03:23:48 yamaguchi Exp $ */
+/* $NetBSD: if.c,v 1.493 2021/09/30 03:35:55 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.492 2021/09/30 03:23:48 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.493 2021/09/30 03:35:55 yamaguchi Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -2410,11 +2410,6 @@
if (ifp->if_link_state_changed != NULL)
ifp->if_link_state_changed(ifp, link_state);
-#if NBRIDGE > 0
- if (ifp->if_bridge != NULL)
- bridge_calc_link_state(ifp->if_bridge);
-#endif
-
#if NLAGG > 0
if (ifp->if_type == IFT_IEEE8023ADLAG)
lagg_linkstate_changed(ifp);
diff -r 568cee0c694b -r 490f5c94d223 sys/net/if_bridge.c
--- a/sys/net/if_bridge.c Thu Sep 30 03:23:48 2021 +0000
+++ b/sys/net/if_bridge.c Thu Sep 30 03:35:55 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bridge.c,v 1.181 2021/07/02 03:30:46 yamaguchi Exp $ */
+/* $NetBSD: if_bridge.c,v 1.182 2021/09/30 03:35:55 yamaguchi Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.181 2021/07/02 03:30:46 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.182 2021/09/30 03:35:55 yamaguchi Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -738,6 +738,10 @@
PSLIST_WRITER_REMOVE(bif, bif_next);
BRIDGE_PSZ_PERFORM(sc);
+
+ if_linkstate_change_disestablish(ifs,
+ bif->bif_linkstate_hook, BRIDGE_LOCK_OBJ(sc));
+
BRIDGE_UNLOCK(sc);
switch (ifs->if_type) {
@@ -796,9 +800,10 @@
*
* Calculate the link state based on each member interface.
*/
-void
-bridge_calc_link_state(struct bridge_softc *sc)
+static void
+bridge_calc_link_state(void *xsc)
{
+ struct bridge_softc *sc = xsc;
struct bridge_iflist *bif;
struct ifnet *ifs;
int link_state = LINK_STATE_DOWN;
@@ -889,6 +894,8 @@
bif->bif_flags = IFBIF_LEARNING | IFBIF_DISCOVER;
bif->bif_priority = BSTP_DEFAULT_PORT_PRIORITY;
bif->bif_path_cost = BSTP_DEFAULT_PATH_COST;
+ bif->bif_linkstate_hook = if_linkstate_change_establish(ifs,
+ bridge_calc_link_state, sc);
PSLIST_ENTRY_INIT(bif, bif_next);
psref_target_init(&bif->bif_psref, bridge_psref_class);
diff -r 568cee0c694b -r 490f5c94d223 sys/net/if_bridgevar.h
--- a/sys/net/if_bridgevar.h Thu Sep 30 03:23:48 2021 +0000
+++ b/sys/net/if_bridgevar.h Thu Sep 30 03:35:55 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bridgevar.h,v 1.35 2020/09/27 00:32:17 roy Exp $ */
+/* $NetBSD: if_bridgevar.h,v 1.36 2021/09/30 03:35:55 yamaguchi Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -269,6 +269,7 @@
struct ifnet *bif_ifp; /* member if */
uint32_t bif_flags; /* member if flags */
struct psref_target bif_psref;
+ void * *bif_linkstate_hook;
};
/*
@@ -346,11 +347,11 @@
int);
void bridge_calc_csum_flags(struct bridge_softc *);
-void bridge_calc_link_state(struct bridge_softc *);
-#define BRIDGE_LOCK(_sc) mutex_enter(&(_sc)->sc_iflist_psref.bip_lock)
-#define BRIDGE_UNLOCK(_sc) mutex_exit(&(_sc)->sc_iflist_psref.bip_lock)
-#define BRIDGE_LOCKED(_sc) mutex_owned(&(_sc)->sc_iflist_psref.bip_lock)
+#define BRIDGE_LOCK_OBJ(_sc) (&(_sc)->sc_iflist_psref.bip_lock)
+#define BRIDGE_LOCK(_sc) mutex_enter(BRIDGE_LOCK_OBJ(_sc))
+#define BRIDGE_UNLOCK(_sc) mutex_exit(BRIDGE_LOCK_OBJ(_sc))
+#define BRIDGE_LOCKED(_sc) mutex_owned(BRIDGE_LOCK_OBJ(_sc))
#define BRIDGE_PSZ_RENTER(__s) do { __s = pserialize_read_enter(); } while (0)
#define BRIDGE_PSZ_REXIT(__s) do { pserialize_read_exit(__s); } while (0)
diff -r 568cee0c694b -r 490f5c94d223 sys/rump/librump/rumpnet/net_stub.c
--- a/sys/rump/librump/rumpnet/net_stub.c Thu Sep 30 03:23:48 2021 +0000
+++ b/sys/rump/librump/rumpnet/net_stub.c Thu Sep 30 03:35:55 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: net_stub.c,v 1.43 2021/07/14 03:19:24 ozaki-r Exp $ */
+/* $NetBSD: net_stub.c,v 1.44 2021/09/30 03:35:55 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.43 2021/07/14 03:19:24 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: net_stub.c,v 1.44 2021/09/30 03:35:55 yamaguchi Exp $");
#include <sys/mutex.h>
#include <sys/param.h>
@@ -62,7 +62,6 @@
__weak_alias(bridge_ifdetach,rumpnet_stub);
__weak_alias(bridge_output,rumpnet_stub);
__weak_alias(bridge_calc_csum_flags,rumpnet_stub);
-__weak_alias(bridge_calc_link_state,rumpnet_stub);
/* agr */
__weak_alias(agr_input,rumpnet_stub);
Home |
Main Index |
Thread Index |
Old Index