diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2005-05-24 04:20:27 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2005-05-24 04:20:27 +0000 |
commit | 3b1f70a1b16fe7fbb4dd2023fca5a05586074d52 (patch) | |
tree | 72f3f02f4df5d3c61cca11a91dd883a2a896d7a4 | |
parent | 361cb4c97740f40c5cd3808004369134731beb44 (diff) |
add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning
-rw-r--r-- | sbin/sysctl/sysctl.c | 21 | ||||
-rw-r--r-- | sys/net/if.c | 25 | ||||
-rw-r--r-- | sys/net/if.h | 20 | ||||
-rw-r--r-- | sys/netinet/in.h | 7 | ||||
-rw-r--r-- | sys/netinet/ip_input.c | 9 |
5 files changed, 73 insertions, 9 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 4341a8efe11..ed86c50f01f 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.121 2005/04/24 21:48:15 deraadt Exp $ */ +/* $OpenBSD: sysctl.c,v 1.122 2005/05/24 04:20:26 markus Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -40,7 +40,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)sysctl.c 8.5 (Berkeley) 5/9/95"; #else -static const char rcsid[] = "$OpenBSD: sysctl.c,v 1.121 2005/04/24 21:48:15 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: sysctl.c,v 1.122 2005/05/24 04:20:26 markus Exp $"; #endif #endif /* not lint */ @@ -60,6 +60,7 @@ static const char rcsid[] = "$OpenBSD: sysctl.c,v 1.121 2005/04/24 21:48:15 dera #include <sys/sensors.h> #include <machine/cpu.h> #include <net/route.h> +#include <net/if.h> #include <netinet/in.h> #include <netinet/in_systm.h> @@ -1373,6 +1374,7 @@ struct ctlname mobileipname[] = MOBILEIPCTL_NAMES; struct ctlname ipcompname[] = IPCOMPCTL_NAMES; struct ctlname carpname[] = CARPCTL_NAMES; struct ctlname bpfname[] = CTL_NET_BPF_NAMES; +struct ctlname ifqname[] = CTL_IFQ_NAMES; struct list inetlist = { inetname, IPPROTO_MAXID }; struct list inetvars[] = { { ipname, IPCTL_MAXID }, /* ip */ @@ -1490,6 +1492,7 @@ struct list inetvars[] = { { carpname, CARPCTL_MAXID }, }; struct list bpflist = { bpfname, NET_BPF_MAXID }; +struct list ifqlist = { ifqname, IFQCTL_MAXID }; struct list kernmalloclist = { kernmallocname, KERN_MALLOC_MAXID }; struct list forkstatlist = { forkstatname, KERN_FORKSTAT_MAXID }; @@ -1839,6 +1842,20 @@ sysctl_inet(char *string, char **bufpp, int mib[], int flags, int *typep) return (-1); mib[3] = indx; *typep = lp->list[indx].ctl_type; + if (*typep == CTLTYPE_NODE) { + int tindx; + + if (*bufpp == 0) { + listall(string, &ifqlist); + return(-1); + } + lp = &ifqlist; + if ((tindx = findname(string, "fifth", bufpp, lp)) == -1) + return (-1); + mib[4] = tindx; + *typep = lp->list[tindx].ctl_type; + return(5); + } return (4); } diff --git a/sys/net/if.c b/sys/net/if.c index 986d622be58..2cee6ff14ca 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.116 2005/05/24 02:49:34 henning Exp $ */ +/* $OpenBSD: if.c,v 1.117 2005/05/24 04:20:25 markus Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -77,6 +77,7 @@ #include <sys/kernel.h> #include <sys/ioctl.h> #include <sys/domain.h> +#include <sys/sysctl.h> #include <net/if.h> #include <net/if_dl.h> @@ -1743,3 +1744,25 @@ ifpromisc(struct ifnet *ifp, int pswitch) ifr.ifr_flags = ifp->if_flags; return ((*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr)); } + +int +sysctl_ifq(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen, struct ifqueue *ifq) +{ + /* 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, ifq->ifq_len)); + case IFQCTL_MAXLEN: + return (sysctl_int(oldp, oldlenp, newp, newlen, + &ifq->ifq_maxlen)); + case IFQCTL_DROPS: + return (sysctl_rdint(oldp, oldlenp, newp, ifq->ifq_drops)); + default: + return (EOPNOTSUPP); + } + /* NOTREACHED */ +} diff --git a/sys/net/if.h b/sys/net/if.h index 20227989e4e..9c8f5018c43 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.69 2005/05/24 02:45:17 reyk Exp $ */ +/* $OpenBSD: if.h,v 1.70 2005/05/24 04:20:25 markus Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -340,6 +340,22 @@ do { \ #define IFQ_MAXLEN 50 #define IFNET_SLOWHZ 1 /* granularity is 1 second */ +/* symbolic names for terminal (per-protocol) CTL_IFQ_ nodes */ +#define IFQCTL_LEN 1 +#define IFQCTL_MAXLEN 2 +#define IFQCTL_DROPS 3 +#define IFQCTL_CONGESTION 4 +#define IFQCTL_MAXID 5 + +/* sysctl for ifq (per-protocol packet input queue variant of ifqueue) */ +#define CTL_IFQ_NAMES { \ + { 0, 0 }, \ + { "len", CTLTYPE_INT }, \ + { "maxlen", CTLTYPE_INT }, \ + { "drops", CTLTYPE_INT }, \ + { "congestion", CTLTYPE_INT }, \ +} + /* * The ifaddr structure contains information about one address * of an interface. They are maintained by the different address families, @@ -690,6 +706,8 @@ int if_clone_create(const char *); int if_clone_destroy(const char *); void if_congestion(struct ifqueue *); +int sysctl_ifq(int *, u_int, void *, size_t *, void *, size_t, + struct ifqueue *); int loioctl(struct ifnet *, u_long, caddr_t); void loopattach(int); diff --git a/sys/netinet/in.h b/sys/netinet/in.h index 366583281c5..a0d14d5878f 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in.h,v 1.64 2005/01/14 14:51:27 mcbride Exp $ */ +/* $OpenBSD: in.h,v 1.65 2005/05/24 04:20:25 markus Exp $ */ /* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */ /* @@ -479,7 +479,8 @@ struct ip_mreq { #define IPCTL_MTUDISC 27 /* allow path MTU discovery */ #define IPCTL_MTUDISCTIMEOUT 28 /* allow path MTU discovery */ #define IPCTL_IPSEC_IPCOMP_ALGORITHM 29 -#define IPCTL_MAXID 30 +#define IPCTL_IFQUEUE 30 +#define IPCTL_MAXID 31 #define IPCTL_NAMES { \ { 0, 0 }, \ @@ -512,6 +513,7 @@ struct ip_mreq { { "mtudisc", CTLTYPE_INT }, \ { "mtudisctimeout", CTLTYPE_INT }, \ { "ipsec-comp-alg", CTLTYPE_STRING }, \ + { "ifq", CTLTYPE_NODE }, \ } #define IPCTL_VARS { \ NULL, \ @@ -544,6 +546,7 @@ struct ip_mreq { NULL, \ NULL, \ NULL, \ + NULL, \ } /* INET6 stuff */ diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 7bb92700d08..3879795e5b1 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.126 2005/04/25 17:55:51 brad Exp $ */ +/* $OpenBSD: ip_input.c,v 1.127 2005/05/24 04:20:25 markus Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -1581,8 +1581,8 @@ ip_sysctl(name, namelen, oldp, oldlenp, newp, newlen) { int error; - /* All sysctl names at this level are terminal. */ - if (namelen != 1) + /* Almost all sysctl names at this level are terminal. */ + if (namelen != 1 && name[0] != IPCTL_IFQUEUE) return (ENOTDIR); switch (name[0]) { @@ -1628,6 +1628,9 @@ ip_sysctl(name, namelen, oldp, oldlenp, newp, newlen) return (sysctl_tstring(oldp, oldlenp, newp, newlen, ipsec_def_comp, sizeof(ipsec_def_comp))); + case IPCTL_IFQUEUE: + return (sysctl_ifq(name + 1, namelen - 1, + oldp, oldlenp, newp, newlen, &ipintrq)); default: if (name[0] < IPCTL_MAXID) return (sysctl_int_arr(ipctl_vars, name, namelen, |