Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Jun 2011 01:20:47 +0000 (UTC)
From:      Hiroki Sato <hrs@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r222664 - user/hrs/ipv6/usr.sbin/rtadvd
Message-ID:  <201106040120.p541KlXP087680@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hrs
Date: Sat Jun  4 01:20:47 2011
New Revision: 222664
URL: http://svn.freebsd.org/changeset/base/222664

Log:
  - Use IANA reserved example.com domain for rtadvd.conf(5).
  - Fix 8-octet boundary calculation.  Extra 8 octets were added when it was
    already on an 8-octet boundary.
  - Typos and style(9) fixes.
  
  Submitted by:	bz

Modified:
  user/hrs/ipv6/usr.sbin/rtadvd/config.c
  user/hrs/ipv6/usr.sbin/rtadvd/dump.c
  user/hrs/ipv6/usr.sbin/rtadvd/rrenum.c
  user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c
  user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.conf
  user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.conf.5
  user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h

Modified: user/hrs/ipv6/usr.sbin/rtadvd/config.c
==============================================================================
--- user/hrs/ipv6/usr.sbin/rtadvd/config.c	Sat Jun  4 01:13:09 2011	(r222663)
+++ user/hrs/ipv6/usr.sbin/rtadvd/config.c	Sat Jun  4 01:20:47 2011	(r222664)
@@ -102,7 +102,7 @@ dname_labelenc(char *dst, const char *sr
 			*dst++ = len = MIN(63, len);
 		else
 			*dst++ = len = MIN(63, p - src);
-		/* Copy only 63 octets at most. */
+		/* Copy 63 octets at most. */
 		memcpy(dst, src, len);
 		dst += len;
 		if (p == NULL) /* the last label */
@@ -1111,7 +1111,7 @@ make_packet(struct rainfo *rainfo)
 
 		/* A zero octet and 8 octet boundary */
 		len++;
-		len += 8 - (len % 8);
+		len += (len % 8) ? 8 - len % 8 : 0;
 
 		packlen += len;
 	}
@@ -1275,7 +1275,7 @@ make_packet(struct rainfo *rainfo)
 
 		/* Padding to next 8 octets boundary */
 		len = buf - (char *)ndopt_dnssl;
-		len += 8 - (len % 8);
+		len += (len % 8) ? 8 - len % 8 : 0;
 
 		/* Length field must be in 8 octets */
 		ndopt_dnssl->nd_opt_dnssl_len = len / 8;

Modified: user/hrs/ipv6/usr.sbin/rtadvd/dump.c
==============================================================================
--- user/hrs/ipv6/usr.sbin/rtadvd/dump.c	Sat Jun  4 01:13:09 2011	(r222663)
+++ user/hrs/ipv6/usr.sbin/rtadvd/dump.c	Sat Jun  4 01:20:47 2011	(r222664)
@@ -240,7 +240,7 @@ if_dump(void)
 				fprintf(fp, "  Recursive DNS servers:\n"
 					    "    Lifetime\tServers\n");
 
