path: root/sbin/dumpon
diff options
authorMark Johnston <markj@FreeBSD.org>2018-11-18 01:58:48 +0000
committerMark Johnston <markj@FreeBSD.org>2018-11-18 01:58:48 +0000
commite5fff57dd0be501d614840abc7b72700e4641206 (patch)
treee4b86927339123d5fa89154230f653bfdea7af9a /sbin/dumpon
parent92e78c1012f2933b032822840b13ff43dad5fcd4 (diff)
Change dumpon(8)'s handling of -g.
Rather than using a special value to denote "use the default router", treat the absence of the -g option to mean the same thing. The in-kernel netdump client will always attempt to reach the server directly before falling back to the configured gateway anyway. This change makes it cleaner to support a hostname value for -g. Reviewed by: cem MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D18025
Notes: svn path=/head/; revision=340547
Diffstat (limited to 'sbin/dumpon')
2 files changed, 24 insertions, 23 deletions
diff --git a/sbin/dumpon/dumpon.8 b/sbin/dumpon/dumpon.8
index 86396f3bdcc3..1ab3c1650adc 100644
--- a/sbin/dumpon/dumpon.8
+++ b/sbin/dumpon/dumpon.8
@@ -28,7 +28,7 @@
.\" From: @(#)swapon.8 8.1 (Berkeley) 6/5/93
.\" $FreeBSD$
-.Dd October 26, 2018
+.Dd November 17, 2018
@@ -46,7 +46,7 @@
.Op Fl k Ar pubkey
.Op Fl Z
.Op Fl z
-.Op Fl g Ar gateway | Li default
+.Op Fl g Ar gateway
.Fl s Ar server
.Fl c Ar client
.Ar iface
@@ -140,21 +140,22 @@ The local IP address of the
.Xr netdump 4
.It Fl g Ar gateway
-If not specified, it is assumed that the
-.Ar server
-is on the same link as the
-.Ar client .
-If specified,
-.Ar gateway
-is the address of the first-hop router between the
+The first-hop router between
.Ar client
-and the
.Ar server .
-The special value
-.Dv Dq default
-indicates that the currently configured system default route should be used.
+If the
+.Fl g
+option is not specified and the system has a default route, the default
+router is used as the
+.Xr netdump 4
+If the
+.Fl g
+option is not specified and the system does not have a default route,
+.Ar server
+is assumed to be on the same link as
+.Ar client .
.It Fl s Ar server
The IP address of the
.Xr netdumpd 8
diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c
index 48b32184a6dc..bafeae171d0e 100644
--- a/sbin/dumpon/dumpon.c
+++ b/sbin/dumpon/dumpon.c
@@ -88,7 +88,7 @@ usage(void)
"usage: dumpon [-v] [-k <pubkey>] [-Zz] <device>\n"
" dumpon [-v] [-k <pubkey>] [-Zz]\n"
- " [-g <gateway>|default] -s <server> -c <client> <iface>\n"
+ " [-g <gateway>] -s <server> -c <client> <iface>\n"
" dumpon [-v] off\n"
" dumpon [-v] -l\n");
@@ -109,8 +109,6 @@ find_gateway(const char *ifname)
size_t sz;
int error, i, ifindex, mib[7];
- ret = NULL;
/* First look up the interface index. */
if (getifaddrs(&ifap) != 0)
err(EX_OSERR, "getifaddrs");
@@ -148,6 +146,7 @@ find_gateway(const char *ifname)
+ ret = NULL;
for (next = buf; next < buf + sz; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)(void *)next;
if (rtm->rtm_version != RTM_VERSION)
@@ -476,12 +475,13 @@ main(int argc, char *argv[])
if (inet_aton(client, &ndconf.ndc_client) == 0)
errx(EX_USAGE, "invalid client address '%s'", client);
- if (gateway == NULL)
+ gateway = find_gateway(argv[0]);
+ if (gateway == NULL) {
+ if (verbose)
+ printf("failed to look up gateway for %s\n",
+ server);
gateway = server;
- else if (strcmp(gateway, "default") == 0 &&
- (gateway = find_gateway(argv[0])) == NULL)
- errx(EX_NOHOST,
- "failed to look up next-hop router for %s", server);
+ }
if (inet_aton(gateway, &ndconf.ndc_gateway) == 0)
errx(EX_USAGE, "invalid gateway address '%s'", gateway);