The -d flag should be a no-op in monitor mode since it does not modify
the routing table.
However, if -d is provided route monitor lists all interfaces and
their associated addresses and exits. This is confusing, unexpected
and no longer needed (if ever).
Make -d a proper no-op for route monitor and get rid of the interfaces
function which didn't use the correct sysctl idiom anyway.
OK?
diff --git route.c route.c
index 85e76621dd3..738de3a8cde 100644
--- route.c
+++ route.c
@@ -115,7 +115,6 @@ int rtmsg(int, int, int, uint8_t);
__dead void usage(char *);
void set_metric(char *, int);
void inet_makenetandmask(u_int32_t, struct sockaddr_in *, int);
-void interfaces(void);
void getlabel(char *);
int gettable(const char *);
int rdomain(int, char **);
@@ -1069,36 +1068,6 @@ prefixlen(int af, char *s)
return (len == max);
}
-void
-interfaces(void)
-{
- size_t needed;
- int mib[6];
- char *buf = NULL, *lim, *next;
- struct rt_msghdr *rtm;
-
- mib[0] = CTL_NET;
- mib[1] = PF_ROUTE;
- mib[2] = 0; /* protocol */
- mib[3] = 0; /* wildcard address family */
- mib[4] = NET_RT_IFLIST;
- mib[5] = 0; /* no flags */
- if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
- err(1, "route-sysctl-estimate");
- if (needed) {
- if ((buf = malloc(needed)) == NULL)
- err(1, "malloc");
- if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
- err(1, "actual retrieval of interface table");
- lim = buf + needed;
- for (next = buf; next < lim; next += rtm->rtm_msglen) {
- rtm = (struct rt_msghdr *)next;
- print_rtmsg(rtm, rtm->rtm_msglen);
- }
- free(buf);
- }
-}
-
void
monitor(int argc, char *argv[])
{
@@ -1107,10 +1076,6 @@ monitor(int argc, char *argv[])
time_t now;
verbose = 1;
- if (debugonly) {
- interfaces();
- exit(0);
- }
for (;;) {
if ((n = read(s, msg, sizeof(msg))) == -1) {
if (errno == EINTR)
--
I'm not entirely sure you are real.