diff --git a/usr.sbin/rtsold/Makefile b/usr.sbin/rtsold/Makefile index bc0f4be1831a..510e2dd5d48b 100644 --- a/usr.sbin/rtsold/Makefile +++ b/usr.sbin/rtsold/Makefile @@ -19,7 +19,7 @@ MAN= rtsold.8 MLINKS= rtsold.8 rtsol.8 SRCS= rtsold.c rtsol.c if.c probe.c dump.c rtsock.c -CFLAGS+= -DINET6 -DHAVE_GETIFADDRS -DHAVE_ARC4RANDOM +CFLAGS+= -DINET6 -DHAVE_ARC4RANDOM DPADD= ${LIBKVM} LDADD= -lkvm diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c index 27690ca7bab4..b1f9fd65a980 100644 --- a/usr.sbin/rtsold/if.c +++ b/usr.sbin/rtsold/if.c @@ -68,9 +68,7 @@ #include #include #include -#ifdef HAVE_GETIFADDRS #include -#endif #include "rtsold.h" @@ -78,9 +76,6 @@ extern int rssock; static int ifsock; static int get_llflag __P((const char *name)); -#ifndef HAVE_GETIFADDRS -static unsigned int if_maxindex __P((void)); -#endif static void get_rtaddrs __P((int addrs, struct sockaddr *sa, struct sockaddr **rti_info)); @@ -326,7 +321,6 @@ getinet6sysctl(int code) static int get_llflag(const char *name) { -#ifdef HAVE_GETIFADDRS struct ifaddrs *ifap, *ifa; struct in6_ifreq ifr6; struct sockaddr_in6 *sin6; @@ -370,88 +364,8 @@ get_llflag(const char *name) freeifaddrs(ifap); close(s); return -1; -#else - int s; - unsigned int maxif; - struct ifreq *iflist; - struct ifconf ifconf; - struct ifreq *ifr, *ifr_end; - struct sockaddr_in6 *sin6; - struct in6_ifreq ifr6; - - maxif = if_maxindex() + 1; - iflist = (struct ifreq *)malloc(maxif * BUFSIZ); /* XXX */ - if (iflist == NULL) { - warnmsg(LOG_ERR, __func__, "not enough core"); - exit(1); - } - - if ((s = socket(PF_INET6, SOCK_DGRAM, 0)) < 0) { - warnmsg(LOG_ERR, __func__, "socket(SOCK_DGRAM): %s", - strerror(errno)); - exit(1); - } - memset(&ifconf, 0, sizeof(ifconf)); - ifconf.ifc_req = iflist; - ifconf.ifc_len = maxif * BUFSIZ; /* XXX */ - if (ioctl(s, SIOCGIFCONF, &ifconf) < 0) { - warnmsg(LOG_ERR, __func__, "ioctl(SIOCGIFCONF): %s", - strerror(errno)); - exit(1); - } - - /* Look for this interface in the list */ - ifr_end = (struct ifreq *) (ifconf.ifc_buf + ifconf.ifc_len); - for (ifr = ifconf.ifc_req; - ifr < ifr_end; - ifr = (struct ifreq *) ((char *) &ifr->ifr_addr - + ifr->ifr_addr.sa_len)) { - if (strlen(ifr->ifr_name) != strlen(name) - || strncmp(ifr->ifr_name, name, strlen(name)) != 0) - continue; - if (ifr->ifr_addr.sa_family != AF_INET6) - continue; - sin6 = (struct sockaddr_in6 *)&ifr->ifr_addr; - if (!IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) - continue; - - memset(&ifr6, 0, sizeof(ifr6)); - strcpy(ifr6.ifr_name, name); - memcpy(&ifr6.ifr_ifru.ifru_addr, sin6, sin6->sin6_len); - if (ioctl(s, SIOCGIFAFLAG_IN6, &ifr6) < 0) { - warnmsg(LOG_ERR, __func__, - "ioctl(SIOCGIFAFLAG_IN6): %s", strerror(errno)); - exit(1); - } - - free(iflist); - close(s); - return ifr6.ifr_ifru.ifru_flags6; - } - - free(iflist); - close(s); - return -1; -#endif } -#ifndef HAVE_GETIFADDRS -static unsigned int -if_maxindex() -{ - struct if_nameindex *p, *p0; - unsigned int max = 0; - - p0 = if_nameindex(); - for (p = p0; p && p->if_index && p->if_name; p++) { - if (max < p->if_index) - max = p->if_index; - } - if_freenameindex(p0); - return max; -} -#endif - static void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) { diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c index 55b1942473a3..ca2044af1063 100644 --- a/usr.sbin/rtsold/rtsold.c +++ b/usr.sbin/rtsold/rtsold.c @@ -751,9 +751,6 @@ warnmsg(priority, func, msg, va_alist) static char ** autoifprobe() { -#ifndef HAVE_GETIFADDRS - errx(1, "-a is not available with the configuration"); -#else static char ifname[IFNAMSIZ + 1]; static char *argv[2]; struct ifaddrs *ifap, *ifa, *target; @@ -804,5 +801,4 @@ autoifprobe() return argv; else return (char **)NULL; -#endif }