Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Make route and netstat share the same struct progops (and in...
details: https://anonhg.NetBSD.org/src/rev/daef8552e61f
branches: trunk
changeset: 970752:daef8552e61f
user: martin <martin%NetBSD.org@localhost>
date: Fri Apr 03 16:20:51 2020 +0000
description:
Make route and netstat share the same struct progops (and initialization
code)
diffstat:
sbin/route/prog_ops.h | 31 ++++++++++++++++++++++++----
sbin/route/route_hostops.c | 12 ++++++++--
sbin/route/route_rumpops.c | 16 ++++++++++++--
usr.bin/netstat/netstat_hostops.c | 19 ++--------------
usr.bin/netstat/netstat_rumpops.c | 28 +------------------------
usr.bin/netstat/prog_ops.h | 42 +-------------------------------------
6 files changed, 55 insertions(+), 93 deletions(-)
diffs (269 lines):
diff -r f49da3b9919e -r daef8552e61f sbin/route/prog_ops.h
--- a/sbin/route/prog_ops.h Fri Apr 03 16:13:32 2020 +0000
+++ b/sbin/route/prog_ops.h Fri Apr 03 16:20:51 2020 +0000
@@ -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 @@
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 @@
#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 @@
#define prog_read read
#define prog_write write
+#define prog_shutdown shutdown
+
#define prog_sysctl sysctl
-#define prog_shutdown shutdown
+#define prog_sysctlbyname sysctlbyname
+#define prog_sysctlgetmibinfo sysctlgetmibinfo
+#define prog_sysctlnametomib sysctlnametomib
+
#endif
#endif /* _PROG_OPS_H_ */
diff -r f49da3b9919e -r daef8552e61f sbin/route/route_hostops.c
--- a/sbin/route/route_hostops.c Fri Apr 03 16:13:32 2020 +0000
+++ b/sbin/route/route_hostops.c Fri Apr 03 16:20:51 2020 +0000
@@ -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 @@
.op_read = read,
.op_write = write,
+ .op_shutdown = shutdown,
+
.op_sysctl = sysctl,
- .op_shutdown = shutdown,
+ .op_sysctlbyname = sysctlbyname,
+
+ .op_sysctlgetmibinfo = sysctlgetmibinfo,
+
+ .op_sysctlnametomib = sysctlnametomib,
};
diff -r f49da3b9919e -r daef8552e61f sbin/route/route_rumpops.c
--- a/sbin/route/route_rumpops.c Fri Apr 03 16:13:32 2020 +0000
+++ b/sbin/route/route_rumpops.c Fri Apr 03 16:20:51 2020 +0000
@@ -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 @@
.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,
};
diff -r f49da3b9919e -r daef8552e61f usr.bin/netstat/netstat_hostops.c
--- a/usr.bin/netstat/netstat_hostops.c Fri Apr 03 16:13:32 2020 +0000
+++ b/usr.bin/netstat/netstat_hostops.c Fri Apr 03 16:20:51 2020 +0000
@@ -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"
diff -r f49da3b9919e -r daef8552e61f usr.bin/netstat/netstat_rumpops.c
--- a/usr.bin/netstat/netstat_rumpops.c Fri Apr 03 16:13:32 2020 +0000
+++ b/usr.bin/netstat/netstat_rumpops.c Fri Apr 03 16:20:51 2020 +0000
@@ -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"
diff -r f49da3b9919e -r daef8552e61f usr.bin/netstat/prog_ops.h
--- a/usr.bin/netstat/prog_ops.h Fri Apr 03 16:13:32 2020 +0000
+++ b/usr.bin/netstat/prog_ops.h Fri Apr 03 16:20:51 2020 +0000
@@ -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"
Home |
Main Index |
Thread Index |
Old Index