Module Name:    src
Committed By:   christos
Date:           Sat Dec 12 23:34:25 UTC 2015

Modified Files:
        src/sys/netinet6: in6.c in6.h in6_src.c ip6_input.c

Log Message:
Hook up the addrctl stuff that's already there.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/sys/netinet6/in6.c
cvs rdiff -u -r1.85 -r1.86 src/sys/netinet6/in6.h
cvs rdiff -u -r1.58 -r1.59 src/sys/netinet6/in6_src.c
cvs rdiff -u -r1.152 -r1.153 src/sys/netinet6/ip6_input.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/in6.c
diff -u src/sys/netinet6/in6.c:1.193 src/sys/netinet6/in6.c:1.194
--- src/sys/netinet6/in6.c:1.193	Thu Nov 26 21:54:22 2015
+++ src/sys/netinet6/in6.c	Sat Dec 12 18:34:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6.c,v 1.193 2015/11/27 02:54:22 ozaki-r Exp $	*/
+/*	$NetBSD: in6.c,v 1.194 2015/12/12 23:34:25 christos 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.193 2015/11/27 02:54:22 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.194 2015/12/12 23:34:25 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -273,6 +273,10 @@ in6_control1(struct socket *so, u_long c
 	int error;
 
 	switch (cmd) {
+	case SIOCAADDRCTL_POLICY:
+	case SIOCDADDRCTL_POLICY:
+		/* Privileged. */
+		return in6_src_ioctl(cmd, data);
 	/*
 	 * XXX: Fix me, once we fix SIOCSIFADDR, SIOCIFDSTADDR, etc.
 	 */
