Module Name: src Committed By: roy Date: Tue Apr 7 23:30:36 UTC 2015
Modified Files: src/sys/net: if.c if.h src/sys/netinet6: in6.c in6_var.h Log Message: Move in6if_do_dad() to if_do_dad() as the routine is not INET6 specific and could equally be used by INET. To generate a diff of this commit: cvs rdiff -u -r1.308 -r1.309 src/sys/net/if.c cvs rdiff -u -r1.186 -r1.187 src/sys/net/if.h cvs rdiff -u -r1.185 -r1.186 src/sys/netinet6/in6.c cvs rdiff -u -r1.72 -r1.73 src/sys/netinet6/in6_var.h 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.308 src/sys/net/if.c:1.309 --- src/sys/net/if.c:1.308 Fri Jan 16 10:36:14 2015 +++ src/sys/net/if.c Tue Apr 7 23:30:36 2015 @@ -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" @@ -2317,6 +2317,39 @@ if_addr_init(ifnet_t *ifp, struct ifaddr } 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) { int rc; Index: src/sys/net/if.h diff -u src/sys/net/if.h:1.186 src/sys/net/if.h:1.187 --- src/sys/net/if.h:1.186 Fri Apr 3 08:20:55 2015 +++ src/sys/net/if.h Tue Apr 7 23:30:36 2015 @@ -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_lon 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); Index: src/sys/netinet6/in6.c diff -u src/sys/netinet6/in6.c:1.185 src/sys/netinet6/in6.c:1.186 --- src/sys/netinet6/in6.c:1.185 Thu Feb 26 12:58:36 2015 +++ src/sys/netinet6/in6.c Tue Apr 7 23:30:36 2015 @@ -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, struc 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, struc * 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. Index: src/sys/netinet6/in6_var.h diff -u src/sys/netinet6/in6_var.h:1.72 src/sys/netinet6/in6_var.h:1.73 --- src/sys/netinet6/in6_var.h:1.72 Thu Feb 26 09:54:46 2015 +++ src/sys/netinet6/in6_var.h Tue Apr 7 23:30:36 2015 @@ -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, 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);