diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-12-14 18:33:43 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-12-14 18:33:43 +0000 |
commit | 5532e64697944ad4c710705ab1b564052a8f51af (patch) | |
tree | 183870f005f01f56ae179f355463d683575b35a0 /sys/netinet6 | |
parent | 4cb17e9667a272f7541dbee84ac942404facb823 (diff) |
add sysctl entry points into various network layers, in particular to
provide netstat(1) with data it needs; ok claudio reyk
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/in6_proto.c | 6 | ||||
-rw-r--r-- | sys/netinet6/ip6_input.c | 31 | ||||
-rw-r--r-- | sys/netinet6/ip6_mroute.c | 25 | ||||
-rw-r--r-- | sys/netinet6/ip6_var.h | 3 | ||||
-rw-r--r-- | sys/netinet6/pim6_var.h | 10 | ||||
-rw-r--r-- | sys/netinet6/raw_ip6.c | 23 | ||||
-rw-r--r-- | sys/netinet6/raw_ip6.h | 13 |
7 files changed, 100 insertions, 11 deletions
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index 10dc35ccafa..387f80ca7ff 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_proto.c,v 1.52 2007/05/03 15:47:47 claudio Exp $ */ +/* $OpenBSD: in6_proto.c,v 1.53 2007/12/14 18:33:41 deraadt Exp $ */ /* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */ /* @@ -145,7 +145,7 @@ struct ip6protosw inet6sw[] = { { SOCK_RAW, &inet6domain, IPPROTO_RAW, PR_ATOMIC|PR_ADDR, rip6_input, rip6_output, rip6_ctlinput, rip6_ctloutput, rip6_usrreq, - 0, 0, 0, 0, + 0, 0, 0, 0, rip6_sysctl }, { SOCK_RAW, &inet6domain, IPPROTO_ICMPV6, PR_ATOMIC|PR_ADDR, icmp6_input, rip6_output, rip6_ctlinput, rip6_ctloutput, @@ -219,7 +219,7 @@ struct ip6protosw inet6sw[] = { { SOCK_RAW, &inet6domain, IPPROTO_PIM, PR_ATOMIC|PR_ADDR, pim6_input, rip6_output, 0, rip6_ctloutput, rip6_usrreq, - 0, 0, 0, 0, + 0, 0, 0, 0, pim6_sysctl }, #endif #if NCARP > 0 diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index eec85836c3f..2459d5d2688 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_input.c,v 1.79 2007/11/27 16:22:13 martynas Exp $ */ +/* $OpenBSD: ip6_input.c,v 1.80 2007/12/14 18:33:41 deraadt Exp $ */ /* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -106,6 +106,10 @@ #include "gif.h" #include "bpfilter.h" +#ifdef MROUTING +#include <netinet6/ip6_mroute.h> +#endif + #if NPF > 0 #include <net/pfvar.h> #endif @@ -1470,6 +1474,11 @@ ip6_sysctl(name, namelen, oldp, oldlenp, newp, newlen) void *newp; size_t newlen; { +#ifdef MROUTING + extern int ip6_mrtproto; + extern struct mrt6stat mrt6stat; +#endif + /* All sysctl names at this level are terminal. */ if (namelen != 1) return ENOTDIR; @@ -1479,6 +1488,26 @@ ip6_sysctl(name, namelen, oldp, oldlenp, newp, newlen) return sysctl_rdstring(oldp, oldlenp, newp, __KAME_VERSION); case IPV6CTL_V6ONLY: return sysctl_rdint(oldp, oldlenp, newp, ip6_v6only); + case IPV6CTL_STATS: + if (newp != NULL) + return (EPERM); + return (sysctl_struct(oldp, oldlenp, newp, newlen, + &ip6stat, sizeof(ip6stat))); + case IPV6CTL_MRTSTATS: +#ifdef MROUTING + if (newp != NULL) + return (EPERM); + return (sysctl_struct(oldp, oldlenp, newp, newlen, + &mrt6stat, sizeof(mrt6stat))); +#else + return (EOPNOTSUPP); +#endif + case IPV6CTL_MRTPROTO: +#ifdef MROUTING + return sysctl_rdint(oldp, oldlenp, newp, ip6_mrtproto); +#else + return (EOPNOTSUPP); +#endif default: if (name[0] < IPV6CTL_MAXID) return (sysctl_int_arr(ipv6ctl_vars, name, namelen, diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index c9d2e7ebbae..3198ad7b8be 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -99,6 +99,7 @@ #include <sys/kernel.h> #include <sys/ioctl.h> #include <sys/syslog.h> +#include <sys/sysctl.h> #include <net/if.h> #include <net/route.h> @@ -1907,3 +1908,27 @@ pim6_input(mp, offp, proto) rip6_input(&m, offp, proto); return (IPPROTO_DONE); } + +/* + * Sysctl for pim6 variables. + */ +int +pim6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen) +{ + /* All sysctl names at this level are terminal. */ + if (namelen != 1) + return (ENOTDIR); + + switch (name[0]) { + case PIM6CTL_STATS: + if (newp != NULL) + return (EPERM); + return (sysctl_struct(oldp, oldlenp, newp, newlen, + &pim6stat, sizeof(pim6stat))); + + default: + return (ENOPROTOOPT); + } + /* NOTREACHED */ +} diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h index b3be6fc3628..b560d21ee74 100644 --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_var.h,v 1.31 2007/06/01 00:52:38 henning Exp $ */ +/* $OpenBSD: ip6_var.h,v 1.32 2007/12/14 18:33:41 deraadt Exp $ */ /* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */ /* @@ -312,6 +312,7 @@ int rip6_ctloutput(int, struct socket *, int, int, struct mbuf **); int rip6_output(struct mbuf *, ...); int rip6_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *); +int rip6_sysctl(int *, u_int, void *, size_t *, void *, size_t); int dest6_input(struct mbuf **, int *, int); int none_input(struct mbuf **, int *, int); diff --git a/sys/netinet6/pim6_var.h b/sys/netinet6/pim6_var.h index 036f83f24d9..59bcfae7c7c 100644 --- a/sys/netinet6/pim6_var.h +++ b/sys/netinet6/pim6_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pim6_var.h,v 1.8 2006/07/06 02:56:58 brad Exp $ */ +/* $OpenBSD: pim6_var.h,v 1.9 2007/12/14 18:33:41 deraadt Exp $ */ /* $KAME: pim6_var.h,v 1.8 2000/06/06 08:07:43 jinmei Exp $ */ /* @@ -54,16 +54,18 @@ struct pim6stat { #if (defined(KERNEL)) || (defined(_KERNEL)) extern struct pim6stat pim6stat; int pim6_input(struct mbuf **, int *, int); +int pim6_sysctl(int *, u_int, void *, size_t *, void *, size_t); #endif /* KERNEL */ /* - * Names for PIM sysctl objects + * Names for PIM6 sysctl objects */ -#define PIM6CTL_STATS 1 /* statistics (read-only) */ +#define PIM6CTL_STATS 1 /* PIM6 stats */ #define PIM6CTL_MAXID 2 #define PIM6CTL_NAMES { \ { 0, 0 }, \ - { 0, 0 }, \ + { "stats", CTLTYPE_NODE }, \ } + #endif /* _NETINET6_PIM6_VAR_H_ */ diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index bccb8e65ccb..5bbb3baaf14 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.34 2007/10/29 16:19:24 chl Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.35 2007/12/14 18:33:41 deraadt Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -69,6 +69,7 @@ #include <sys/socketvar.h> #include <sys/errno.h> #include <sys/systm.h> +#include <sys/sysctl.h> #include <net/if.h> #include <net/route.h> @@ -841,3 +842,23 @@ rip6_usrreq(so, req, m, nam, control, p) m_freem(m); return (error); } + +int +rip6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen) +{ + /* All sysctl names at this level are terminal. */ + if (namelen != 1) + return ENOTDIR; + + switch (name[0]) { + case RIPV6CTL_STATS: + if (newp != NULL) + return (EPERM); + return (sysctl_struct(oldp, oldlenp, newp, newlen, + &rip6stat, sizeof(rip6stat))); + default: + return (EOPNOTSUPP); + } + /* NOTREACHED */ +} diff --git a/sys/netinet6/raw_ip6.h b/sys/netinet6/raw_ip6.h index 1a40829539c..d81b1451b4d 100644 --- a/sys/netinet6/raw_ip6.h +++ b/sys/netinet6/raw_ip6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.h,v 1.2 2006/07/06 02:56:58 brad Exp $ */ +/* $OpenBSD: raw_ip6.h,v 1.3 2007/12/14 18:33:42 deraadt Exp $ */ /* $KAME: raw_ip6.h,v 1.2 2001/05/27 13:28:35 itojun Exp $ */ /* @@ -47,6 +47,17 @@ struct rip6stat { u_int64_t rip6s_opackets; /* total output packets */ }; +/* + * Names for RIP6 sysctl objects + */ +#define RIPV6CTL_STATS 1 /* RIP6 stats */ +#define RIPV6CTL_MAXID 2 + +#define RIPM6CTL_NAMES { \ + { 0, 0 }, \ + { "stats", CTLTYPE_NODE }, \ +} + #ifdef _KERNEL extern struct rip6stat rip6stat; #endif |