Hook up the addrctl stuff that's already there.

This commit is contained in:
christos 2015-12-12 23:34:25 +00:00
parent c2c3e4cd11
commit 5b5956f338
4 changed files with 38 additions and 21 deletions

View File

@ -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 cmd, void *data, struct ifnet *ifp)
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 cmd, void *data, struct ifnet *ifp)
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,

View File

@ -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 ifnet *);
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[];

View File

@ -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;

View File

@ -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)
{
@ -1817,15 +1819,6 @@ sysctl_net_inet6_ip6_setup(struct sysctllog **clog)
NULL, 0, &ip6_v6only, 0,
CTL_NET, PF_INET6, IPPROTO_IPV6,
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",
@ -1858,6 +1851,23 @@ sysctl_net_inet6_ip6_setup(struct sysctllog **clog)
CTL_NET, PF_INET6, IPPROTO_IPV6,
IPV6CTL_LOWPORTMAX, CTL_EOL);
#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",