diff options
author | ume <ume@FreeBSD.org> | 2010-02-02 18:38:17 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2010-02-02 18:38:17 +0000 |
commit | 8a75e0399dc0ea366e99c69d9e95b89a9929f87f (patch) | |
tree | bdd7727f0f0f16a74b90141552c3c58f3f9fd97f | |
parent | cce36e4d2f85506b677a150068e644bbb065603e (diff) | |
download | FreeBSD-src-8a75e0399dc0ea366e99c69d9e95b89a9929f87f.zip FreeBSD-src-8a75e0399dc0ea366e99c69d9e95b89a9929f87f.tar.gz |
Exclude the interfaces which IPv6 and/or accepting RA is disabled
from the auto probed interface list.
MFC after: 1 week
-rw-r--r-- | usr.sbin/rtsold/rtsold.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c index 6aee160..12c0836 100644 --- a/usr.sbin/rtsold/rtsold.c +++ b/usr.sbin/rtsold/rtsold.c @@ -32,15 +32,20 @@ */ #include <sys/types.h> +#include <sys/ioctl.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/param.h> #include <net/if.h> #include <net/if_dl.h> +#include <net/if_var.h> #include <netinet/in.h> #include <netinet/icmp6.h> +#include <netinet/in_var.h> + +#include <netinet6/nd6.h> #include <signal.h> #include <unistd.h> @@ -785,8 +790,9 @@ autoifprobe(void) static char **argv = NULL; static int n = 0; char **a; - int i, found; + int s, i, found; struct ifaddrs *ifap, *ifa, *target; + struct in6_ndireq nd; /* initialize */ while (n--) @@ -800,6 +806,11 @@ autoifprobe(void) if (getifaddrs(&ifap) != 0) return NULL; + if (!Fflag && (s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { + err(1, "socket"); + /* NOTREACHED */ + } + target = NULL; /* find an ethernet */ for (ifa = ifap; ifa; ifa = ifa->ifa_next) { @@ -825,6 +836,23 @@ autoifprobe(void) if (found) continue; + /* + * Skip the interfaces which IPv6 and/or accepting RA + * is disabled. + */ + if (!Fflag) { + memset(&nd, 0, sizeof(nd)); + strlcpy(nd.ifname, ifa->ifa_name, sizeof(nd.ifname)); + if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&nd) < 0) { + err(1, "ioctl(SIOCGIFINFO_IN6)"); + /* NOTREACHED */ + } + if ((nd.ndi.flags & ND6_IFF_IFDISABLED)) + continue; + if (!(nd.ndi.flags & ND6_IFF_ACCEPT_RTADV)) + continue; + } + /* if we find multiple candidates, just warn. */ if (n != 0 && dflag > 1) warnx("multiple interfaces found"); @@ -851,6 +879,8 @@ autoifprobe(void) warnx("probing %s", argv[i]); } } + if (!Fflag) + close(s); freeifaddrs(ifap); return argv; } |