svn commit: r225150 - user/hrs/ipv6/usr.sbin/rtsold

Hiroki Sato hrs at FreeBSD.org
Wed Aug 24 19:01:38 UTC 2011


Author: hrs
Date: Wed Aug 24 19:01:37 2011
New Revision: 225150
URL: http://svn.freebsd.org/changeset/base/225150

Log:
  Fix -F flag handling to support receiving RAs even when ip6.forwarding=1.

Modified:
  user/hrs/ipv6/usr.sbin/rtsold/rtsold.c

Modified: user/hrs/ipv6/usr.sbin/rtsold/rtsold.c
==============================================================================
--- user/hrs/ipv6/usr.sbin/rtsold/rtsold.c	Wed Aug 24 18:44:05 2011	(r225149)
+++ user/hrs/ipv6/usr.sbin/rtsold/rtsold.c	Wed Aug 24 19:01:37 2011	(r225150)
@@ -225,6 +225,7 @@ main(int argc, char **argv)
 	srandom((u_long)time(NULL));
 #endif
 
+#if (__FreeBSD_version < 900000)
 	if (Fflag) {
 		setinet6sysctl(IPV6CTL_FORWARDING, 0);
 	} else {
@@ -232,6 +233,7 @@ main(int argc, char **argv)
 		if (getinet6sysctl(IPV6CTL_FORWARDING))
 			warnx("kernel is configured as a router, not a host");
 	}
+#endif
 
 #ifndef SMALL
 	/* initialization to dump internal status to a file */
@@ -411,6 +413,32 @@ ifconfig(char *ifname)
 		return (-1);
 	}
 
+	if (Fflag) {
+		struct in6_ndireq nd;
+		int s;
+
+		if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
+			warnmsg(LOG_ERR, __func__, "socket() failed.");
+			return (-1);
+		}
+		memset(&nd, 0, sizeof(nd));
+		strlcpy(nd.ifname, ifname, sizeof(nd.ifname));
+		if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&nd) < 0) {
+			warnmsg(LOG_ERR, __func__,
+			    "cannot get accept_rtadv flag");
+			close(s);
+			return (-1);
+		}
+		nd.ndi.flags |= ND6_IFF_ACCEPT_RTADV;
+		if (ioctl(s, SIOCSIFINFO_IN6, (caddr_t)&nd) < 0) {
+			warnmsg(LOG_ERR, __func__,
+			    "cannot set accept_rtadv flag");
+			close(s);
+			return (-1);
+		}
+		close(s);
+	}
+
 	if ((ifi = malloc(sizeof(*ifi))) == NULL) {
 		warnmsg(LOG_ERR, __func__, "memory allocation failed");
 		free(sdl);


More information about the svn-src-user mailing list