diff options
-rw-r--r-- | sys/kern/uipc_domain.c | 36 | ||||
-rw-r--r-- | sys/net/ifq.c | 40 | ||||
-rw-r--r-- | sys/sys/sysctl.h | 3 |
3 files changed, 76 insertions, 3 deletions
diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index fafd5da50c7..8cb2c77dc60 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_domain.c,v 1.56 2018/06/23 14:38:59 denis Exp $ */ +/* $OpenBSD: uipc_domain.c,v 1.57 2019/07/03 10:19:45 dlg Exp $ */ /* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */ /* @@ -159,6 +159,37 @@ pffindproto(int family, int protocol, int type) return (maybe); } +static int +net_link_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen) +{ + int node; + int error; + + /* + * All sysctl names at this level are nonterminal. + */ + if (namelen < 2) + return (EISDIR); /* overloaded */ + node = name[0]; + + namelen--; + name++; + + switch (node) { + case NET_LINK_IFRXQ: + error = net_ifiq_sysctl(name, namelen, oldp, oldlenp, + newp, newlen); + break; + + default: + error = ENOPROTOOPT; + break; + } + + return (error); +} + int net_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen, struct proc *p) @@ -178,6 +209,9 @@ net_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, if (family == PF_UNSPEC) return (0); + if (family == PF_LINK) + return (net_link_sysctl(name + 1, namelen - 1, oldp, oldlenp, + newp, newlen)); #if NBPFILTER > 0 if (family == PF_BPF) return (bpf_sysctl(name + 1, namelen - 1, oldp, oldlenp, diff --git a/sys/net/ifq.c b/sys/net/ifq.c index bd0764e907f..302277c2e7b 100644 --- a/sys/net/ifq.c +++ b/sys/net/ifq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifq.c,v 1.32 2019/07/01 00:44:29 dlg Exp $ */ +/* $OpenBSD: ifq.c,v 1.33 2019/07/03 10:19:45 dlg Exp $ */ /* * Copyright (c) 2015 David Gwynne <dlg@openbsd.org> @@ -23,6 +23,7 @@ #include <sys/socket.h> #include <sys/mbuf.h> #include <sys/proc.h> +#include <sys/sysctl.h> #include <net/if.h> #include <net/if_var.h> @@ -607,6 +608,43 @@ ifiq_process(void *arg) if_input_process(ifiq->ifiq_if, &ml); } +int +net_ifiq_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen) +{ + int val; + int error; + + if (namelen != 1) + return (EISDIR); + + switch (name[0]) { + case NET_LINK_IFRXQ_PRESSURE_RETURN: + val = ifiq_pressure_return; + error = sysctl_int(oldp, oldlenp, newp, newlen, &val); + if (error != 0) + return (error); + if (val < 1 || val > ifiq_pressure_drop) + return (EINVAL); + ifiq_pressure_return = val; + break; + case NET_LINK_IFRXQ_PRESSURE_DROP: + val = ifiq_pressure_drop; + error = sysctl_int(oldp, oldlenp, newp, newlen, &val); + if (error != 0) + return (error); + if (ifiq_pressure_return > val) + return (EINVAL); + ifiq_pressure_drop = val; + break; + default: + error = EOPNOTSUPP; + break; + } + + return (error); +} + /* * priq implementation */ diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 5607ef1c8ef..836aeeb91f9 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.192 2019/06/25 14:08:57 deraadt Exp $ */ +/* $OpenBSD: sysctl.h,v 1.193 2019/07/03 10:19:45 dlg Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -1031,6 +1031,7 @@ int sysctl_wdog(int *, u_int, void *, size_t *, void *, size_t); extern int (*cpu_cpuspeed)(int *); extern void (*cpu_setperf)(int); +int net_ifiq_sysctl(int *, u_int, void *, size_t *, void *, size_t); int bpf_sysctl(int *, u_int, void *, size_t *, void *, size_t); int pflow_sysctl(int *, u_int, void *, size_t *, void *, size_t); int pipex_sysctl(int *, u_int, void *, size_t *, void *, size_t); |