diff options
-rw-r--r-- | sys/net/if.c | 42 | ||||
-rw-r--r-- | sys/netinet/in.c | 7 | ||||
-rw-r--r-- | sys/netinet6/in6.c | 13 |
3 files changed, 26 insertions, 36 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 35e16b372be..48175e23dac 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.521 2017/10/31 22:05:12 sashan Exp $ */ +/* $OpenBSD: if.c,v 1.522 2017/11/04 13:11:54 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1985,30 +1985,6 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) rtm_ifchg(ifp); break; - case SIOCDIFPHYADDR: - case SIOCSLIFPHYADDR: - case SIOCSLIFPHYRTABLE: - case SIOCSLIFPHYTTL: - case SIOCADDMULTI: - case SIOCDELMULTI: - case SIOCSIFMEDIA: - case SIOCSVNETID: - case SIOCSIFPAIR: - case SIOCSIFPARENT: - case SIOCDIFPARENT: - if ((error = suser(p, 0)) != 0) - break; - /* FALLTHROUGH */ - case SIOCGLIFPHYADDR: - case SIOCGLIFPHYRTABLE: - case SIOCGLIFPHYTTL: - case SIOCGIFMEDIA: - case SIOCGVNETID: - case SIOCGIFPAIR: - case SIOCGIFPARENT: - error = (*ifp->if_ioctl)(ifp, cmd, data); - break; - case SIOCGIFDESCR: strlcpy(ifdescrbuf, ifp->if_description, IFDESCRSIZE); error = copyoutstr(ifdescrbuf, ifr->ifr_data, IFDESCRSIZE, @@ -2138,10 +2114,26 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) ifp->if_llprio = ifr->ifr_llprio; break; + case SIOCDIFPHYADDR: + case SIOCSLIFPHYADDR: + case SIOCSLIFPHYRTABLE: + case SIOCSLIFPHYTTL: + case SIOCADDMULTI: + case SIOCDELMULTI: + case SIOCSIFMEDIA: + case SIOCSVNETID: + case SIOCSIFPAIR: + case SIOCSIFPARENT: + case SIOCDIFPARENT: + if ((error = suser(p, 0)) != 0) + break; + /* FALLTHROUGH */ default: error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, (struct mbuf *) cmd, (struct mbuf *) data, (struct mbuf *) ifp, p)); + if (error == EOPNOTSUPP) + error = ((*ifp->if_ioctl)(ifp, cmd, data)); break; } diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 3d52824b16e..5681667a688 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in.c,v 1.143 2017/10/24 09:30:15 mpi Exp $ */ +/* $OpenBSD: in.c,v 1.144 2017/11/04 13:11:54 mpi Exp $ */ /* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */ /* @@ -213,7 +213,7 @@ in_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, int privileged) int newifaddr; if (ifp == NULL) - return (EOPNOTSUPP); + return (ENXIO); NET_ASSERT_LOCKED(); @@ -393,8 +393,7 @@ in_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, int privileged) break; default: - error = ((*ifp->if_ioctl)(ifp, cmd, data)); - return (error); + return (EOPNOTSUPP); } return (0); } diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 236d8abb709..dc101dba578 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.c,v 1.217 2017/11/02 13:17:37 florian Exp $ */ +/* $OpenBSD: in6.c,v 1.218 2017/11/04 13:11:54 mpi Exp $ */ /* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */ /* @@ -204,10 +204,11 @@ in6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, int privileged) struct in6_ifaddr *ia6 = NULL; struct in6_aliasreq *ifra = (struct in6_aliasreq *)data; struct sockaddr_in6 *sa6; - int error; if (ifp == NULL) - return (EOPNOTSUPP); + return (ENXIO); + + NET_ASSERT_LOCKED(); switch (cmd) { case SIOCGIFINFO_IN6: @@ -246,7 +247,7 @@ in6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, int privileged) * Do not pass those ioctl to driver handler since they are not * properly setup. Instead just error out. */ - return (EOPNOTSUPP); + return (EINVAL); default: sa6 = NULL; break; @@ -308,7 +309,6 @@ in6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, int privileged) } switch (cmd) { - case SIOCGIFDSTADDR_IN6: if ((ifp->if_flags & IFF_POINTOPOINT) == 0) return (EINVAL); @@ -451,8 +451,7 @@ in6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, int privileged) break; default: - error = ((*ifp->if_ioctl)(ifp, cmd, data)); - return (error); + return (EOPNOTSUPP); } return (0); |