summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2007-12-14 18:33:43 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2007-12-14 18:33:43 +0000
commit5532e64697944ad4c710705ab1b564052a8f51af (patch)
tree183870f005f01f56ae179f355463d683575b35a0
parent4cb17e9667a272f7541dbee84ac942404facb823 (diff)
add sysctl entry points into various network layers, in particular to
provide netstat(1) with data it needs; ok claudio reyk
-rw-r--r--sys/net/if_pfsync.c22
-rw-r--r--sys/net/if_pfsync.h15
-rw-r--r--sys/netatalk/at_proto.c5
-rw-r--r--sys/netatalk/ddp_usrreq.c26
-rw-r--r--sys/netatalk/ddp_var.h20
-rw-r--r--sys/netinet/igmp.c31
-rw-r--r--sys/netinet/igmp_var.h18
-rw-r--r--sys/netinet/in.h142
-rw-r--r--sys/netinet/in_proto.c8
-rw-r--r--sys/netinet/ip_ah.h7
-rw-r--r--sys/netinet/ip_carp.c18
-rw-r--r--sys/netinet/ip_carp.h6
-rw-r--r--sys/netinet/ip_esp.h7
-rw-r--r--sys/netinet/ip_ether.c7
-rw-r--r--sys/netinet/ip_ether.h6
-rw-r--r--sys/netinet/ip_input.c25
-rw-r--r--sys/netinet/ip_ipcomp.h9
-rw-r--r--sys/netinet/ip_ipip.c7
-rw-r--r--sys/netinet/ip_ipip.h6
-rw-r--r--sys/netinet/ip_mroute.c29
-rw-r--r--sys/netinet/ipsec_input.c62
-rw-r--r--sys/netinet/pim_var.h3
-rw-r--r--sys/netinet6/in6_proto.c6
-rw-r--r--sys/netinet6/ip6_input.c31
-rw-r--r--sys/netinet6/ip6_mroute.c25
-rw-r--r--sys/netinet6/ip6_var.h3
-rw-r--r--sys/netinet6/pim6_var.h10
-rw-r--r--sys/netinet6/raw_ip6.c23
-rw-r--r--sys/netinet6/raw_ip6.h13
29 files changed, 527 insertions, 63 deletions
diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c
index 839d7bbfa1f..61e909655ca 100644
--- a/sys/net/if_pfsync.c
+++ b/sys/net/if_pfsync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pfsync.c,v 1.87 2007/09/18 18:56:02 markus Exp $ */
+/* $OpenBSD: if_pfsync.c,v 1.88 2007/12/14 18:33:37 deraadt Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
@@ -36,6 +36,7 @@
#include <sys/ioctl.h>
#include <sys/timeout.h>
#include <sys/kernel.h>
+#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -1756,3 +1757,22 @@ pfsync_update_tdb(struct tdb *tdb, int output)
return (ret);
}
#endif
+
+int
+pfsync_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 PFSYNCCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &pfsyncstats, sizeof(pfsyncstats)));
+ default:
+ return (ENOPROTOOPT);
+ }
+}
diff --git a/sys/net/if_pfsync.h b/sys/net/if_pfsync.h
index 6e9059660cf..e94dad5fa46 100644
--- a/sys/net/if_pfsync.h
+++ b/sys/net/if_pfsync.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pfsync.h,v 1.31 2007/05/31 04:11:42 mcbride Exp $ */
+/* $OpenBSD: if_pfsync.h,v 1.32 2007/12/14 18:33:37 deraadt Exp $ */
/*
* Copyright (c) 2001 Michael Shalayeff
@@ -86,6 +86,17 @@ struct pfsync_state_bus {
u_int8_t pad[7];
} __packed;
+/*
+ * Names for PFSYNC sysctl objects
+ */
+#define PFSYNCCTL_STATS 1 /* PFSYNC stats */
+#define PFSYNCCTL_MAXID 2
+
+#define PFSYNCCTL_NAMES { \
+ { 0, 0 }, \
+ { "stats", CTLTYPE_STRUCT }, \
+}
+
#ifdef _KERNEL
union sc_statep {
@@ -255,6 +266,8 @@ struct pfsyncreq {
void pfsync_input(struct mbuf *, ...);
int pfsync_clear_states(u_int32_t, char *);
int pfsync_pack_state(u_int8_t, struct pf_state *, int);
+int pfsync_sysctl(int *, u_int, void *, size_t *, void *, size_t);
+
#define pfsync_insert_state(st) do { \
if ((st->rule.ptr->rule_flag & PFRULE_NOSYNC) || \
(st->state_key->proto == IPPROTO_PFSYNC)) \
diff --git a/sys/netatalk/at_proto.c b/sys/netatalk/at_proto.c
index c133bd422d4..919c560bb87 100644
--- a/sys/netatalk/at_proto.c
+++ b/sys/netatalk/at_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: at_proto.c,v 1.1 1997/07/23 03:39:52 denny Exp $ */
+/* $OpenBSD: at_proto.c,v 1.2 2007/12/14 18:33:40 deraadt Exp $ */
/*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
* All Rights Reserved.
@@ -82,6 +82,7 @@
#include <netinet/if_ether.h>
#include <netatalk/at.h>
+#include <netatalk/ddp_var.h>
#include <netatalk/at_extern.h>
struct protosw atalksw[] = {
@@ -100,7 +101,7 @@ struct protosw atalksw[] = {
/* socket-protocol interface. */
ddp_usrreq,
/* utility routines. */
- ddp_init, 0, 0, 0,
+ ddp_init, 0, 0, 0, ddp_sysctl
},
};
diff --git a/sys/netatalk/ddp_usrreq.c b/sys/netatalk/ddp_usrreq.c
index 6137596c059..f3193ae421e 100644
--- a/sys/netatalk/ddp_usrreq.c
+++ b/sys/netatalk/ddp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ddp_usrreq.c,v 1.10 2007/10/06 02:18:38 krw Exp $ */
+/* $OpenBSD: ddp_usrreq.c,v 1.11 2007/12/14 18:33:40 deraadt Exp $ */
/*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
@@ -587,3 +587,27 @@ ddp_init()
atintrq1.ifq_maxlen = IFQ_MAXLEN;
atintrq2.ifq_maxlen = IFQ_MAXLEN;
}
+
+/*
+ * Sysctl for ddp variables.
+ */
+int
+ddp_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 DDPCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &ddpstat, sizeof(ddpstat)));
+
+ default:
+ return (ENOPROTOOPT);
+ }
+ /* NOTREACHED */
+}
diff --git a/sys/netatalk/ddp_var.h b/sys/netatalk/ddp_var.h
index 39deefcb89d..a70c20f44d7 100644
--- a/sys/netatalk/ddp_var.h
+++ b/sys/netatalk/ddp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ddp_var.h,v 1.2 2007/05/26 12:09:40 claudio Exp $ */
+/* $OpenBSD: ddp_var.h,v 1.3 2007/12/14 18:33:40 deraadt Exp $ */
/*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
@@ -75,10 +75,28 @@ struct ddpstat {
u_long ddps_nosockspace; /* no space in sockbuf for packet */
};
+/*
+ * Names for DDP sysctl objects
+ */
+#define DDPCTL_STATS 1 /* DDP statistics */
+#define DDPCTL_MAXID 2
+
+#define DDPCTL_NAMES { \
+ { 0, 0 }, \
+ { "stats", CTLTYPE_STRUCT } \
+}
+
+#define UDPCTL_VARS { \
+ NULL \
+}
+
#ifdef _KERNEL
extern struct ddpcb *ddp_ports[ ATPORT_LAST ];
extern struct ddpcb *ddpcb;
extern struct ddpstat ddpstat;
+
+int ddp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
+
#endif
#endif /* _NETATALK_DDP_VAR_H_ */
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index b7ef843f0c2..c2ca8b0d2ab 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: igmp.c,v 1.25 2007/12/13 20:47:57 millert Exp $ */
+/* $OpenBSD: igmp.c,v 1.26 2007/12/14 18:33:40 deraadt Exp $ */
/* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */
/*
@@ -79,6 +79,7 @@
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/protosw.h>
+#include <sys/sysctl.h>
#include <net/if.h>
#include <net/route.h>
@@ -96,6 +97,8 @@
#define IP_MULTICASTOPTS 0
+int *igmpctl_vars[IGMPCTL_MAXID] = IGMPCTL_VARS;
+
int igmp_timers_are_running;
static struct router_info *rti_head;
struct igmpstat igmpstat;
@@ -623,3 +626,29 @@ igmp_sendpkt(inm, type, addr)
++igmpstat.igps_snd_reports;
}
+
+/*
+ * Sysctl for igmp variables.
+ */
+int
+igmp_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 IGMPCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &igmpstat, sizeof(igmpstat)));
+ default:
+ if (name[0] < IGMPCTL_MAXID)
+ return (sysctl_int_arr(igmpctl_vars, name, namelen,
+ oldp, oldlenp, newp, newlen));
+ return (ENOPROTOOPT);
+ }
+ /* NOTREACHED */
+}
diff --git a/sys/netinet/igmp_var.h b/sys/netinet/igmp_var.h
index 3f478e5a4fe..c0aaa286ce9 100644
--- a/sys/netinet/igmp_var.h
+++ b/sys/netinet/igmp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: igmp_var.h,v 1.7 2003/06/02 23:28:13 millert Exp $ */
+/* $OpenBSD: igmp_var.h,v 1.8 2007/12/14 18:33:40 deraadt Exp $ */
/* $NetBSD: igmp_var.h,v 1.9 1996/02/13 23:41:31 christos Exp $ */
/*
@@ -62,6 +62,21 @@ struct igmpstat {
u_long igps_snd_reports; /* sent membership reports */
};
+/*
+ * Names for IGMP sysctl objects
+ */
+#define IGMPCTL_STATS 1 /* IGMP statistics */
+#define IGMPCTL_MAXID 2
+
+#define IGMPCTL_NAMES { \
+ { 0, 0 }, \
+ { "stats", CTLTYPE_STRUCT } \
+}
+
+#define IGMPCTL_VARS { \
+ NULL \
+}
+
#ifdef _KERNEL
extern struct igmpstat igmpstat;
@@ -78,5 +93,6 @@ void igmp_joingroup(struct in_multi *);
void igmp_leavegroup(struct in_multi *);
void igmp_fasttimo(void);
void igmp_slowtimo(void);
+int igmp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
#endif /* _KERNEL */
#endif /* _NETINET_IGMP_VAR_H_ */
diff --git a/sys/netinet/in.h b/sys/netinet/in.h
index 1a2e3a98897..ba3695b80ca 100644
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.h,v 1.75 2007/12/13 20:00:53 reyk Exp $ */
+/* $OpenBSD: in.h,v 1.76 2007/12/14 18:33:40 deraadt Exp $ */
/* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
/*
@@ -325,7 +325,7 @@ struct ip_mreq {
* Third level is protocol number.
* Fourth level is desired variable within that protocol.
*/
-#define IPPROTO_MAXID (IPPROTO_CARP + 1) /* don't list to IPPROTO_MAX */
+#define IPPROTO_MAXID (IPPROTO_PFSYNC + 1) /* don't list to IPPROTO_MAX */
#define CTL_IPPROTO_NAMES { \
{ "ip", CTLTYPE_NODE }, \
@@ -441,6 +441,134 @@ struct ip_mreq {
{ 0, 0 }, \
{ 0, 0 }, \
{ "carp", CTLTYPE_NODE }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { "pfsync", CTLTYPE_NODE }, \
}
/*
@@ -483,7 +611,9 @@ struct ip_mreq {
#define IPCTL_MFORWARDING 31
#define IPCTL_MULTIPATH 32
#define IPCTL_STATS 33 /* IP statistics */
-#define IPCTL_MAXID 34
+#define IPCTL_MRTPROTO 34 /* type of multicast */
+#define IPCTL_MRTSTATS 35
+#define IPCTL_MAXID 36
#define IPCTL_NAMES { \
{ 0, 0 }, \
@@ -519,7 +649,9 @@ struct ip_mreq {
{ "ifq", CTLTYPE_NODE }, \
{ "mforwarding", CTLTYPE_INT }, \
{ "multipath", CTLTYPE_INT }, \
- { "stats", CTLTYPE_STRUCT } \
+ { "stats", CTLTYPE_STRUCT }, \
+ { "mrtproto", CTLTYPE_INT }, \
+ { "mrtstats", CTLTYPE_STRUCT }, \
}
#define IPCTL_VARS { \
NULL, \
@@ -555,6 +687,8 @@ struct ip_mreq {
NULL, \
&ipmforwarding, \
&ipmultipath, \
+ NULL, \
+ NULL, \
NULL \
}
diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c
index 924630dc039..6969401128e 100644
--- a/sys/netinet/in_proto.c
+++ b/sys/netinet/in_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_proto.c,v 1.46 2007/06/06 09:58:12 henning Exp $ */
+/* $OpenBSD: in_proto.c,v 1.47 2007/12/14 18:33:40 deraadt Exp $ */
/* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */
/*
@@ -229,13 +229,13 @@ struct protosw inetsw[] = {
{ SOCK_RAW, &inetdomain, IPPROTO_IGMP, PR_ATOMIC|PR_ADDR,
igmp_input, rip_output, 0, rip_ctloutput,
rip_usrreq,
- igmp_init, igmp_fasttimo, igmp_slowtimo, 0,
+ igmp_init, igmp_fasttimo, igmp_slowtimo, 0, igmp_sysctl
},
#ifdef PIM
{ SOCK_RAW, &inetdomain, IPPROTO_PIM, PR_ATOMIC|PR_ADDR,
pim_input, rip_output, 0, rip_ctloutput,
rip_usrreq,
- 0, 0, 0, 0,
+ 0, 0, 0, 0, pim_sysctl
},
#endif /* PIM */
#ifdef IPSEC
@@ -283,7 +283,7 @@ struct protosw inetsw[] = {
{ SOCK_RAW, &inetdomain, IPPROTO_PFSYNC, PR_ATOMIC|PR_ADDR,
pfsync_input, rip_output, 0, rip_ctloutput,
rip_usrreq,
- 0, 0, 0, 0,
+ 0, 0, 0, 0, pfsync_sysctl
},
#endif /* NPFSYNC > 0 */
/* raw wildcard */
diff --git a/sys/netinet/ip_ah.h b/sys/netinet/ip_ah.h
index 2ec742dfe11..8d6fe54bcd7 100644
--- a/sys/netinet/ip_ah.h
+++ b/sys/netinet/ip_ah.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ah.h,v 1.31 2004/02/17 12:07:45 markus Exp $ */
+/* $OpenBSD: ip_ah.h,v 1.32 2007/12/14 18:33:40 deraadt Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -79,16 +79,19 @@ struct ah
* Names for AH sysctl objects
*/
#define AHCTL_ENABLE 1 /* Enable AH processing */
-#define AHCTL_MAXID 2
+#define AHCTL_STATS 2 /* AH stats */
+#define AHCTL_MAXID 3
#define AHCTL_NAMES { \
{ 0, 0 }, \
{ "enable", CTLTYPE_INT }, \
+ { "stats", CTLTYPE_STRUCT } \
}
#define AHCTL_VARS { \
NULL, \
&ah_enable, \
+ NULL \
}
#ifdef _KERNEL
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index 97f5cab752f..8aebcfcb331 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_carp.c,v 1.158 2007/11/27 11:34:18 claudio Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.159 2007/12/14 18:33:40 deraadt Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -802,10 +802,18 @@ carp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
if (namelen != 1)
return (ENOTDIR);
- if (name[0] <= 0 || name[0] >= CARPCTL_MAXID)
- return (ENOPROTOOPT);
-
- return sysctl_int(oldp, oldlenp, newp, newlen, &carp_opts[name[0]]);
+ switch (name[0]) {
+ case CARPCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &carpstats, sizeof(carpstats)));
+ default:
+ if (name[0] <= 0 || name[0] >= CARPCTL_MAXID)
+ return (ENOPROTOOPT);
+ return sysctl_int(oldp, oldlenp, newp, newlen,
+ &carp_opts[name[0]]);
+ }
}
/*
diff --git a/sys/netinet/ip_carp.h b/sys/netinet/ip_carp.h
index 60d47df748a..f2d9bf7b046 100644
--- a/sys/netinet/ip_carp.h
+++ b/sys/netinet/ip_carp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_carp.h,v 1.24 2007/11/22 01:21:40 mpf Exp $ */
+/* $OpenBSD: ip_carp.h,v 1.25 2007/12/14 18:33:40 deraadt Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -143,7 +143,8 @@ struct carpreq {
#define CARPCTL_PREEMPT 2 /* high-pri backup preemption mode */
#define CARPCTL_LOG 3 /* log bad packets */
#define CARPCTL_ARPBALANCE 4 /* balance arp responses */
-#define CARPCTL_MAXID 5
+#define CARPCTL_STATS 5 /* CARP stats */
+#define CARPCTL_MAXID 6
#define CARPCTL_NAMES { \
{ 0, 0 }, \
@@ -151,6 +152,7 @@ struct carpreq {
{ "preempt", CTLTYPE_INT }, \
{ "log", CTLTYPE_INT }, \
{ "arpbalance", CTLTYPE_INT }, \
+ { "stats", CTLTYPE_STRUCT }, \
}
#ifdef _KERNEL
diff --git a/sys/netinet/ip_esp.h b/sys/netinet/ip_esp.h
index 887dbdeac28..42a66386a44 100644
--- a/sys/netinet/ip_esp.h
+++ b/sys/netinet/ip_esp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_esp.h,v 1.40 2004/02/17 12:07:45 markus Exp $ */
+/* $OpenBSD: ip_esp.h,v 1.41 2007/12/14 18:33:41 deraadt Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -72,13 +72,15 @@ struct espstat
#define ESPCTL_ENABLE 1 /* Enable ESP processing */
#define ESPCTL_UDPENCAP_ENABLE 2 /* Enable ESP over UDP */
#define ESPCTL_UDPENCAP_PORT 3 /* UDP port for encapsulation */
-#define ESPCTL_MAXID 4
+#define ESPCTL_STATS 4 /* ESP Stats */
+#define ESPCTL_MAXID 5
#define ESPCTL_NAMES { \
{ 0, 0 }, \
{ "enable", CTLTYPE_INT }, \
{ "udpencap", CTLTYPE_INT }, \
{ "udpencap_port", CTLTYPE_INT }, \
+ { "stats", CTLTYPE_STRUCT }, \
}
#define ESPCTL_VARS { \
@@ -86,6 +88,7 @@ struct espstat
&esp_enable, \
&udpencap_enable, \
&udpencap_port, \
+ NULL \
}
#ifdef _KERNEL
diff --git a/sys/netinet/ip_ether.c b/sys/netinet/ip_ether.c
index eca7269af15..c29d2dc54bb 100644
--- a/sys/netinet/ip_ether.c
+++ b/sys/netinet/ip_ether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ether.c,v 1.50 2007/02/20 19:37:40 claudio Exp $ */
+/* $OpenBSD: ip_ether.c,v 1.51 2007/12/14 18:33:41 deraadt Exp $ */
/*
* The author of this code is Angelos D. Keromytis (kermit@adk.gr)
*
@@ -425,6 +425,11 @@ etherip_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
case ETHERIPCTL_ALLOW:
return (sysctl_int(oldp, oldlenp, newp, newlen,
&etherip_allow));
+ case ETHERIPCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &etheripstat, sizeof(etheripstat)));
default:
return (ENOPROTOOPT);
}
diff --git a/sys/netinet/ip_ether.h b/sys/netinet/ip_ether.h
index 7bcde9799a7..c2372557bd6 100644
--- a/sys/netinet/ip_ether.h
+++ b/sys/netinet/ip_ether.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ether.h,v 1.13 2002/06/09 16:26:10 itojun Exp $ */
+/* $OpenBSD: ip_ether.h,v 1.14 2007/12/14 18:33:41 deraadt Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@adk.gr)
*
@@ -54,11 +54,13 @@ struct etherip_header {
* Names for Ether-IP sysctl objects
*/
#define ETHERIPCTL_ALLOW 1 /* accept incoming EtherIP packets */
-#define ETHERIPCTL_MAXID 2
+#define ETHERIPCTL_STATS 2 /* etherip stats */
+#define ETHERIPCTL_MAXID 3
#define ETHERIPCTL_NAMES { \
{ 0, 0 }, \
{ "allow", CTLTYPE_INT }, \
+ { "stats", CTLTYPE_STRUCT }, \
}
#ifdef _KERNEL
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 8bbe357c553..d8d3c01a4b4 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.155 2007/12/13 20:00:53 reyk Exp $ */
+/* $OpenBSD: ip_input.c,v 1.156 2007/12/14 18:33:41 deraadt Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -63,6 +63,10 @@
#include <net/pfvar.h>
#endif
+#ifdef MROUTING
+#include <netinet/ip_mroute.h>
+#endif
+
#ifdef IPSEC
#include <netinet/ip_ipsp.h>
#endif /* IPSEC */
@@ -1571,6 +1575,10 @@ ip_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
size_t newlen;
{
int error;
+#ifdef MROUTING
+ extern int ip_mrtproto;
+ extern struct mrtstat mrtstat;
+#endif
/* Almost all sysctl names at this level are terminal. */
if (namelen != 1 && name[0] != IPCTL_IFQUEUE)
@@ -1627,6 +1635,21 @@ ip_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
return (EPERM);
return (sysctl_struct(oldp, oldlenp, newp, newlen,
&ipstat, sizeof(ipstat)));
+ case IPCTL_MRTSTATS:
+#ifdef MROUTING
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &mrtstat, sizeof(mrtstat)));
+#else
+ return (EOPNOTSUPP);
+#endif
+ case IPCTL_MRTPROTO:
+#ifdef MROUTING
+ return (sysctl_rdint(oldp, oldlenp, newp, ip_mrtproto));
+#else
+ return (EOPNOTSUPP);
+#endif
default:
if (name[0] < IPCTL_MAXID)
return (sysctl_int_arr(ipctl_vars, name, namelen,
diff --git a/sys/netinet/ip_ipcomp.h b/sys/netinet/ip_ipcomp.h
index 501e0db7bcc..76596ebdadd 100644
--- a/sys/netinet/ip_ipcomp.h
+++ b/sys/netinet/ip_ipcomp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipcomp.h,v 1.6 2004/02/17 12:07:45 markus Exp $ */
+/* $OpenBSD: ip_ipcomp.h,v 1.7 2007/12/14 18:33:41 deraadt Exp $ */
/*
* Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org)
@@ -68,16 +68,19 @@ struct ipcomp {
* Names for IPCOMP sysctl objects
*/
#define IPCOMPCTL_ENABLE 1 /* Enable COMP processing */
-#define IPCOMPCTL_MAXID 2
+#define IPCOMPCTL_STATS 2 /* COMP stats */
+#define IPCOMPCTL_MAXID 3
#define IPCOMPCTL_NAMES { \
{ 0, 0 }, \
- { "enable", CTLTYPE_INT}, \
+ { "enable", CTLTYPE_INT }, \
+ { "stats", CTLTYPE_STRUCT }, \
}
#define IPCOMPCTL_VARS { \
NULL, \
&ipcomp_enable, \
+ NULL \
}
#ifdef _KERNEL
diff --git a/sys/netinet/ip_ipip.c b/sys/netinet/ip_ipip.c
index 4b9fae0b5cb..c763e9b6bd7 100644
--- a/sys/netinet/ip_ipip.c
+++ b/sys/netinet/ip_ipip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipip.c,v 1.39 2007/02/10 15:34:22 claudio Exp $ */
+/* $OpenBSD: ip_ipip.c,v 1.40 2007/12/14 18:33:41 deraadt Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -633,6 +633,11 @@ ipip_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
switch (name[0]) {
case IPIPCTL_ALLOW:
return (sysctl_int(oldp, oldlenp, newp, newlen, &ipip_allow));
+ case IPIPCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &ipipstat, sizeof(ipipstat)));
default:
return (ENOPROTOOPT);
}
diff --git a/sys/netinet/ip_ipip.h b/sys/netinet/ip_ipip.h
index 60561001ef9..ed9755f31f1 100644
--- a/sys/netinet/ip_ipip.h
+++ b/sys/netinet/ip_ipip.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipip.h,v 1.5 2002/06/09 16:26:10 itojun Exp $ */
+/* $OpenBSD: ip_ipip.h,v 1.6 2007/12/14 18:33:41 deraadt Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -64,11 +64,13 @@ struct ipipstat
* Names for IPIP sysctl objects
*/
#define IPIPCTL_ALLOW 1 /* accept incoming IP4 packets */
-#define IPIPCTL_MAXID 2
+#define IPIPCTL_STATS 2 /* IPIP stats */
+#define IPIPCTL_MAXID 3
#define IPIPCTL_NAMES { \
{ 0, 0 }, \
{ "allow", CTLTYPE_INT }, \
+ { "stats", CTLTYPE_STRUCT }, \
}
#ifdef _KERNEL
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index 309c5e3ac6a..68af8f8b963 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_mroute.c,v 1.48 2007/05/22 09:51:13 michele Exp $ */
+/* $OpenBSD: ip_mroute.c,v 1.49 2007/12/14 18:33:41 deraadt Exp $ */
/* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */
/*
@@ -72,6 +72,7 @@
#include <sys/kernel.h>
#include <sys/ioctl.h>
#include <sys/syslog.h>
+#include <sys/sysctl.h>
#include <sys/timeout.h>
#include <net/if.h>
@@ -3405,4 +3406,30 @@ pim_input_to_daemon:
return;
}
+
+/*
+ * Sysctl for pim variables.
+ */
+int
+pim_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 PIMCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &pimstat, sizeof(pimstat)));
+
+ default:
+ return (ENOPROTOOPT);
+ }
+ /* NOTREACHED */
+}
+
+
#endif /* PIM */
diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c
index 16ea0a2cdb7..13370a297be 100644
--- a/sys/netinet/ipsec_input.c
+++ b/sys/netinet/ipsec_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsec_input.c,v 1.84 2007/05/28 17:16:39 henning Exp $ */
+/* $OpenBSD: ipsec_input.c,v 1.85 2007/12/14 18:33:41 deraadt Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -644,30 +644,66 @@ int
esp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen)
{
- if (name[0] < ESPCTL_MAXID)
- return (sysctl_int_arr(espctl_vars, name, namelen,
- oldp, oldlenp, newp, newlen));
- return (ENOPROTOOPT);
+ /* All sysctl names at this level are terminal. */
+ if (namelen != 1)
+ return (ENOTDIR);
+
+ switch (name[0]) {
+ case ESPCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &espstat, sizeof(espstat)));
+ default:
+ if (name[0] < ESPCTL_MAXID)
+ return (sysctl_int_arr(espctl_vars, name, namelen,
+ oldp, oldlenp, newp, newlen));
+ return (ENOPROTOOPT);
+ }
}
int
ah_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen)
{
- if (name[0] < AHCTL_MAXID)
- return (sysctl_int_arr(ahctl_vars, name, namelen,
- oldp, oldlenp, newp, newlen));
- return (ENOPROTOOPT);
+ /* All sysctl names at this level are terminal. */
+ if (namelen != 1)
+ return (ENOTDIR);
+
+ switch (name[0]) {
+ case AHCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &ahstat, sizeof(ahstat)));
+ default:
+ if (name[0] < AHCTL_MAXID)
+ return (sysctl_int_arr(ahctl_vars, name, namelen,
+ oldp, oldlenp, newp, newlen));
+ return (ENOPROTOOPT);
+ }
}
int
ipcomp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen)
{
- if (name[0] < IPCOMPCTL_MAXID)
- return (sysctl_int_arr(ipcompctl_vars, name, namelen,
- oldp, oldlenp, newp, newlen));
- return (ENOPROTOOPT);
+ /* All sysctl names at this level are terminal. */
+ if (namelen != 1)
+ return (ENOTDIR);
+
+ switch (name[0]) {
+ case IPCOMPCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &ipcompstat, sizeof(ipcompstat)));
+ default:
+ if (name[0] < IPCOMPCTL_MAXID)
+ return (sysctl_int_arr(ipcompctl_vars, name, namelen,
+ oldp, oldlenp, newp, newlen));
+ return (ENOPROTOOPT);
+ }
}
#ifdef INET
diff --git a/sys/netinet/pim_var.h b/sys/netinet/pim_var.h
index 7ff2b55fa29..bddc04a1ff6 100644
--- a/sys/netinet/pim_var.h
+++ b/sys/netinet/pim_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pim_var.h,v 1.2 2006/07/06 02:56:58 brad Exp $ */
+/* $OpenBSD: pim_var.h,v 1.3 2007/12/14 18:33:41 deraadt Exp $ */
/* $NetBSD: pim_var.h,v 1.1 2004/09/04 23:32:29 manu Exp $ */
/*
@@ -77,6 +77,7 @@ struct pimstat {
extern struct pimstat pimstat;
void pim_input(struct mbuf *, ...);
+int pim_sysctl(int *, u_int, void *, size_t *, void *, size_t);
#endif
#endif /* _NETINET_PIM_VAR_H_ */
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