Package: freebsd-utils / 10.1~svn273304-1

route_list.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

When route is invoked with no arguments, fallback to "netstat -r"
to list existing routes.

Index: freebsd-utils-jessie/src/sbin/route/route.c
===================================================================
--- freebsd-utils-jessie.orig/src/sbin/route/route.c
+++ freebsd-utils-jessie/src/sbin/route/route.c
@@ -138,10 +138,19 @@ static void usage(const char *) __dead2;
 static void
 usage(const char *cp)
 {
-	if (cp != NULL)
+	if (cp != NULL) {
 		warnx("bad keyword: %s", cp);
-	errx(EX_USAGE, "usage: route [-46dnqtv] command [[modifiers] args]");
-	/* NOTREACHED */
+		errx(EX_USAGE, "usage: route [-46dnqtv] command [[modifiers] args]");
+		/* NOTREACHED */
+	} else {
+		warnx("warning: route invoked with no arguments. fallback to \"netstat -r\"\n");
+
+		/* For compatibility with the Linux version of route. */
+		char *opt = nflag ? "-n" : NULL;
+		char *netstat_args[] = { "netstat", "-r", opt, NULL };
+		execvp("netstat", netstat_args);
+		err(1, "netstat");
+	}
 }
 
 int