Module Name: src
Committed By: roy
Date: Sun Sep 27 19:16:28 UTC 2020
Modified Files:
src/sys/net: if.c if.h if_bridge.c
Log Message:
bridge: When an interface joins then mark addresses on it as tentative
The exact flow is detatch addresses, join bridge and then mark detached
addresses as tentative.
This ensures that Duplicate Address Detection for the joining interface
are performed across all members of the bridge.
To generate a diff of this commit:
cvs rdiff -u -r1.482 -r1.483 src/sys/net/if.c
cvs rdiff -u -r1.287 -r1.288 src/sys/net/if.h
cvs rdiff -u -r1.175 -r1.176 src/sys/net/if_bridge.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.482 src/sys/net/if.c:1.483
--- src/sys/net/if.c:1.482 Sun Sep 27 00:32:17 2020
+++ src/sys/net/if.c Sun Sep 27 19:16:28 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.482 2020/09/27 00:32:17 roy Exp $ */
+/* $NetBSD: if.c,v 1.483 2020/09/27 19:16:28 roy 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.482 2020/09/27 00:32:17 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.483 2020/09/27 19:16:28 roy Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -2473,6 +2473,28 @@ out:
}
/*
+ * Used to mark addresses on an interface as DETATCHED or TENTATIVE
+ * and thus start Duplicate Address Detection without changing the
+ * real link state.
+ */
+void
+if_domain_link_state_change(struct ifnet *ifp, int link_state)
+{
+ struct domain *dp;
+ int s = splnet();
+
+ KERNEL_LOCK_UNLESS_NET_MPSAFE();
+
+ DOMAIN_FOREACH(dp) {
+ if (dp->dom_if_link_state_change != NULL)
+ dp->dom_if_link_state_change(ifp, link_state);
+ }
+
+ splx(s);
+ KERNEL_UNLOCK_UNLESS_NET_MPSAFE();
+}
+
+/*
* Default action when installing a local route on a point-to-point
* interface.
*/
Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.287 src/sys/net/if.h:1.288
--- src/sys/net/if.h:1.287 Sat Sep 26 18:35:12 2020
+++ src/sys/net/if.h Sun Sep 27 19:16:28 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.287 2020/09/26 18:35:12 roy Exp $ */
+/* $NetBSD: if.h,v 1.288 2020/09/27 19:16:28 roy Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -1134,6 +1134,7 @@ void if_detach(struct ifnet *);
void if_down(struct ifnet *);
void if_down_locked(struct ifnet *);
void if_link_state_change(struct ifnet *, int);
+void if_domain_link_state_change(struct ifnet *, int);
void if_up(struct ifnet *);
void ifinit(void);
void ifinit1(void);
Index: src/sys/net/if_bridge.c
diff -u src/sys/net/if_bridge.c:1.175 src/sys/net/if_bridge.c:1.176
--- src/sys/net/if_bridge.c:1.175 Sun Sep 27 00:32:17 2020
+++ src/sys/net/if_bridge.c Sun Sep 27 19:16:28 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bridge.c,v 1.175 2020/09/27 00:32:17 roy Exp $ */
+/* $NetBSD: if_bridge.c,v 1.176 2020/09/27 19:16:28 roy Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.175 2020/09/27 00:32:17 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.176 2020/09/27 19:16:28 roy Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -904,6 +904,13 @@ bridge_ioctl_add(struct bridge_softc *sc
PSLIST_ENTRY_INIT(bif, bif_next);
psref_target_init(&bif->bif_psref, bridge_psref_class);
+ /*
+ * Pretend that the link is down for domains.
+ * This will detach any addresses assigned to the interface.
+ */
+ if (ifs->if_link_state != LINK_STATE_DOWN)
+ if_domain_link_state_change(ifs, LINK_STATE_DOWN);
+
BRIDGE_LOCK(sc);
ifs->if_bridge = sc;
@@ -921,6 +928,13 @@ bridge_ioctl_add(struct bridge_softc *sc
else
bstp_stop(sc);
+ /*
+ * If the link was not initially down then mark any detached addresses
+ * as tentative and start Duplicate Address Detection for them.
+ */
+ if (ifs->if_link_state != LINK_STATE_DOWN)
+ if_domain_link_state_change(ifs, ifs->if_link_state);
+
out:
if_put(ifs, &psref);
if (error) {