Module Name: src
Committed By: martin
Date: Fri Apr 3 16:20:52 UTC 2020
Modified Files:
src/sbin/route: prog_ops.h route_hostops.c route_rumpops.c
src/usr.bin/netstat: netstat_hostops.c netstat_rumpops.c prog_ops.h
Log Message:
Make route and netstat share the same struct progops (and initialization
code)
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/route/prog_ops.h
cvs rdiff -u -r1.2 -r1.3 src/sbin/route/route_hostops.c \
src/sbin/route/route_rumpops.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/netstat/netstat_hostops.c \
src/usr.bin/netstat/netstat_rumpops.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/netstat/prog_ops.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/route/prog_ops.h
diff -u src/sbin/route/prog_ops.h:1.4 src/sbin/route/prog_ops.h:1.5
--- src/sbin/route/prog_ops.h:1.4 Thu Apr 2 18:32:31 2020
+++ src/sbin/route/prog_ops.h Fri Apr 3 16:20:52 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: prog_ops.h,v 1.4 2020/04/02 18:32:31 christos Exp $ */
+/* $NetBSD: prog_ops.h,v 1.5 2020/04/03 16:20:52 martin Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,9 +30,13 @@
#define _PROG_OPS_H_
#include <sys/types.h>
+#include <sys/sysctl.h>
#ifndef CRUNCHOPS
-/* XXX: Keep same order with netstat! */
+/*
+ * This is shared between netstat and route (as they share some code)
+ */
+struct sysctlnode;
struct prog_ops {
int (*op_init)(void);
@@ -46,10 +50,18 @@ struct prog_ops {
ssize_t (*op_read)(int, void *, size_t);
ssize_t (*op_write)(int, const void *, size_t);
+ int (*op_shutdown)(int, int);
+
int (*op_sysctl)(const int *, u_int, void *, size_t *,
const void *, size_t);
- int (*op_shutdown)(int, int);
+ int (*op_sysctlbyname)(const char *, void *, size_t *,
+ const void *, size_t);
+
+ int (*op_sysctlgetmibinfo)(const char *, int *, u_int *,
+ char *, size_t *, struct sysctlnode **, int);
+
+ int (*op_sysctlnametomib)(const char *, int *, size_t *);
};
extern const struct prog_ops prog_ops;
@@ -64,9 +76,13 @@ extern const struct prog_ops prog_ops;
#define prog_read prog_ops.op_read
#define prog_write prog_ops.op_write
+#define prog_shutdown prog_ops.op_shutdown
+
#define prog_sysctl prog_ops.op_sysctl
-#define prog_shutdown prog_ops.op_shutdown
+#define prog_sysctlbyname prog_ops.op_sysctlbyname
+#define prog_sysctlgetmibinfo prog_ops.op_sysctlgetmibinfo
+#define prog_sysctlnametomib prog_ops.op_sysctlnametomib
#else
#define prog_init ((int (*)(void))NULL)
@@ -80,8 +96,13 @@ extern const struct prog_ops prog_ops;
#define prog_read read
#define prog_write write
-#define prog_sysctl sysctl
#define prog_shutdown shutdown
+
+#define prog_sysctl sysctl
+#define prog_sysctlbyname sysctlbyname
+#define prog_sysctlgetmibinfo sysctlgetmibinfo
+#define prog_sysctlnametomib sysctlnametomib
+
#endif
#endif /* _PROG_OPS_H_ */
Index: src/sbin/route/route_hostops.c
diff -u src/sbin/route/route_hostops.c:1.2 src/sbin/route/route_hostops.c:1.3
--- src/sbin/route/route_hostops.c:1.2 Thu Apr 2 18:32:31 2020
+++ src/sbin/route/route_hostops.c Fri Apr 3 16:20:52 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: route_hostops.c,v 1.2 2020/04/02 18:32:31 christos Exp $ */
+/* $NetBSD: route_hostops.c,v 1.3 2020/04/03 16:20:52 martin Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: route_hostops.c,v 1.2 2020/04/02 18:32:31 christos Exp $");
+__RCSID("$NetBSD: route_hostops.c,v 1.3 2020/04/03 16:20:52 martin Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -51,7 +51,13 @@ const struct prog_ops prog_ops = {
.op_read = read,
.op_write = write,
+ .op_shutdown = shutdown,
+
.op_sysctl = sysctl,
- .op_shutdown = shutdown,
+ .op_sysctlbyname = sysctlbyname,
+
+ .op_sysctlgetmibinfo = sysctlgetmibinfo,
+
+ .op_sysctlnametomib = sysctlnametomib,
};
Index: src/sbin/route/route_rumpops.c
diff -u src/sbin/route/route_rumpops.c:1.2 src/sbin/route/route_rumpops.c:1.3
--- src/sbin/route/route_rumpops.c:1.2 Thu Apr 2 18:32:31 2020
+++ src/sbin/route/route_rumpops.c Fri Apr 3 16:20:52 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: route_rumpops.c,v 1.2 2020/04/02 18:32:31 christos Exp $ */
+/* $NetBSD: route_rumpops.c,v 1.3 2020/04/03 16:20:52 martin Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: route_rumpops.c,v 1.2 2020/04/02 18:32:31 christos Exp $");
+__RCSID("$NetBSD: route_rumpops.c,v 1.3 2020/04/03 16:20:52 martin Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -54,7 +54,17 @@ const struct prog_ops prog_ops = {
.op_read = rump_sys_read,
.op_write = rump_sys_write,
+ .op_shutdown = rump_sys_shutdown,
+
.op_sysctl = rump_sys___sysctl,
- .op_shutdown = rump_sys_shutdown,
+ /*
+ * The following are only indirected through ops because
+ * santizers get confused otherwise.
+ */
+ .op_sysctlbyname = sysctlbyname,
+
+ .op_sysctlgetmibinfo = sysctlgetmibinfo,
+
+ .op_sysctlnametomib = sysctlnametomib,
};
Index: src/usr.bin/netstat/netstat_hostops.c
diff -u src/usr.bin/netstat/netstat_hostops.c:1.2 src/usr.bin/netstat/netstat_hostops.c:1.3
--- src/usr.bin/netstat/netstat_hostops.c:1.2 Sun Aug 18 04:14:40 2019
+++ src/usr.bin/netstat/netstat_hostops.c Fri Apr 3 16:20:51 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: netstat_hostops.c,v 1.2 2019/08/18 04:14:40 kamil Exp $ */
+/* $NetBSD: netstat_hostops.c,v 1.3 2020/04/03 16:20:51 martin Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,20 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: netstat_hostops.c,v 1.2 2019/08/18 04:14:40 kamil Exp $");
+__RCSID("$NetBSD: netstat_hostops.c,v 1.3 2020/04/03 16:20:51 martin Exp $");
#endif /* !lint */
-#include <sys/types.h>
-#include <sys/sysctl.h>
-
-#include "prog_ops.h"
-
-const struct prog_ops prog_ops = {
- .op_sysctl = sysctl,
-
- .op_sysctlbyname = sysctlbyname,
-
- .op_sysctlgetmibinfo = sysctlgetmibinfo,
-
- .op_sysctlnametomib = sysctlnametomib,
-};
+#include "../../sbin/route/route_hostops.c"
Index: src/usr.bin/netstat/netstat_rumpops.c
diff -u src/usr.bin/netstat/netstat_rumpops.c:1.2 src/usr.bin/netstat/netstat_rumpops.c:1.3
--- src/usr.bin/netstat/netstat_rumpops.c:1.2 Sun Aug 18 04:14:40 2019
+++ src/usr.bin/netstat/netstat_rumpops.c Fri Apr 3 16:20:51 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: netstat_rumpops.c,v 1.2 2019/08/18 04:14:40 kamil Exp $ */
+/* $NetBSD: netstat_rumpops.c,v 1.3 2020/04/03 16:20:51 martin Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -26,28 +26,4 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#ifndef lint
-__RCSID("$NetBSD: netstat_rumpops.c,v 1.2 2019/08/18 04:14:40 kamil Exp $");
-#endif /* !lint */
-
-#include <sys/types.h>
-#include <sys/sysctl.h>
-
-#include <rump/rump.h>
-#include <rump/rumpclient.h>
-#include <rump/rump_syscalls.h>
-
-#include "prog_ops.h"
-
-const struct prog_ops prog_ops = {
- .op_init = rumpclient_init,
-
- .op_sysctl = rump_sys___sysctl,
-
- .op_sysctlbyname = sysctlbyname,
-
- .op_sysctlgetmibinfo = sysctlgetmibinfo,
-
- .op_sysctlnametomib = sysctlnametomib,
-};
+#include "../../sbin/route/route_rumpops.c"
Index: src/usr.bin/netstat/prog_ops.h
diff -u src/usr.bin/netstat/prog_ops.h:1.3 src/usr.bin/netstat/prog_ops.h:1.4
--- src/usr.bin/netstat/prog_ops.h:1.3 Sun Aug 18 04:14:40 2019
+++ src/usr.bin/netstat/prog_ops.h Fri Apr 3 16:20:51 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: prog_ops.h,v 1.3 2019/08/18 04:14:40 kamil Exp $ */
+/* $NetBSD: prog_ops.h,v 1.4 2020/04/03 16:20:51 martin Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -26,43 +26,5 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _PROG_OPS_H_
-#define _PROG_OPS_H_
-#include <sys/types.h>
-
-#ifndef CRUNCHOPS
-struct sysctlnode;
-
-struct prog_ops {
- int (*op_init)(void);
-
- int (*op_sysctl)(const int *, u_int, void *, size_t *,
- const void *, size_t);
-
- /* Indirection needed for sanitizers. */
-
- int (*op_sysctlbyname)(const char *, void *, size_t *,
- const void *, size_t);
-
- int (*op_sysctlgetmibinfo)(const char *, int *, u_int *,
- char *, size_t *, struct sysctlnode **, int);
-
- int (*op_sysctlnametomib)(const char *, int *, size_t *);
-};
-extern const struct prog_ops prog_ops;
-
-#define prog_init prog_ops.op_init
-#define prog_sysctl prog_ops.op_sysctl
-#define prog_sysctlbyname prog_ops.op_sysctlbyname
-#define prog_sysctlgetmibinfo prog_ops.op_sysctlgetmibinfo
-#define prog_sysctlnametomib prog_ops.op_sysctlnametomib
-#else
-#define prog_init ((int (*)(void))NULL)
-#define prog_sysctl sysctl
-#define prog_sysctlbyname sysctlbyname
-#define prog_sysctlgetmibinfo sysctlgetmibinfo
-#define prog_sysctlnametomib sysctlnametomib
-#endif
-
-#endif /* _PROG_OPS_H_ */
+#include "../../sbin/route/prog_ops.h"