summaryrefslogtreecommitdiff
path: root/sys/net
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 /sys/net
parent4cb17e9667a272f7541dbee84ac942404facb823 (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/net')
-rw-r--r--sys/net/if_pfsync.c22
-rw-r--r--sys/net/if_pfsync.h15
2 files changed, 35 insertions, 2 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)) \