(racoon2 42) Re: zero scope ID in link-local addresses

KAMADA Ken'ichi <[email protected]> Thu, 08 Dec 2005 10:04:23 +0900
Newsgroups gmane.network.ipv6.kame.racoon
Message-ID <20051208100423LS%[email protected]>
At Wed, 07 Dec 2005 13:27:52 +0100,
Francis Dupont <[email protected]> wrote:
> 
> In lib/rc_net.c getifaddrlist() the #ifdef __KAME__ is incorrect:
> this bug was fixed years ago.

s/years/months/?
It seems that the fix doesn't have merged into *BSD yet.
Is the following change ok for you?


Index: lib/rc_net.c
===================================================================
RCS file: /cvs/racoon2/racoon2/lib/rc_net.c,v
retrieving revision 1.41
diff -u -r1.41 rc_net.c
--- lib/rc_net.c	29 Sep 2005 09:41:08 -0000	1.41
+++ lib/rc_net.c	8 Dec 2005 00:36:28 -0000
@@ -395,10 +395,13 @@
 #ifdef __KAME__
 			if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
 			    IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)) {
-				sin6->sin6_scope_id =
-				    ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]);
-				sin6->sin6_addr.s6_addr[2] = 0;
-				sin6->sin6_addr.s6_addr[3] = 0;
+				int scope_id =
+				    *(u_int16_t *)&sin6->sin6_addr.s6_addr[2];
+				if (scope_id != 0) {
+					sin6->sin6_scope_id = ntohs(scope_id);
+					sin6->sin6_addr.s6_addr[2] = 0;
+					sin6->sin6_addr.s6_addr[3] = 0;
+				}
 			}
 #endif
 #ifdef HAVE_GETIFADDRS_LL_SIN6_SCOPE_ID_BUG


-- 
KAMADA Ken'ichi <[email protected]>