-			fprintf(fp, "    % 8u\t", rdn->rd_ltime);
+			fprintf(fp, "    %8u\t", rdn->rd_ltime);
 			TAILQ_FOREACH(rdna, &rdn->rd_list, ra_next) {
 				inet_ntop(AF_INET6, &rdna->ra_dns,
 				    prefixbuf, sizeof(prefixbuf));
@@ -260,7 +260,7 @@ if_dump(void)
 				fprintf(fp, "  DNS search list:\n"
 					    "    Lifetime\tDomains\n");
 
-			fprintf(fp, "    % 8u\t", dns->dn_ltime);
+			fprintf(fp, "    %8u\t", dns->dn_ltime);
 			TAILQ_FOREACH(dnsa, &dns->dn_list, da_next) {
 				dname_labeldec(buf, sizeof(buf), dnsa->da_dom);
 				if (dnsa != TAILQ_FIRST(&dns->dn_list))

Modified: user/hrs/ipv6/usr.sbin/rtadvd/rrenum.c
==============================================================================
--- user/hrs/ipv6/usr.sbin/rtadvd/rrenum.c	Sat Jun  4 01:13:09 2011	(r222663)
+++ user/hrs/ipv6/usr.sbin/rtadvd/rrenum.c	Sat Jun  4 01:20:47 2011	(r222664)
@@ -450,9 +450,8 @@ rr_input(int len, struct icmp6_router_re
 	 * We rely on the kernel input routine for unicast addresses, and thus
 	 * check multicast destinations only.
 	 */
-	if (IN6_IS_ADDR_MULTICAST(&pi->ipi6_addr) &&
-	    !IN6_ARE_ADDR_EQUAL(&sin6_sitelocal_allrouters.sin6_addr,
-				&pi->ipi6_addr)) {
+	if (IN6_IS_ADDR_MULTICAST(&pi->ipi6_addr) && !IN6_ARE_ADDR_EQUAL(
+	    &sin6_sitelocal_allrouters.sin6_addr, &pi->ipi6_addr)) {
 		syslog(LOG_NOTICE,
 		       "<%s>: RR message with invalid destination (%s) "
 		       "from %s on %s",

Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c
==============================================================================
--- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c	Sat Jun  4 01:13:09 2011	(r222663)
+++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c	Sat Jun  4 01:20:47 2011	(r222664)
@@ -132,16 +132,19 @@ u_int32_t ndopt_flags[] = {
 	[ND_OPT_RDNSS]			= NDOPT_FLAG_RDNSS,
 	[ND_OPT_DNSSL]			= NDOPT_FLAG_DNSSL,
 };
+
 const struct sockaddr_in6 sin6_linklocal_allnodes = {
         .sin6_len =     sizeof(sin6_linklocal_allnodes),
         .sin6_family =  AF_INET6,
         .sin6_addr =    IN6ADDR_LINKLOCAL_ALLNODES_INIT,
 };
+
 const struct sockaddr_in6 sin6_linklocal_allrouters = {
         .sin6_len =     sizeof(sin6_linklocal_allrouters),
         .sin6_family =  AF_INET6,
         .sin6_addr =    IN6ADDR_LINKLOCAL_ALLROUTERS_INIT,
 };
+
 const struct sockaddr_in6 sin6_sitelocal_allrouters = {
         .sin6_len =     sizeof(sin6_sitelocal_allrouters),
         .sin6_family =  AF_INET6,
@@ -762,7 +765,7 @@ rtadvd_input(void)
 	case ND_ROUTER_ADVERT:
 		/*
 		 * Message verification - RFC-2461 6.1.2
-		 * XXX: there's a same dilemma as above...
+		 * XXX: there's the same dilemma as above...
 		 */
 		if (*hlimp != 255) {
 			syslog(LOG_NOTICE,
@@ -1337,17 +1340,25 @@ nd6_options(struct nd_opt_hdr *hdr, int 
 		 * Option length check.  Do it here for all fixed-length
 		 * options.
 		 */
-		if ((hdr->nd_opt_type == ND_OPT_MTU &&
-			optlen != sizeof(struct nd_opt_mtu)) ||
-		    (hdr->nd_opt_type == ND_OPT_RDNSS &&
-			(optlen < 24 ||
-			(optlen - sizeof(struct nd_opt_rdnss)) % 16 != 0)) ||
-		    (hdr->nd_opt_type == ND_OPT_DNSSL &&
-			(optlen < 16 ||
-			(optlen - sizeof(struct nd_opt_dnssl)) % 8 != 0)) ||
-		    (hdr->nd_opt_type == ND_OPT_PREFIX_INFORMATION &&
-			optlen != sizeof(struct nd_opt_prefix_info))
-		) {
+		switch (hdr->nd_opt_type) {
+		case ND_OPT_MTU:
+			if (optlen == sizeof(struct nd_opt_mtu))
+				break;
+			goto skip;
+		case ND_OPT_RDNSS:
+			if (optlen >= 24 &&
+			    (optlen - sizeof(struct nd_opt_rdnss)) % 16 == 0)
+				break;
+			goto skip;
+		case ND_OPT_DNSSL:
+			if (optlen >= 16 &&
+			    (optlen - sizeof(struct nd_opt_dnssl)) % 8 == 0)
+				break;
+			goto skip;
+		case ND_OPT_PREFIX_INFORMATION:
+			if (optlen == sizeof(struct nd_opt_prefix_info))
+				break;
+skip:
 			syslog(LOG_INFO, "<%s> invalid option length",
 			    __func__);
 			continue;

Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.conf
==============================================================================
--- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.conf	Sat Jun  4 01:13:09 2011	(r222663)
+++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.conf	Sat Jun  4 01:20:47 2011	(r222664)
@@ -19,4 +19,4 @@
  
 #ef0:\
 #	:addr="2001:db8:ffff:1000::":prefixlen#64:\
-#	:rddns="2001:db8:ffff:1000::1":dnssl="foo.com":
+#	:rdnss="2001:db8:ffff:1000::1":dnssl="example.com":

Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.conf.5
==============================================================================
--- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.conf.5	Sat Jun  4 01:13:09 2011	(r222663)
+++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.conf.5	Sat Jun  4 01:20:47 2011	(r222664)
@@ -385,13 +385,14 @@ manual page for resolver implementation 
 .It Cm \&rdnssltime
 The lifetime of the
 .Cm rdnss
-DNS server entries.  The default value is 3/2 of the interval
-time.
+DNS server entries.
+The default value is 3/2 of the interval time.
 .It Cm \&dnssl
 (str) One or more domain names in a comma-separated string.
 These domain names will be used when making DNS queries on a
-non-fully-qualified domain name.  If different lifetimes are needed for
-different domains, separate entries can be given by using
+non-fully-qualified domain name.
+If different lifetimes are needed for different domains, separate entries
+can be given by using
 .Cm dnssl ,
 .Cm dnssl0 ,
 .Cm dnssl1 ,
@@ -410,8 +411,8 @@ manual page for resolver implementation 
 .It Cm \&dnsslltime
 The lifetime of the
 .Cm dnssl
-DNS search list entries.  The default value is 3/2 of the interval
-time.
+DNS search list entries.
+The default value is 3/2 of the interval time.
 .El
 .Pp
 You can also refer one line from another by using
@@ -457,8 +458,8 @@ using the default option lifetime values
 .Bd -literal -offset
 wlan0:\\
 	:addr="2001:db8:ffff:1000::":prefixlen#64:\\
-	:rdnss="2001:db8:ffff::10,2001:db8:ffff::2:43:\\
-	:dnssl="foo.com":
+	:rdnss="2001:db8:ffff::10,2001:db8:ffff::2:43":\\
+	:dnssl="example.com":
 .Ed
 .Pp
 The following example presents the default values in an explicit manner.

Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h
==============================================================================
--- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h	Sat Jun  4 01:13:09 2011	(r222663)
+++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.h	Sat Jun  4 01:20:47 2011	(r222664)
@@ -29,18 +29,23 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #define IN6ADDR_LINKLOCAL_ALLNODES_INIT				\
 	{{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	\
 	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
+
 #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT			\
 	{{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	\
 	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
+
 #define IN6ADDR_SITELOCAL_ALLROUTERS_INIT			\
 	{{{ 0xff, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	\
 	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
+
 extern const struct sockaddr_in6 sin6_linklocal_allnodes;
 extern const struct sockaddr_in6 sin6_linklocal_allrouters;
 extern const struct sockaddr_in6 sin6_sitelocal_allrouters;
+
 /*
  * RFC 3542 API deprecates IPV6_PKTINFO in favor of
  * IPV6_RECVPKTINFO
@@ -50,6 +55,7 @@ extern const struct sockaddr_in6 sin6_si
 #define IPV6_RECVPKTINFO	IPV6_PKTINFO
 #endif
 #endif
+
 /*
  * RFC 3542 API deprecates IPV6_HOPLIMIT in favor of
  * IPV6_RECVHOPLIMIT
@@ -123,6 +129,7 @@ struct rdnss_addr {
 
 	struct in6_addr ra_dns;	/* DNS server entry */
 };
+
 struct rdnss {
 	TAILQ_ENTRY(rdnss) rd_next;
 
@@ -138,6 +145,7 @@ struct rdnss {
  */
 #define _DNAME_LABELENC_MAXLEN \
 	(NI_MAXHOST + (NI_MAXHOST / 64 + 1) + 1)
+
 #define DNAME_LABELENC_MAXLEN \
 	(_DNAME_LABELENC_MAXLEN + 8 - _DNAME_LABELENC_MAXLEN % 8)
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106040120.p541KlXP087680>