summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorroy <roy@NetBSD.org>2013-05-21 08:37:27 +0000
committerroy <roy@NetBSD.org>2013-05-21 08:37:27 +0000
commit2cf5bba25ebacbea04bb23a6be240dbd5cf3d2da (patch)
treec469be0d502893df5eaec43fd6cd502d604561d7 /sys
parentbfc5471276134ffbc5bf615a03df9eb96d83dc2a (diff)
For IPv6, emit RTM_NEWADDR once DAD completes and also when address flag
changes. Tentative addresses are not emitted. Version bumped so userland can detect this behaviour change.
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet6/in6.c32
-rw-r--r--sys/netinet6/nd6.c14
-rw-r--r--sys/netinet6/nd6.h3
-rw-r--r--sys/netinet6/nd6_nbr.c48
-rw-r--r--sys/netinet6/nd6_rtr.c8
-rw-r--r--sys/sys/param.h4
6 files changed, 85 insertions, 24 deletions
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 964d131d7a4..ccc1e2be057 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1,4 +1,4 @@
-/* $NetBSD: in6.c,v 1.161 2012/06/23 03:14:03 christos Exp $ */
+/* $NetBSD: in6.c,v 1.162 2013/05/21 08:37:27 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.161 2012/06/23 03:14:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.162 2013/05/21 08:37:27 roy Exp $");
#include "opt_inet.h"
#include "opt_pfil_hooks.h"
@@ -191,13 +191,29 @@ in6_ifloop_request(int cmd, struct ifaddr *ifa)
rt_replace_ifa(nrt, ifa);
/*
- * Report the addition/removal of the address to the routing socket.
+ * Report the addition/removal of the address to the routing socket
+ * unless the address is marked tentative, where it will be reported
+ * once DAD completes.
* XXX: since we called rtinit for a p2p interface with a destination,
* we end up reporting twice in such a case. Should we rather
* omit the second report?
*/
if (nrt) {
- rt_newaddrmsg(cmd, ifa, e, nrt);
+ if (cmd != RTM_ADD ||
+ !(((struct in6_ifaddr *)ifa)->ia6_flags &IN6_IFF_TENTATIVE))
+ {
+#if 0
+ struct in6_ifaddr *ia;
+
+ ia = (struct in6_ifaddr *)ifa;
+ log(LOG_DEBUG,
+ "in6_ifloop_request: announced %s (%s %d)\n",
+ ip6_sprintf(&ia->ia_addr.sin6_addr),
+ cmd == RTM_ADD ? "RTM_ADD" : "RTM_DELETE",
+ ia->ia6_flags);
+#endif
+ rt_newaddrmsg(cmd, ifa, e, nrt);
+ }
if (cmd == RTM_DELETE) {
if (nrt->rt_refcnt <= 0) {
/* XXX: we should free the entry ourselves. */
@@ -1058,10 +1074,6 @@ in6_update_ifa1(struct ifnet *ifp, struct in6_aliasreq *ifra,
} else
ia->ia6_lifetime.ia6t_preferred = 0;
- /* reset the interface and routing table appropriately. */
- if ((error = in6_ifinit(ifp, ia, &ifra->ifra_addr, hostIsNew)) != 0)
- goto unlink;
-
/*
* configure address flags.
*/
@@ -1084,6 +1096,10 @@ in6_update_ifa1(struct ifnet *ifp, struct in6_aliasreq *ifra,
if (hostIsNew && in6if_do_dad(ifp))
ia->ia6_flags |= IN6_IFF_TENTATIVE;
+ /* reset the interface and routing table appropriately. */
+ if ((error = in6_ifinit(ifp, ia, &ifra->ifra_addr, hostIsNew)) != 0)
+ goto unlink;
+
/*
* We are done if we have simply modified an existing address.
*/
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 85bad604b58..3b103fcb1a5 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6.c,v 1.144 2013/01/24 14:23:09 joerg Exp $ */
+/* $NetBSD: nd6.c,v 1.145 2013/05/21 08:37:27 roy Exp $ */
/* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.144 2013/01/24 14:23:09 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.145 2013/05/21 08:37:27 roy Exp $");
#include "opt_ipsec.h"
@@ -582,7 +582,10 @@ nd6_timer(void *ignored_arg)
} else if (IFA6_IS_DEPRECATED(ia6)) {
int oldflags = ia6->ia6_flags;
- ia6->ia6_flags |= IN6_IFF_DEPRECATED;
+ if ((oldflags & IN6_IFF_DEPRECATED) == 0) {
+ ia6->ia6_flags |= IN6_IFF_DEPRECATED;
+ nd6_newaddrmsg((struct ifaddr *)ia6);
+ }
/*
* If a temporary address has just become deprecated,
@@ -613,7 +616,10 @@ nd6_timer(void *ignored_arg)
* A new RA might have made a deprecated address
* preferred.
*/
- ia6->ia6_flags &= ~IN6_IFF_DEPRECATED;
+ if (ia6->ia6_flags & IN6_IFF_DEPRECATED) {
+ ia6->ia6_flags &= ~IN6_IFF_DEPRECATED;
+ nd6_newaddrmsg((struct ifaddr *)ia6);
+ }
}
}
diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h
index e29c32def38..0bae321239e 100644
--- a/sys/netinet6/nd6.h
+++ b/sys/netinet6/nd6.h
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6.h,v 1.57 2012/06/23 03:14:04 christos Exp $ */
+/* $NetBSD: nd6.h,v 1.58 2013/05/21 08:37:27 roy Exp $ */
/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */
/*
@@ -435,6 +435,7 @@ void nd6_ns_input(struct mbuf *, int, int);
void nd6_ns_output(struct ifnet *, const struct in6_addr *,
const struct in6_addr *, struct llinfo_nd6 *, int);
const void *nd6_ifptomac(const struct ifnet *);
+void nd6_newaddrmsg(struct ifaddr *);
void nd6_dad_start(struct ifaddr *, int);
void nd6_dad_stop(struct ifaddr *);
void nd6_dad_duplicated(struct ifaddr *);
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index ef4866635df..698b77a433d 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6_nbr.c,v 1.96 2012/03/22 20:34:41 drochner Exp $ */
+/* $NetBSD: nd6_nbr.c,v 1.97 2013/05/21 08:37:27 roy Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.96 2012/03/22 20:34:41 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.97 2013/05/21 08:37:27 roy Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -1056,6 +1056,39 @@ nd6_dad_stoptimer(struct dadq *dp)
}
/*
+ * Routine to report address flag changes to the routing socket
+ */
+void
+nd6_newaddrmsg(struct ifaddr *ifa)
+{
+ struct sockaddr_in6 all1_sa;
+ struct rtentry *nrt = NULL;
+ int e;
+
+ sockaddr_in6_init(&all1_sa, &in6mask128, 0, 0, 0);
+
+ e = rtrequest(RTM_GET, ifa->ifa_addr, ifa->ifa_addr,
+ (struct sockaddr *)&all1_sa, RTF_UP|RTF_HOST|RTF_LLINFO, &nrt);
+ if (e != 0) {
+ log(LOG_ERR, "nd6_newaddrmsg: "
+ "RTM_GET operation failed for %s (errno=%d)\n",
+ ip6_sprintf(&((struct in6_ifaddr *)ifa)->ia_addr.sin6_addr),
+ e);
+ }
+
+ if (nrt) {
+ rt_newaddrmsg(RTM_ADD, ifa, e, nrt);
+//#if 0
+ log(LOG_DEBUG, "nd6_newaddrmsg: announced %s\n",
+ ip6_sprintf(&((struct in6_ifaddr *)ifa)->ia_addr.sin6_addr)
+ );
+//#endif
+ nrt->rt_refcnt--;
+ }
+}
+
+
+/*
* Start Duplicate Address Detection (DAD) for specified interface address.
*
* xtick: minimum delay ticks for IFF_UP event
@@ -1085,12 +1118,9 @@ nd6_dad_start(struct ifaddr *ifa, int xtick)
ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
return;
}
- if (ia->ia6_flags & IN6_IFF_ANYCAST) {
- ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
- return;
- }
- if (!ip6_dad_count) {
+ if (ia->ia6_flags & IN6_IFF_ANYCAST || !ip6_dad_count) {
ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
+ nd6_newaddrmsg(ifa);
return;
}
if (ifa->ifa_ifp == NULL)
@@ -1246,6 +1276,7 @@ nd6_dad_timer(struct ifaddr *ifa)
* No duplicate address found.
*/
ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
+ nd6_newaddrmsg(ifa);
nd6log((LOG_DEBUG,
"%s: DAD complete for %s - no duplicates found\n",
@@ -1294,6 +1325,9 @@ nd6_dad_duplicated(struct ifaddr *ifa)
log(LOG_ERR, "%s: manual intervention required\n",
if_name(ifp));
+ /* Inform the routing socket that DAD has completed */
+ nd6_newaddrmsg(ifa);
+
/*
* If the address is a link-local address formed from an interface
* identifier based on the hardware address which is supposed to be
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index 2a32108b436..88a62c81fb9 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6_rtr.c,v 1.86 2013/02/18 16:45:50 christos Exp $ */
+/* $NetBSD: nd6_rtr.c,v 1.87 2013/05/21 08:37:27 roy Exp $ */
/* $KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.86 2013/02/18 16:45:50 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.87 2013/05/21 08:37:27 roy Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1580,10 +1580,14 @@ pfxlist_onlink_check(void)
ifa->ia6_flags |= IN6_IFF_TENTATIVE;
nd6_dad_start((struct ifaddr *)ifa,
0);
+ /* We will notify the routing socket
+ * of the DAD result, so no need to
+ * here */
}
} else {
if ((ifa->ia6_flags & IN6_IFF_DETACHED) == 0) {
ifa->ia6_flags |= IN6_IFF_DETACHED;
+ nd6_newaddrmsg((struct ifaddr *)ifa);
}
}
}
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 912b8d3386a..c5d23dc12d9 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.428 2013/03/29 01:09:45 christos Exp $ */
+/* $NetBSD: param.h,v 1.429 2013/05/21 08:37:27 roy Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -63,7 +63,7 @@
* 2.99.9 (299000900)
*/
-#define __NetBSD_Version__ 699001900 /* NetBSD 6.99.19 */
+#define __NetBSD_Version__ 699002000 /* NetBSD 6.99.20 */
#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
(m) * 1000000) + (p) * 100) <= __NetBSD_Version__)