From owner-svn-src-all@FreeBSD.ORG Sat Sep 12 22:14:58 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9AC14106568B; Sat, 12 Sep 2009 22:14:58 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 89E928FC1A; Sat, 12 Sep 2009 22:14:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8CMEw1A098999; Sat, 12 Sep 2009 22:14:58 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8CMEw6t098994; Sat, 12 Sep 2009 22:14:58 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <200909122214.n8CMEw6t098994@svn.freebsd.org> From: Hiroki Sato Date: Sat, 12 Sep 2009 22:14:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197141 - head/usr.sbin/rtsold X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Sep 2009 22:14:58 -0000 Author: hrs Date: Sat Sep 12 22:14:58 2009 New Revision: 197141 URL: http://svn.freebsd.org/changeset/base/197141 Log: Add support for ND6_IFF_IFDISABLED and ND6_IFF_ACCEPT_RTADV to the -F flag. MFC after: 3 days Modified: head/usr.sbin/rtsold/if.c head/usr.sbin/rtsold/rtsold.8 head/usr.sbin/rtsold/rtsold.c head/usr.sbin/rtsold/rtsold.h Modified: head/usr.sbin/rtsold/if.c ============================================================================== --- head/usr.sbin/rtsold/if.c Sat Sep 12 22:14:21 2009 (r197140) +++ head/usr.sbin/rtsold/if.c Sat Sep 12 22:14:58 2009 (r197141) @@ -48,6 +48,7 @@ #include #include +#include #include #include @@ -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__, Modified: head/usr.sbin/rtsold/rtsold.8 ============================================================================== --- head/usr.sbin/rtsold/rtsold.8 Sat Sep 12 22:14:21 2009 (r197140) +++ head/usr.sbin/rtsold/rtsold.8 Sat Sep 12 22:14:58 2009 (r197141) @@ -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 ope 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, Modified: head/usr.sbin/rtsold/rtsold.c ============================================================================== --- head/usr.sbin/rtsold/rtsold.c Sat Sep 12 22:14:21 2009 (r197140) +++ head/usr.sbin/rtsold/rtsold.c Sat Sep 12 22:14:58 2009 (r197141) @@ -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"); Modified: head/usr.sbin/rtsold/rtsold.h ============================================================================== --- head/usr.sbin/rtsold/rtsold.h Sat Sep 12 22:14:21 2009 (r197140) +++ head/usr.sbin/rtsold/rtsold.h Sat Sep 12 22:14:58 2009 (r197141) @@ -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);