Module Name:    src
Committed By:   ozaki-r
Date:           Sun Dec 11 07:37:53 UTC 2016

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

Log Message:
Move default interface things from nd6_rtr.c to nd6.c


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/sys/netinet6/nd6.c
cvs rdiff -u -r1.74 -r1.75 src/sys/netinet6/nd6.h
cvs rdiff -u -r1.121 -r1.122 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.211 src/sys/netinet6/nd6.c:1.212
--- src/sys/netinet6/nd6.c:1.211	Mon Nov 14 02:34:19 2016
+++ src/sys/netinet6/nd6.c	Sun Dec 11 07:37:53 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.c,v 1.211 2016/11/14 02:34:19 ozaki-r Exp $	*/
+/*	$NetBSD: nd6.c,v 1.212 2016/12/11 07:37:53 ozaki-r 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.211 2016/11/14 02:34:19 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.212 2016/12/11 07:37:53 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -125,6 +125,11 @@ static struct work	nd6_timer_wk;
 static int fill_drlist(void *, size_t *, size_t);
 static int fill_prlist(void *, size_t *, size_t);
 
+static struct ifnet *nd6_defifp;
+static int nd6_defifindex;
+
+static int nd6_setdefaultiface(int);
+
 MALLOC_DEFINE(M_IP6NDP, "NDP", "IPv6 Neighbour Discovery");
 
 void
@@ -2780,3 +2785,32 @@ fill_prlist(void *oldp, size_t *oldlenp,
 
 	return error;
 }
+
+static int
+nd6_setdefaultiface(int ifindex)
+{
+	ifnet_t *ifp;
+	int error = 0;
+	int s;
+
+	s = pserialize_read_enter();
+	ifp = if_byindex(ifindex);
+	if (ifp == NULL) {
+		pserialize_read_exit(s);
+		return EINVAL;
+	}
+	if (nd6_defifindex != ifindex) {
+		nd6_defifindex = ifindex;
+		nd6_defifp = nd6_defifindex > 0 ? ifp : NULL;
+
+		/*
+		 * Our current implementation assumes one-to-one maping between
+		 * interfaces and links, so it would be natural to use the
+		 * default interface as the default link.
+		 */
+		scope6_setdefault(nd6_defifp);
+	}
+	pserialize_read_exit(s);
+
+	return (error);
+}

Index: src/sys/netinet6/nd6.h
diff -u src/sys/netinet6/nd6.h:1.74 src/sys/netinet6/nd6.h:1.75
--- src/sys/netinet6/nd6.h:1.74	Sun Dec 11 07:36:55 2016
+++ src/sys/netinet6/nd6.h	Sun Dec 11 07:37:53 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.h,v 1.74 2016/12/11 07:36:55 ozaki-r Exp $	*/
+/*	$NetBSD: nd6.h,v 1.75 2016/12/11 07:37:53 ozaki-r Exp $	*/
 /*	$KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $	*/
 
 /*
@@ -354,7 +354,6 @@ extern int nd6_debug;
 	do { if (nd6_debug) log(level, "%s: " fmt, __func__, ##args);} while (0)
 
 /* nd6_rtr.c */
-extern int nd6_defifindex;
 extern int ip6_desync_factor;	/* seconds */
 extern u_int32_t ip6_temp_preferred_lifetime; /* seconds */
 extern u_int32_t ip6_temp_valid_lifetime; /* seconds */
@@ -441,7 +440,6 @@ void prelist_remove(struct nd_prefix *);
 void pfxlist_onlink_check(void);
 struct nd_defrouter *defrouter_lookup(const struct in6_addr *, struct ifnet *);
 void rt6_flush(struct in6_addr *, struct ifnet *);
-int nd6_setdefaultiface(int);
 int in6_tmpifadd(const struct in6_ifaddr *, int, int);
 bool nd6_accepts_rtadv(const struct nd_ifinfo *);
 

Index: src/sys/netinet6/nd6_rtr.c
diff -u src/sys/netinet6/nd6_rtr.c:1.121 src/sys/netinet6/nd6_rtr.c:1.122
--- src/sys/netinet6/nd6_rtr.c:1.121	Sun Dec 11 07:36:55 2016
+++ src/sys/netinet6/nd6_rtr.c	Sun Dec 11 07:37:53 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6_rtr.c,v 1.121 2016/12/11 07:36:55 ozaki-r Exp $	*/
+/*	$NetBSD: nd6_rtr.c,v 1.122 2016/12/11 07:37:53 ozaki-r 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.121 2016/12/11 07:36:55 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.122 2016/12/11 07:37:53 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -92,9 +92,6 @@ static struct nd_prefix *nd6_prefix_look
 
 extern int nd6_recalc_reachtm_interval;
 
-static struct ifnet *nd6_defifp;
-int nd6_defifindex;
-
 int ip6_use_tempaddr = 0;
 
 int ip6_desync_factor;
@@ -2203,32 +2200,3 @@ rt6_deleteroute_matcher(struct rtentry *
 
 	return 1;
 }
-
-int
-nd6_setdefaultiface(int ifindex)
-{
-	ifnet_t *ifp;
-	int error = 0;
-	int s;
-
-	s = pserialize_read_enter();
-	ifp = if_byindex(ifindex);
-	if (ifp == NULL) {
-		pserialize_read_exit(s);
-		return EINVAL;
-	}
-	if (nd6_defifindex != ifindex) {
-		nd6_defifindex = ifindex;
-		nd6_defifp = nd6_defifindex > 0 ? ifp : NULL;
-
-		/*
-		 * Our current implementation assumes one-to-one maping between
-		 * interfaces and links, so it would be natural to use the
-		 * default interface as the default link.
-		 */
-		scope6_setdefault(nd6_defifp);
-	}
-	pserialize_read_exit(s);
-
-	return (error);
-}

Reply via email to