Source-Changes-HG archive

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

[src/trunk]: src/sys/net bridge: When an interface joins then mark addresses ...



details:   https://anonhg.NetBSD.org/src/rev/782488d44e3b
branches:  trunk
changeset: 939691:782488d44e3b
user:      roy <roy%NetBSD.org@localhost>
date:      Sun Sep 27 19:16:28 2020 +0000

description:
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.

diffstat:

 sys/net/if.c        |  26 ++++++++++++++++++++++++--
 sys/net/if.h        |   3 ++-
 sys/net/if_bridge.c |  18 ++++++++++++++++--
 3 files changed, 42 insertions(+), 5 deletions(-)

diffs (110 lines):

diff -r b57ffc13985a -r 782488d44e3b sys/net/if.c
--- a/sys/net/if.c      Sun Sep 27 19:15:43 2020 +0000
+++ b/sys/net/if.c      Sun Sep 27 19:16:28 2020 +0000
@@ -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 @@
 }
 
 /*
+ * 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.
  */
diff -r b57ffc13985a -r 782488d44e3b sys/net/if.h
--- a/sys/net/if.h      Sun Sep 27 19:15:43 2020 +0000
+++ b/sys/net/if.h      Sun Sep 27 19:16:28 2020 +0000
@@ -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_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);
diff -r b57ffc13985a -r 782488d44e3b sys/net/if_bridge.c
--- a/sys/net/if_bridge.c       Sun Sep 27 19:15:43 2020 +0000
+++ b/sys/net/if_bridge.c       Sun Sep 27 19:16:28 2020 +0000
@@ -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 @@
        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 @@
        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) {



Home | Main Index | Thread Index | Old Index