diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2017-10-12 09:14:17 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2017-10-12 09:14:17 +0000 |
commit | ed871f5e0c4abb0cd4cc968ba206117a33ff83e2 (patch) | |
tree | c15917c2b24af0cff48f39a50f35a21a6b182065 /sys | |
parent | c5c4ce195851796e1d8b4490e7682babbffb7ad5 (diff) |
Move sysctl_mq() where it can safely mess with mbuf queue internals.
ok visa@, bluhm@, deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/uipc_mbuf.c | 34 | ||||
-rw-r--r-- | sys/net/if.c | 35 | ||||
-rw-r--r-- | sys/net/if_var.h | 5 | ||||
-rw-r--r-- | sys/sys/sysctl.h | 5 |
4 files changed, 39 insertions, 40 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 2bc128dbe2e..3265238ac8d 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.249 2017/09/15 18:13:05 bluhm Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.250 2017/10/12 09:14:16 mpi Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -84,6 +84,7 @@ #include <sys/protosw.h> #include <sys/pool.h> #include <sys/percpu.h> +#include <sys/sysctl.h> #include <sys/socket.h> #include <sys/socketvar.h> @@ -1649,3 +1650,34 @@ mq_purge(struct mbuf_queue *mq) return (ml_purge(&ml)); } + +int +sysctl_mq(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen, struct mbuf_queue *mq) +{ + unsigned int maxlen; + int error; + + /* All sysctl names at this level are terminal. */ + if (namelen != 1) + return (ENOTDIR); + + switch (name[0]) { + case IFQCTL_LEN: + return (sysctl_rdint(oldp, oldlenp, newp, mq_len(mq))); + case IFQCTL_MAXLEN: + maxlen = mq->mq_maxlen; + error = sysctl_int(oldp, oldlenp, newp, newlen, &maxlen); + if (!error && maxlen != mq->mq_maxlen) { + mtx_enter(&mq->mq_mtx); + mq->mq_maxlen = maxlen; + mtx_leave(&mq->mq_mtx); + } + return (error); + case IFQCTL_DROPS: + return (sysctl_rdint(oldp, oldlenp, newp, mq_drops(mq))); + default: + return (EOPNOTSUPP); + } + /* NOTREACHED */ +} diff --git a/sys/net/if.c b/sys/net/if.c index da3d6dbb97f..4c675a5368b 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.515 2017/10/12 09:10:52 mpi Exp $ */ +/* $OpenBSD: if.c,v 1.516 2017/10/12 09:14:16 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -82,7 +82,6 @@ #include <sys/kernel.h> #include <sys/ioctl.h> #include <sys/domain.h> -#include <sys/sysctl.h> #include <sys/task.h> #include <sys/atomic.h> #include <sys/proc.h> @@ -2656,38 +2655,6 @@ ifpromisc(struct ifnet *ifp, int pswitch) return ((*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr)); } -/* XXX move to kern/uipc_mbuf.c */ -int -sysctl_mq(int *name, u_int namelen, void *oldp, size_t *oldlenp, - void *newp, size_t newlen, struct mbuf_queue *mq) -{ - unsigned int maxlen; - int error; - - /* All sysctl names at this level are terminal. */ - if (namelen != 1) - return (ENOTDIR); - - switch (name[0]) { - case IFQCTL_LEN: - return (sysctl_rdint(oldp, oldlenp, newp, mq_len(mq))); - case IFQCTL_MAXLEN: - maxlen = mq->mq_maxlen; - error = sysctl_int(oldp, oldlenp, newp, newlen, &maxlen); - if (!error && maxlen != mq->mq_maxlen) { - mtx_enter(&mq->mq_mtx); - mq->mq_maxlen = maxlen; - mtx_leave(&mq->mq_mtx); - } - return (error); - case IFQCTL_DROPS: - return (sysctl_rdint(oldp, oldlenp, newp, mq_drops(mq))); - default: - return (EOPNOTSUPP); - } - /* NOTREACHED */ -} - void ifa_add(struct ifnet *ifp, struct ifaddr *ifa) { diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 14e118bcbef..85c4836255f 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_var.h,v 1.81 2017/05/08 08:46:39 rzalamena Exp $ */ +/* $OpenBSD: if_var.h,v 1.82 2017/10/12 09:14:16 mpi Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -324,9 +324,6 @@ int if_clone_destroy(const char *); struct if_clone * if_clone_lookup(const char *, int *); -int sysctl_mq(int *, u_int, void *, size_t *, void *, size_t, - struct mbuf_queue *); - void ifa_add(struct ifnet *, struct ifaddr *); void ifa_del(struct ifnet *, struct ifaddr *); void ifa_update_broadaddr(struct ifnet *, struct ifaddr *, diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index ba0a03e416f..300a59db935 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.174 2017/06/14 03:00:40 dlg Exp $ */ +/* $OpenBSD: sysctl.h,v 1.175 2017/10/12 09:14:16 mpi Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -936,6 +936,9 @@ int sysctl_rdstruct(void *, size_t *, void *, const void *, size_t); int sysctl_struct(void *, size_t *, void *, size_t, void *, size_t); int sysctl_file(int *, u_int, char *, size_t *, struct proc *); int sysctl_doproc(int *, u_int, char *, size_t *); +struct mbuf_queue; +int sysctl_mq(int *, u_int, void *, size_t *, void *, size_t, + struct mbuf_queue *); struct rtentry; struct walkarg; int sysctl_dumpentry(struct rtentry *, void *, unsigned int); |