Module Name:    src
Committed By:   roy
Date:           Tue Dec 16 11:42:27 UTC 2014

Modified Files:
        src/sys/netinet6: nd6.c nd6.h nd6_nbr.c nd6_rtr.c

Log Message:
Report route additions/changes/deletions for cached neighbours to userland.


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/netinet6/nd6.c
cvs rdiff -u -r1.60 -r1.61 src/sys/netinet6/nd6.h
cvs rdiff -u -r1.102 -r1.103 src/sys/netinet6/nd6_nbr.c
cvs rdiff -u -r1.94 -r1.95 src/sys/netinet6/nd6_rtr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet6/nd6.c
diff -u src/sys/netinet6/nd6.c:1.155 src/sys/netinet6/nd6.c:1.156
--- src/sys/netinet6/nd6.c:1.155	Wed Dec  3 01:32:11 2014
+++ src/sys/netinet6/nd6.c	Tue Dec 16 11:42:27 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.c,v 1.155 2014/12/03 01:32:11 christos Exp $	*/
+/*	$NetBSD: nd6.c,v 1.156 2014/12/16 11:42: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.155 2014/12/03 01:32:11 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.156 2014/12/16 11:42:27 roy Exp $");
 
 #include "bridge.h"
 #include "carp.h"
@@ -1037,6 +1037,7 @@ nd6_free(struct rtentry *rt, int gc)
 	struct llinfo_nd6 *ln = (struct llinfo_nd6 *)rt->rt_llinfo, *next;
 	struct in6_addr in6 = satocsin6(rt_getkey(rt))->sin6_addr;
 	struct nd_defrouter *dr;
+	struct rtentry *oldrt;
 
 	/*
 	 * we used to have pfctlinput(PRC_HOSTDEAD) here.
@@ -1129,7 +1130,15 @@ nd6_free(struct rtentry *rt, int gc)
 	 * caches, and disable the route entry not to be used in already
 	 * cached routes.
 	 */
-	rtrequest(RTM_DELETE, rt_getkey(rt), NULL, rt_mask(rt), 0, NULL);
+	oldrt = NULL;
+	rtrequest(RTM_DELETE, rt_getkey(rt), NULL, rt_mask(rt), 0, &oldrt);
+	if (oldrt) {
+		nd6_rtmsg(RTM_DELETE, oldrt); /* tell user process */
+		if (oldrt->rt_refcnt <= 0) {
+			oldrt->rt_refcnt++;
+			rtfree(oldrt);
+		}
+	}
 
 	return next;
 }
@@ -2059,6 +2068,9 @@ fail:
 		break;
 	}
 
