Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Dec 2011 02:07:07 +0900
From:      Hajimu UMEMOTO <ume@mahoroba.org>
To:        "Daniel O'Connor" <doconnor@gsoft.com.au>
Cc:        freebsd-net@freebsd.org
Subject:   Re: FreeBSD 8 as an IPv6 router
Message-ID:  <yge39co5rk4.wl%ume@mahoroba.org>
In-Reply-To: <58FFF22D-6578-447D-AAC0-9673057DAD84@gsoft.com.au>
References:  <2CECE1B6-98B6-4219-BDD7-220F83CAEC36@gsoft.com.au> <ygeaa6w25vy.wl%ume@mahoroba.org> <4F9821A6-673B-4DE6-A543-5F37BDD3F9B7@gsoft.com.au> <yge8vmg259x.wl%ume@mahoroba.org> <58FFF22D-6578-447D-AAC0-9673057DAD84@gsoft.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
--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" <doconnor@gsoft.com.au> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?yge39co5rk4.wl%ume>