@@ -725,6 +729,10 @@ in6_control(struct socket *so, u_long cm
 	case OSIOCAIFADDR_IN6:
 #endif
 	case SIOCAIFADDR_IN6:
+
+	case SIOCAADDRCTL_POLICY:
+	case SIOCDADDRCTL_POLICY:
+
 		if (kauth_authorize_network(curlwp->l_cred,
 		    KAUTH_NETWORK_SOCKET,
 		    KAUTH_REQ_NETWORK_SOCKET_SETPRIV,

Index: src/sys/netinet6/in6.h
diff -u src/sys/netinet6/in6.h:1.85 src/sys/netinet6/in6.h:1.86
--- src/sys/netinet6/in6.h:1.85	Fri Aug  7 04:11:33 2015
+++ src/sys/netinet6/in6.h	Sat Dec 12 18:34:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6.h,v 1.85 2015/08/07 08:11:33 ozaki-r Exp $	*/
+/*	$NetBSD: in6.h,v 1.86 2015/12/12 23:34:25 christos Exp $	*/
 /*	$KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $	*/
 
 /*
@@ -576,7 +576,8 @@ struct ip6_mtuinfo {
 #define IPV6CTL_LOWPORTMAX	31	/* maximum reserved port */
 /* 32 to 34: reserved */
 #define IPV6CTL_AUTO_LINKLOCAL	35	/* automatic link-local addr assign */
-/* 36 to 38: reserved */
+/* 36 to 37: reserved */
+#define IPV6CTL_ADDRCTLPOLICY	38	/* get/set address selection policy */
 #define IPV6CTL_USE_DEFAULTZONE	39	/* use default scope zone */
 /* 40: reserved */
 #define IPV6CTL_MAXFRAGS	41	/* max fragments */
@@ -708,9 +709,6 @@ extern void in6_if_link_down(struct ifne
 extern void in6_if_link_state_change(struct ifnet *, int);
 extern void in6_if_up(struct ifnet *);
 extern void in6_if_down(struct ifnet *);
-#ifndef __FreeBSD__
-extern int in6_src_sysctl(void *, size_t *, void *, size_t);
-#endif
 extern void addrsel_policy_init(void);
 extern	u_char	ip6_protox[];
 

Index: src/sys/netinet6/in6_src.c
diff -u src/sys/netinet6/in6_src.c:1.58 src/sys/netinet6/in6_src.c:1.59
--- src/sys/netinet6/in6_src.c:1.58	Mon Aug 24 18:21:27 2015
+++ src/sys/netinet6/in6_src.c	Sat Dec 12 18:34:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_src.c,v 1.58 2015/08/24 22:21:27 pooka Exp $	*/
+/*	$NetBSD: in6_src.c,v 1.59 2015/12/12 23:34:25 christos Exp $	*/
 /*	$KAME: in6_src.c,v 1.159 2005/10/19 01:40:32 t-momose Exp $	*/
 
 /*
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.58 2015/08/24 22:21:27 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.59 2015/12/12 23:34:25 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -885,8 +885,9 @@ struct sel_walkarg {
 	void *w_limit;
 };
 
+int sysctl_net_inet6_addrctlpolicy(SYSCTLFN_ARGS);
 int
-in6_src_sysctl(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+sysctl_net_inet6_addrctlpolicy(SYSCTLFN_ARGS)
 {
 	int error = 0;
 	int s;

Index: src/sys/netinet6/ip6_input.c
diff -u src/sys/netinet6/ip6_input.c:1.152 src/sys/netinet6/ip6_input.c:1.153
--- src/sys/netinet6/ip6_input.c:1.152	Mon Aug 24 18:21:27 2015
+++ src/sys/netinet6/ip6_input.c	Sat Dec 12 18:34:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_input.c,v 1.152 2015/08/24 22:21:27 pooka Exp $	*/
+/*	$NetBSD: ip6_input.c,v 1.153 2015/12/12 23:34:25 christos Exp $	*/
 /*	$KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.152 2015/08/24 22:21:27 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.153 2015/12/12 23:34:25 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_gateway.h"
@@ -1611,6 +1611,8 @@ const u_char inet6ctlerrmap[PRC_NCMDS] =
 	ENOPROTOOPT
 };
 
+extern int sysctl_net_inet6_addrctlpolicy(SYSCTLFN_ARGS);
+
 static int
 sysctl_net_inet6_ip6_stats(SYSCTLFN_ARGS)
 {
@@ -1819,15 +1821,6 @@ sysctl_net_inet6_ip6_setup(struct sysctl
 		       IPV6CTL_V6ONLY, CTL_EOL);
 	sysctl_createv(clog, 0, NULL, NULL,
 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
-		       CTLTYPE_INT, "auto_linklocal",
-		       SYSCTL_DESCR("Default value of per-interface flag for "
-		                    "adding an IPv6 link-local address to "
-				    "interfaces when attached"),
-		       NULL, 0, &ip6_auto_linklocal, 0,
-		       CTL_NET, PF_INET6, IPPROTO_IPV6,
-		       IPV6CTL_AUTO_LINKLOCAL, CTL_EOL);
-	sysctl_createv(clog, 0, NULL, NULL,
-		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
 		       CTLTYPE_INT, "anonportmin",
 		       SYSCTL_DESCR("Lowest ephemeral port number to assign"),
 		       sysctl_net_inet_ip_ports, 0, &ip6_anonportmin, 0,
@@ -1860,6 +1853,23 @@ sysctl_net_inet6_ip6_setup(struct sysctl
 #endif /* IPNOPRIVPORTS */
 	sysctl_createv(clog, 0, NULL, NULL,
 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+		       CTLTYPE_INT, "auto_linklocal",
+		       SYSCTL_DESCR("Default value of per-interface flag for "
+		                    "adding an IPv6 link-local address to "
+				    "interfaces when attached"),
+		       NULL, 0, &ip6_auto_linklocal, 0,
+		       CTL_NET, PF_INET6, IPPROTO_IPV6,
+		       IPV6CTL_AUTO_LINKLOCAL, CTL_EOL);
+	sysctl_createv(clog, 0, NULL, NULL,
+		       CTLFLAG_PERMANENT|CTLFLAG_READONLY,
+		       CTLTYPE_STRUCT, "addctlpolicy",
+		       SYSCTL_DESCR("Return the current address control"
+			   " policy"),
+		       sysctl_net_inet6_addrctlpolicy, 0, NULL, 0,
+		       CTL_NET, PF_INET6, IPPROTO_IPV6,
+		       IPV6CTL_ADDRCTLPOLICY, CTL_EOL);
+	sysctl_createv(clog, 0, NULL, NULL,
+		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
 		       CTLTYPE_INT, "use_tempaddr",
 		       SYSCTL_DESCR("Use temporary address"),
 		       NULL, 0, &ip6_use_tempaddr, 0,

Reply via email to