From owner-freebsd-net@FreeBSD.ORG Tue Dec 13 17:07:21 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC0FC106566B for ; Tue, 13 Dec 2011 17:07:21 +0000 (UTC) (envelope-from ume@mahoroba.org) Received: from mail.mahoroba.org (ent.mahoroba.org [IPv6:2001:2f0:104:8010::1]) by mx1.freebsd.org (Postfix) with ESMTP id 8F4F28FC12 for ; Tue, 13 Dec 2011 17:07:20 +0000 (UTC) Received: from yuga.mahoroba.org (ume@yuga.mahoroba.org [IPv6:2001:2f0:104:8010:7258:12ff:fe22:d94b]) (user=ume mech=DIGEST-MD5 bits=0) by mail.mahoroba.org (8.14.5/8.14.5) with ESMTP/inet6 id pBDH77Si066104 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 14 Dec 2011 02:07:12 +0900 (JST) (envelope-from ume@mahoroba.org) Date: Wed, 14 Dec 2011 02:07:07 +0900 Message-ID: From: Hajimu UMEMOTO To: "Daniel O'Connor" In-Reply-To: <58FFF22D-6578-447D-AAC0-9673057DAD84@gsoft.com.au> References: <2CECE1B6-98B6-4219-BDD7-220F83CAEC36@gsoft.com.au> <4F9821A6-673B-4DE6-A543-5F37BDD3F9B7@gsoft.com.au> <58FFF22D-6578-447D-AAC0-9673057DAD84@gsoft.com.au> User-Agent: xcite1.60> Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?ISO-2022-JP-2?B?R29qGyQoRCtXGyhC?=) APEL/10.8 Emacs/23.3 (i386-portbld-freebsd9.0) MULE/6.0 (HANACHIRUSATO) X-Operating-System: FreeBSD 9.0-PRERELEASE X-PGP-Key: http://www.imasy.or.jp/~ume/publickey.asc X-PGP-Fingerprint: 1F00 0B9E 2164 70FC 6DC5 BF5F 04E9 F086 BF90 71FE Organization: Internet Mutual Aid Society, YOKOHAMA MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Wed_Dec_14_02:07:07_2011-1" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (mail.mahoroba.org [IPv6:2001:2f0:104:8010::1]); Wed, 14 Dec 2011 02:07:12 +0900 (JST) X-Virus-Scanned: clamav-milter 0.97.3 at asuka.mahoroba.org X-Virus-Status: Clean X-Spam-Status: No, score=-4.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on asuka.mahoroba.org Cc: freebsd-net@freebsd.org Subject: Re: FreeBSD 8 as an IPv6 router X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Dec 2011 17:07:21 -0000 --Multipart_Wed_Dec_14_02:07:07_2011-1 Content-Type: text/plain; charset=US-ASCII Hi, >>>>> On Tue, 13 Dec 2011 20:11:45 +1030 >>>>> "Daniel O'Connor" said: doconnor> On 13/12/2011, at 19:54, Hajimu UMEMOTO wrote: > doconnor> Is there a way to tweak it to do the right thing? > > Perhaps, sla-len should be 8. doconnor> Ahh many thanks, that seems work work. You are welcome. doconnor> Such are the risk when you copy things off the internet :) Yes, the sla-len depends on the prefixlen of the delegated prefix, and the length depends on your ISP. The DHCPv6 server announces the prefixlen, and the dhcp6c can know it. However, the dhcp6c doesn't assume that the prefixlen of the prefix-interface is 64. So, you still need to specify an appropriate sla-len value. It seems inconvenient to me. So, I applied the attached patch to calculate the sla-len automatically with the assumption that the prefix-interface is 64, personally. Sincerely, --Multipart_Wed_Dec_14_02:07:07_2011-1 Content-Type: text/x-patch; charset=US-ASCII Content-Disposition: attachment; filename="patch-sla_len" Content-Transfer-Encoding: 7bit Index: config.c diff -u -p config.c.orig config.c --- config.c.orig Sat Sep 2 17:03:33 2006 +++ config.c Thu Oct 12 11:27:39 2006 @@ -470,7 +502,7 @@ add_pd_pif(iapdc, cfl0) } pif->ifid_len = IFID_LEN_DEFAULT; - pif->sla_len = SLA_LEN_DEFAULT; + pif->sla_len = -1; if (get_default_ifid(pif)) { dprintf(LOG_NOTICE, FNAME, "failed to get default IF ID for %s", pif->ifname); @@ -483,13 +515,13 @@ add_pd_pif(iapdc, cfl0) pif->sla_id = (u_int32_t)cfl->num; break; case IFPARAM_SLA_LEN: - pif->sla_len = (int)cfl->num; - if (pif->sla_len < 0 || pif->sla_len > 128) { + if ((int)cfl->num < 0 || (int)cfl->num > 128) { dprintf(LOG_ERR, FNAME, "%s:%d " "invalid SLA length: %d", - configfilename, cfl->line, pif->sla_len); + configfilename, cfl->line, (int)cfl->num); goto bad; } + pif->sla_len = (int)cfl->num; break; default: dprintf(LOG_ERR, FNAME, "%s:%d internal error: " Index: config.h diff -u config.h.orig config.h --- config.h.orig Sun Jul 30 19:24:19 2006 +++ config.h Thu Oct 12 11:34:15 2006 @@ -174,7 +174,6 @@ char ifid[16]; /* Interface ID, up to 128bits */ }; #define IFID_LEN_DEFAULT 64 -#define SLA_LEN_DEFAULT 16 typedef enum { IATYPE_PD, IATYPE_NA } iatype_t; struct ia_conf { Index: dhcp6c.conf.5 diff -u dhcp6c.conf.5.orig dhcp6c.conf.5 --- dhcp6c.conf.5.orig Sun Jul 30 19:24:19 2006 +++ dhcp6c.conf.5 Wed Oct 11 14:48:16 2006 @@ -435,7 +458,7 @@ .Ar length must be a decimal number between 0 and 128. If the length is not specified by this statement, -the default value 16 will be used. +the value will be determined automatically. .El .El .\" Index: prefixconf.c diff -u -p prefixconf.c.orig prefixconf.c --- prefixconf.c.orig Mon Aug 7 13:35:32 2006 +++ prefixconf.c Wed Oct 11 14:48:16 2006 @@ -435,7 +459,7 @@ add_ifprefix(siteprefix, prefix, pconf) struct in6_addr *a; u_long sla_id; char *sp; - int b, i; + int b, i, sla_len; if ((ifpfx = malloc(sizeof(*ifpfx))) == NULL) { dprintf(LOG_NOTICE, FNAME, @@ -451,7 +475,11 @@ add_ifprefix(siteprefix, prefix, pconf) ifpfx->paddr.sin6_len = sizeof(struct sockaddr_in6); #endif ifpfx->paddr.sin6_addr = prefix->addr; - ifpfx->plen = prefix->plen + pconf->sla_len; + if (pconf->sla_len >= 0) + sla_len = pconf->sla_len; + else + sla_len = 128 - pconf->ifid_len - prefix->plen; + ifpfx->plen = prefix->plen + sla_len; /* * XXX: our current implementation assumes ifid len is a multiple of 8 */ @@ -464,7 +492,7 @@ add_ifprefix(siteprefix, prefix, pconf) ifpfx->plen + pconf->ifid_len > 128) { dprintf(LOG_INFO, FNAME, "invalid prefix length %d + %d + %d", - prefix->plen, pconf->sla_len, pconf->ifid_len); + prefix->plen, sla_len, pconf->ifid_len); goto bad; } @@ -476,7 +504,7 @@ add_ifprefix(siteprefix, prefix, pconf) sla_id = htonl(pconf->sla_id); sp = ((char *)&sla_id + 3); i = (128 - pconf->ifid_len) / 8; - for (b = pconf->sla_len; b > 7; b -= 8, sp--) + for (b = sla_len; b > 7; b -= 8, sp--) a->s6_addr[--i] = *sp; if (b) a->s6_addr[--i] |= *sp; --Multipart_Wed_Dec_14_02:07:07_2011-1 Content-Type: text/plain; charset=US-ASCII -- Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan ume@mahoroba.org ume@{,jp.}FreeBSD.org http://www.imasy.org/~ume/ --Multipart_Wed_Dec_14_02:07:07_2011-1--