Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Sep 2015 15:47:53 -0400
From:      Ryan Stone <rysto32@gmail.com>
To:        freebsd-net <freebsd-net@freebsd.org>
Subject:   route command will perform DNS lookup of invalid interface name
Message-ID:  <CAFMmRNxRPhGbZUCm-xtrhRWtLRXFs0qB9djGK9U6BFQvJJNr-Q@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
At $WORK, we have observed that if you attempt to add a route with the
-iface flag, but you specify an incorrect interface name, the route command
will perform a DNS lookup of the interface name.  It appears that if the
DNS lookup succeeds that it will treat the parameter to -iface as if it
were a gateway for the route and not an interface.

This appears to be a simple bug.  This patch resolves the issue for me, but
I'm a bit worried that the fallback to a DNS lookup might actually be
desired behaviour in some case.  Does anybody have any ideas?

diff --git a/sbin/route/route.c b/sbin/route/route.c
index 1bce41e..a447a45 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -1222,6 +1222,9 @@ getaddr(int idx, char *str, struct hostent **hpp, int
nrflags)
                        freeifaddrs(ifap);
                        if (sdl != NULL)
                                return(1);
+                       else
+                               errx(EX_DATAERR,
+                                   "inferface '%s' does not exist", str);
                }
                break;
        case RTAX_IFP:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFMmRNxRPhGbZUCm-xtrhRWtLRXFs0qB9djGK9U6BFQvJJNr-Q>