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.
This commit is contained in:
parent
0490d42245
commit
039adaac92
26
sys/net/if.c
26
sys/net/if.c
@ -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"
|
||||
@ -2472,6 +2472,28 @@ out:
|
||||
KERNEL_UNLOCK_UNLESS_NET_MPSAFE();
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
|
@ -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);
|
||||
|
@ -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, void *arg)
|
||||
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, void *arg)
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user