summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-11-04 13:11:55 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-11-04 13:11:55 +0000
commit494cc0eb658eb64325d225030aa3a74f62113ce1 (patch)
tree1374417a40f2e89150851834c8776ef9e329306d /sys/net
parentc72eae7ae02d3bb6c61a06e2ded9e55931f10b87 (diff)
Stop calling ifp->if_ioctl() inside in{,6}_ioctl().
Instead return EOPNOTSUPP and call it from ifioctl(). This will help getting per-driver ioctl routines outside of need the NET_LOCK(). While here always return ENXIO when ``ifp'' is NULL. ok visa@, florian@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c42
1 files changed, 17 insertions, 25 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;
}