+	if (do_update)
+		nd6_rtmsg(RTM_CHANGE, rt);  /* tell user process */
+
 	/*
 	 * When the link-layer address of a router changes, select the
 	 * best router again.  In particular, when the neighbor entry is newly

Index: src/sys/netinet6/nd6.h
diff -u src/sys/netinet6/nd6.h:1.60 src/sys/netinet6/nd6.h:1.61
--- src/sys/netinet6/nd6.h:1.60	Fri Sep  5 06:08:15 2014
+++ src/sys/netinet6/nd6.h	Tue Dec 16 11:42:27 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.h,v 1.60 2014/09/05 06:08:15 matt Exp $	*/
+/*	$NetBSD: nd6.h,v 1.61 2014/12/16 11:42:27 roy Exp $	*/
 /*	$KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $	*/
 
 /*
@@ -413,6 +413,7 @@ void nd6_option_init(void *, int, union 
 struct nd_opt_hdr *nd6_option(union nd_opts *);
 int nd6_options(union nd_opts *);
 struct	rtentry *nd6_lookup(const struct in6_addr *, int, struct ifnet *);
+void nd6_rtmsg(int, struct rtentry *);
 void nd6_setmtu(struct ifnet *);
 void nd6_llinfo_settimer(struct llinfo_nd6 *, long);
 void nd6_timer(void *);

Index: src/sys/netinet6/nd6_nbr.c
diff -u src/sys/netinet6/nd6_nbr.c:1.102 src/sys/netinet6/nd6_nbr.c:1.103
--- src/sys/netinet6/nd6_nbr.c:1.102	Sun Oct 12 20:05:50 2014
+++ src/sys/netinet6/nd6_nbr.c	Tue Dec 16 11:42:27 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6_nbr.c,v 1.102 2014/10/12 20:05:50 roy Exp $	*/
+/*	$NetBSD: nd6_nbr.c,v 1.103 2014/12/16 11:42: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.102 2014/10/12 20:05:50 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.103 2014/12/16 11:42:27 roy Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -567,6 +567,7 @@ nd6_na_input(struct mbuf *m, int off, in
 	struct sockaddr_dl *sdl;
 	union nd_opts ndopts;
 	struct sockaddr_in6 ssin6;
+	int rt_announce;
 
 	if (ip6->ip6_hlim != 255) {
 		nd6log((LOG_ERR,
@@ -669,6 +670,7 @@ nd6_na_input(struct mbuf *m, int off, in
 	   ((sdl = satosdl(rt->rt_gateway)) == NULL))
 		goto freeit;
 
+	rt_announce = 0;
 	if (ln->ln_state == ND6_LLINFO_INCOMPLETE) {
 		/*
 		 * If the link-layer has address, and no lladdr option came,
@@ -682,6 +684,7 @@ nd6_na_input(struct mbuf *m, int off, in
 		 */
 		(void)sockaddr_dl_setaddr(sdl, sdl->sdl_len, lladdr,
 		    ifp->if_addrlen);
+		rt_announce = 1;
 		if (is_solicited) {
 			ln->ln_state = ND6_LLINFO_REACHABLE;
 			ln->ln_byhint = 0;
@@ -712,11 +715,11 @@ nd6_na_input(struct mbuf *m, int off, in
 		else {
 			if (sdl->sdl_alen) {
 				if (memcmp(lladdr, CLLADDR(sdl), ifp->if_addrlen))
-					llchange = 1;
+					llchange = rt_announce = 1;
 				else
 					llchange = 0;
 			} else
-				llchange = 1;
+				llchange = rt_announce = 1;
 		}
 
 		/*
@@ -819,6 +822,8 @@ nd6_na_input(struct mbuf *m, int off, in
 	rt->rt_flags &= ~RTF_REJECT;
 	ln->ln_asked = 0;
 	nd6_llinfo_release_pkts(ln, ifp, rt);
+	if (rt_announce) /* tell user process about any new lladdr */
+		nd6_rtmsg(RTM_CHANGE, rt);
 
  freeit:
 	m_freem(m);

Index: src/sys/netinet6/nd6_rtr.c
diff -u src/sys/netinet6/nd6_rtr.c:1.94 src/sys/netinet6/nd6_rtr.c:1.95
--- src/sys/netinet6/nd6_rtr.c:1.94	Fri Sep  5 06:08:15 2014
+++ src/sys/netinet6/nd6_rtr.c	Tue Dec 16 11:42:27 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6_rtr.c,v 1.94 2014/09/05 06:08:15 matt Exp $	*/
+/*	$NetBSD: nd6_rtr.c,v 1.95 2014/12/16 11:42: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.94 2014/09/05 06:08:15 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.95 2014/12/16 11:42:27 roy Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -76,7 +76,6 @@ static void pfxrtr_del(struct nd_pfxrout
 static struct nd_pfxrouter *find_pfxlist_reachable_router
 	(struct nd_prefix *);
 static void defrouter_delreq(struct nd_defrouter *);
-static void nd6_rtmsg(int, struct rtentry *);
 
 static int in6_init_prefix_ltimes(struct nd_prefix *);
 static void in6_init_address_ltimes(struct nd_prefix *,
@@ -416,7 +415,7 @@ nd6_ra_input(struct mbuf *m, int off, in
  */
 
 /* tell the change to user processes watching the routing socket. */
-static void
+void
 nd6_rtmsg(int cmd, struct rtentry *rt)
 {
 	struct rt_addrinfo info;

Reply via email to