diff options
author | hrs <hrs@FreeBSD.org> | 2009-09-12 22:14:58 +0000 |
---|---|---|
committer | hrs <hrs@FreeBSD.org> | 2009-09-12 22:14:58 +0000 |
commit | 4336827beb00bfaf2520b29f97e1c6db93b39b25 (patch) | |
tree | 0333d62ac2771237b7cdd4310c23e91f7dde7b02 /usr.sbin | |
parent | 46934a2853f4c79ad97f401d9afbfd0970b702aa (diff) | |
download | FreeBSD-src-4336827beb00bfaf2520b29f97e1c6db93b39b25.zip FreeBSD-src-4336827beb00bfaf2520b29f97e1c6db93b39b25.tar.gz |
Add support for ND6_IFF_IFDISABLED and ND6_IFF_ACCEPT_RTADV to
the -F flag.
MFC after: 3 days
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/rtsold/if.c | 54 | ||||
-rw-r--r-- | usr.sbin/rtsold/rtsold.8 | 6 | ||||
-rw-r--r-- | usr.sbin/rtsold/rtsold.c | 6 | ||||
-rw-r--r-- | usr.sbin/rtsold/rtsold.h | 1 |
4 files changed, 60 insertions, 7 deletions
diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c index 4b238a1..e8786ff 100644 --- a/usr.sbin/rtsold/if.c +++ b/usr.sbin/rtsold/if.c @@ -48,6 +48,7 @@ #include <netinet/icmp6.h> #include <netinet6/in6_var.h> +#include <netinet6/nd6.h> #include <stdio.h> #include <unistd.h> @@ -78,9 +79,15 @@ int interface_up(char *name) { struct ifreq ifr; + struct in6_ndireq nd; int llflag; + int s; + int error; + memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + memset(&nd, 0, sizeof(nd)); + strlcpy(nd.ifname, name, sizeof(nd.ifname)); if (ioctl(ifsock, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) { warnmsg(LOG_WARNING, __func__, "ioctl(SIOCGIFFLAGS): %s", @@ -94,9 +101,56 @@ interface_up(char *name) "ioctl(SIOCSIFFLAGS): %s", strerror(errno)); return(-1); } + if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { + warnmsg(LOG_WARNING, __func__, "socket(AF_INET6, SOCK_DGRAM): %s", + strerror(errno)); + return(-1); + } + if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&nd) < 0) { + warnmsg(LOG_WARNING, __func__, "ioctl(SIOCGIFINFO_IN6): %s", + strerror(errno)); + close(s); + return(-1); + } warnmsg(LOG_DEBUG, __func__, "checking if %s is ready...", name); + if (nd.ndi.flags & ND6_IFF_IFDISABLED) { + if (Fflag) { + nd.ndi.flags &= ~ND6_IFF_IFDISABLED; + if (ioctl(s, SIOCSIFINFO_IN6, (caddr_t)&nd)) { + warnmsg(LOG_WARNING, __func__, + "ioctl(SIOCSIFINFO_IN6): %s", + strerror(errno)); + close(s); + return(-1); + } + } else { + warnmsg(LOG_WARNING, __func__, + "%s is disabled.", name); + close(s); + return(-1); + } + } + if (!(nd.ndi.flags & ND6_IFF_ACCEPT_RTADV)) { + if (Fflag) { + nd.ndi.flags |= ND6_IFF_ACCEPT_RTADV; + if (ioctl(s, SIOCSIFINFO_IN6, (caddr_t)&nd)) { + warnmsg(LOG_WARNING, __func__, + "ioctl(SIOCSIFINFO_IN6): %s", + strerror(errno)); + close(s); + return(-1); + } + } else { + warnmsg(LOG_WARNING, __func__, + "%s does not accept Router Advertisement.", name); + close(s); + return(-1); + } + } + close(s); + llflag = get_llflag(name); if (llflag < 0) { warnmsg(LOG_WARNING, __func__, diff --git a/usr.sbin/rtsold/rtsold.8 b/usr.sbin/rtsold/rtsold.8 index 1ee932d..412054a5 100644 --- a/usr.sbin/rtsold/rtsold.8 +++ b/usr.sbin/rtsold/rtsold.8 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 17, 1998 +.Dd September 2, 2009 .Dt RTSOLD 8 .Os .\" @@ -186,7 +186,9 @@ if they are incompatible with proper operation, warning messages will be generated, but Router Solicitations will still be sent. The settings may be changed manually with -.Xr sysctl 8 . +.Xr sysctl 8 +and +.Xr ifconfig 8 . .It Fl m Enable mobility support. If this option is specified, diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c index f0493fbd..93fb1eb 100644 --- a/usr.sbin/rtsold/rtsold.c +++ b/usr.sbin/rtsold/rtsold.c @@ -62,8 +62,8 @@ struct ifinfo *iflist; struct timeval tm_max = {0x7fffffff, 0x7fffffff}; static int log_upto = 999; static int fflag = 0; -static int Fflag = 0; /* force setting sysctl parameters */ +int Fflag = 0; /* force setting sysctl parameters */ int aflag = 0; int dflag = 0; @@ -197,12 +197,8 @@ main(int argc, char **argv) #endif if (Fflag) { - setinet6sysctl(IPV6CTL_ACCEPT_RTADV, 1); setinet6sysctl(IPV6CTL_FORWARDING, 0); } else { - /* warn if accept_rtadv is down */ - if (!getinet6sysctl(IPV6CTL_ACCEPT_RTADV)) - warnx("kernel is configured not to accept RAs"); /* warn if forwarding is up */ if (getinet6sysctl(IPV6CTL_FORWARDING)) warnx("kernel is configured as a router, not a host"); diff --git a/usr.sbin/rtsold/rtsold.h b/usr.sbin/rtsold/rtsold.h index 88e6311..8a3cfa6 100644 --- a/usr.sbin/rtsold/rtsold.h +++ b/usr.sbin/rtsold/rtsold.h @@ -67,6 +67,7 @@ struct ifinfo { extern struct timeval tm_max; extern int dflag; extern int aflag; +extern int Fflag; extern char *otherconf_script; extern int ifconfig(char *); extern void iflist_init(void); |