diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-06-13 10:34:41 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-06-13 10:34:41 +0000 |
commit | 37360075efddca88f7878c867e5d5d40d43d14f1 (patch) | |
tree | 587f1ad7243dad8efd3e4f5b68259c36d56155df /sys/netinet6 | |
parent | fb652f1341d7d273fc8db5919c71dbff4b2b0276 (diff) |
Move the ioctl(2) logic of in{,6}_control() into two new functions
in{,6}_ioctl() that do not deal with sockets.
This will allow to automagically configure interface addresses in
the kernel without too many layer violations.
Required by upcoming umb(4).
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/in6.c | 35 | ||||
-rw-r--r-- | sys/netinet6/in6_var.h | 3 |
2 files changed, 24 insertions, 14 deletions
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index b3bff8a09a7..c775786b6f6 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.c,v 1.186 2016/03/03 12:57:15 jca Exp $ */ +/* $OpenBSD: in6.c,v 1.187 2016/06/13 10:34:40 mpi Exp $ */ /* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */ /* @@ -118,7 +118,8 @@ const struct in6_addr in6mask64 = IN6MASK64; const struct in6_addr in6mask96 = IN6MASK96; const struct in6_addr in6mask128 = IN6MASK128; -int in6_lifaddr_ioctl(struct socket *, u_long, caddr_t, struct ifnet *); +int in6_lifaddr_ioctl(u_long, caddr_t, struct ifnet *, int); +int in6_ioctl(u_long, caddr_t, struct ifnet *, int); int in6_ifinit(struct ifnet *, struct in6_ifaddr *, int); void in6_unlink_ifa(struct in6_ifaddr *, struct ifnet *); @@ -165,11 +166,7 @@ in6_mask2len(struct in6_addr *mask, u_char *lim0) int in6_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp) { - struct in6_ifreq *ifr = (struct in6_ifreq *)data; - struct in6_ifaddr *ia6 = NULL; - struct in6_aliasreq *ifra = (struct in6_aliasreq *)data; - struct sockaddr_in6 *sa6; - int s, privileged; + int privileged; privileged = 0; if ((so->so_state & SS_PRIV) != 0) @@ -183,6 +180,18 @@ in6_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp) } #endif + return (in6_ioctl(cmd, data, ifp, privileged)); +} + +int +in6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, int privileged) +{ + struct in6_ifreq *ifr = (struct in6_ifreq *)data; + struct in6_ifaddr *ia6 = NULL; + struct in6_aliasreq *ifra = (struct in6_aliasreq *)data; + struct sockaddr_in6 *sa6; + int s; + if (ifp == NULL) return (EOPNOTSUPP); @@ -206,7 +215,7 @@ in6_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp) return (EPERM); /* FALLTHROUGH */ case SIOCGLIFADDR: - return in6_lifaddr_ioctl(so, cmd, data, ifp); + return in6_lifaddr_ioctl(cmd, data, ifp, privileged); } /* @@ -939,8 +948,7 @@ in6_unlink_ifa(struct in6_ifaddr *ia6, struct ifnet *ifp) * address encoding scheme. (see figure on page 8) */ int -in6_lifaddr_ioctl(struct socket *so, u_long cmd, caddr_t data, - struct ifnet *ifp) +in6_lifaddr_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, int privileged) { struct if_laddrreq *iflr = (struct if_laddrreq *)data; struct ifaddr *ifa; @@ -1047,7 +1055,8 @@ in6_lifaddr_ioctl(struct socket *so, u_long cmd, caddr_t data, in6_prefixlen2mask(&ifra.ifra_prefixmask.sin6_addr, prefixlen); ifra.ifra_flags = iflr->flags & ~IFLR_PREFIX; - return in6_control(so, SIOCAIFADDR_IN6, (caddr_t)&ifra, ifp); + return in6_ioctl(SIOCAIFADDR_IN6, (caddr_t)&ifra, ifp, + privileged); } case SIOCGLIFADDR: case SIOCDLIFADDR: @@ -1142,8 +1151,8 @@ in6_lifaddr_ioctl(struct socket *so, u_long cmd, caddr_t data, ia6->ia_prefixmask.sin6_len); ifra.ifra_flags = ia6->ia6_flags; - return in6_control(so, SIOCDIFADDR_IN6, (caddr_t)&ifra, - ifp); + return in6_ioctl(SIOCDIFADDR_IN6, (caddr_t)&ifra, ifp, + privileged); } } } diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h index 3447750cb55..9d9383d6007 100644 --- a/sys/netinet6/in6_var.h +++ b/sys/netinet6/in6_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_var.h,v 1.62 2016/03/03 12:57:15 jca Exp $ */ +/* $OpenBSD: in6_var.h,v 1.63 2016/06/13 10:34:40 mpi Exp $ */ /* $KAME: in6_var.h,v 1.55 2001/02/16 12:49:45 itojun Exp $ */ /* @@ -394,6 +394,7 @@ int in6_hasmulti(struct in6_addr *, struct ifnet *); struct in6_multi_mship *in6_joingroup(struct ifnet *, struct in6_addr *, int *); int in6_leavegroup(struct in6_multi_mship *); int in6_control(struct socket *, u_long, caddr_t, struct ifnet *); +int in6_ioctl(u_long, caddr_t, struct ifnet *, int); int in6_update_ifa(struct ifnet *, struct in6_aliasreq *, struct in6_ifaddr *); void in6_purgeaddr(struct ifaddr *); |