Move in6if_do_dad() to if_do_dad() as the routine is not INET6 specific
and could equally be used by INET.
This commit is contained in:
parent
cc09a3cba1
commit
2aa9f440e3
37
sys/net/if.c
37
sys/net/if.c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if.c,v 1.308 2015/01/16 10:36:14 ozaki-r Exp $ */
|
||||
/* $NetBSD: if.c,v 1.309 2015/04/07 23:30:36 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.308 2015/01/16 10:36:14 ozaki-r Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.309 2015/04/07 23:30:36 roy Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_inet.h"
|
||||
|
@ -2316,6 +2316,39 @@ if_addr_init(ifnet_t *ifp, struct ifaddr *ifa, const bool src)
|
|||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
if_do_dad(struct ifnet *ifp)
|
||||
{
|
||||
if ((ifp->if_flags & IFF_LOOPBACK) != 0)
|
||||
return 0;
|
||||
|
||||
switch (ifp->if_type) {
|
||||
case IFT_FAITH:
|
||||
/*
|
||||
* These interfaces do not have the IFF_LOOPBACK flag,
|
||||
* but loop packets back. We do not have to do DAD on such
|
||||
* interfaces. We should even omit it, because loop-backed
|
||||
* responses would confuse the DAD procedure.
|
||||
*/
|
||||
return 0;
|
||||
default:
|
||||
/*
|
||||
* Our DAD routine requires the interface up and running.
|
||||
* However, some interfaces can be up before the RUNNING
|
||||
* status. Additionaly, users may try to assign addresses
|
||||
* before the interface becomes up (or running).
|
||||
* We simply skip DAD in such a case as a work around.
|
||||
* XXX: we should rather mark "tentative" on such addresses,
|
||||
* and do DAD after the interface becomes ready.
|
||||
*/
|
||||
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) !=
|
||||
(IFF_UP|IFF_RUNNING))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
if_flags_set(ifnet_t *ifp, const short flags)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if.h,v 1.186 2015/04/03 08:20:55 msaitoh Exp $ */
|
||||
/* $NetBSD: if.h,v 1.187 2015/04/07 23:30:36 roy Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -879,6 +879,7 @@ int ifioctl_common(struct ifnet *, u_long, void *);
|
|||
int ifpromisc(struct ifnet *, int);
|
||||
struct ifnet *ifunit(const char *);
|
||||
int if_addr_init(ifnet_t *, struct ifaddr *, bool);
|
||||
int if_do_dad(struct ifnet *);
|
||||
int if_mcast_op(ifnet_t *, const unsigned long, const struct sockaddr *);
|
||||
int if_flags_set(struct ifnet *, const short);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: in6.c,v 1.185 2015/02/26 12:58:36 roy Exp $ */
|
||||
/* $NetBSD: in6.c,v 1.186 2015/04/07 23:30:36 roy Exp $ */
|
||||
/* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -62,7 +62,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.185 2015/02/26 12:58:36 roy Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.186 2015/04/07 23:30:36 roy Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_compat_netbsd.h"
|
||||
|
@ -979,7 +979,7 @@ in6_update_ifa1(struct ifnet *ifp, struct in6_aliasreq *ifra,
|
|||
if (ifp->if_link_state == LINK_STATE_DOWN) {
|
||||
ia->ia6_flags |= IN6_IFF_DETACHED;
|
||||
ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
|
||||
} else if ((hostIsNew || was_tentative) && in6if_do_dad(ifp))
|
||||
} else if ((hostIsNew || was_tentative) && if_do_dad(ifp))
|
||||
ia->ia6_flags |= IN6_IFF_TENTATIVE;
|
||||
|
||||
/*
|
||||
|
@ -1205,7 +1205,7 @@ in6_update_ifa1(struct ifnet *ifp, struct in6_aliasreq *ifra,
|
|||
* XXX It may be of use, if we can administratively
|
||||
* disable DAD.
|
||||
*/
|
||||
if (hostIsNew && in6if_do_dad(ifp) &&
|
||||
if (hostIsNew && if_do_dad(ifp) &&
|
||||
((ifra->ifra_flags & IN6_IFF_NODAD) == 0) &&
|
||||
(ia->ia6_flags & IN6_IFF_TENTATIVE))
|
||||
{
|
||||
|
@ -2005,7 +2005,7 @@ in6_if_link_up(struct ifnet *ifp)
|
|||
/* If detached then mark as tentative */
|
||||
if (ia->ia6_flags & IN6_IFF_DETACHED) {
|
||||
ia->ia6_flags &= ~IN6_IFF_DETACHED;
|
||||
if (in6if_do_dad(ifp)) {
|
||||
if (if_do_dad(ifp)) {
|
||||
ia->ia6_flags |= IN6_IFF_TENTATIVE;
|
||||
nd6log((LOG_ERR, "in6_if_up: "
|
||||
"%s marked tentative\n",
|
||||
|
@ -2097,39 +2097,6 @@ in6_if_down(struct ifnet *ifp)
|
|||
in6_if_link_down(ifp);
|
||||
}
|
||||
|
||||
int
|
||||
in6if_do_dad(struct ifnet *ifp)
|
||||
{
|
||||
if ((ifp->if_flags & IFF_LOOPBACK) != 0)
|
||||
return 0;
|
||||
|
||||
switch (ifp->if_type) {
|
||||
case IFT_FAITH:
|
||||
/*
|
||||
* These interfaces do not have the IFF_LOOPBACK flag,
|
||||
* but loop packets back. We do not have to do DAD on such
|
||||
* interfaces. We should even omit it, because loop-backed
|
||||
* NS would confuse the DAD procedure.
|
||||
*/
|
||||
return 0;
|
||||
default:
|
||||
/*
|
||||
* Our DAD routine requires the interface up and running.
|
||||
* However, some interfaces can be up before the RUNNING
|
||||
* status. Additionaly, users may try to assign addresses
|
||||
* before the interface becomes up (or running).
|
||||
* We simply skip DAD in such a case as a work around.
|
||||
* XXX: we should rather mark "tentative" on such addresses,
|
||||
* and do DAD after the interface becomes ready.
|
||||
*/
|
||||
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) !=
|
||||
(IFF_UP|IFF_RUNNING))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate max IPv6 MTU through all the interfaces and store it
|
||||
* to in6_maxmtu.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: in6_var.h,v 1.72 2015/02/26 09:54:46 roy Exp $ */
|
||||
/* $NetBSD: in6_var.h,v 1.73 2015/04/07 23:30:36 roy Exp $ */
|
||||
/* $KAME: in6_var.h,v 1.81 2002/06/08 11:16:51 itojun Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -685,7 +685,6 @@ int in6_control(struct socket *, u_long, void *, struct ifnet *);
|
|||
int in6_update_ifa(struct ifnet *, struct in6_aliasreq *,
|
||||
struct in6_ifaddr *, int);
|
||||
void in6_purgeaddr(struct ifaddr *);
|
||||
int in6if_do_dad(struct ifnet *);
|
||||
void in6_purgeif(struct ifnet *);
|
||||
void in6_savemkludge(struct in6_ifaddr *);
|
||||
void in6_setmaxmtu (void);
|
||||
|
|
Loading…
Reference in New Issue