Subject: Link-local addresses "inheritance" by gif(4)
To: None <tech-net@netbsd.org>
From: Martijn van Buul <martijnb@atlas.ipv6.stack.nl>
List: tech-net
Date: 05/08/2006 09:26:31
Hey;

Consider the following setup (Slightly summarized for brevity)

ral0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	address: 00:0c:f6:18:7f:0e
	inet6 fe80::20c:f6ff:fe18:7f0e%ral0 prefixlen 64 scopeid 0x1
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	address: 00:40:f4:ce:5b:43
	inet6 fe80::240:f4ff:fece:5b43%re0 prefixlen 64 scopeid 0x2
nfe0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	address: 00:15:f2:4d:39:d8
	inet6 fe80::215:f2ff:fe4d:39d8%nfe0 prefixlen 64 scopeid 0x3
lo0: flags=8009<UP,LOOPBACK,MULTICAST> mtu 33648
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
gif0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1280
	tunnel inet 85.145.84.197 --> 131.155.141.2
	inet6 2001:610:1108:5001::3f ->  prefixlen 64
	inet6 fe80::20c:f6ff:fe18:7f0e%gif0 ->  prefixlen 64 scopeid 0x5
gif1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1280
	tunnel inet 85.145.84.197 --> 83.160.166.71
	inet6 fe80::20c:f6ff:fe18:7f0e%gif1 ->  prefixlen 64 scopeid 0x6
gif2: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1280
	tunnel inet 85.145.84.197 --> 85.145.80.155
	inet 192.168.64.1 -> 192.168.21.1 netmask 0xffffff00
	inet6 fe80::20c:f6ff:fe18:7f0e%gif2 ->  prefixlen 64 scopeid 0x7
gif3: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1280
	tunnel inet 85.145.84.197 --> 85.145.85.61
	inet 192.168.64.1 -> 192.168.3.1 netmask 0xffffff00
	inet6 fe80::20c:f6ff:fe18:7f0e%gif3 ->  prefixlen 64 scopeid 0x8

Note how all gif-devices seem to inherit their link-local address from ral0.
I understand that, lacking a unique interface identifier on their own they
have to fallback on something else, but why ral0? What's the logic behind
the choice? 

I stumbled over this today, because gif 1 through 3 had died for IPv6. While
gif0 has an address of its own, gif1 throuh 3 don't, so I abuse the link-local
addresses for that, like this (from /etc/ifconfig.gif1):

create 
tunnel 85.145.84.197 83.160.166.71
up
!route add -inet6 2001:610:1108:5810:: -prefixlen 60 fe80::240:f4ff:fece:5b43%gif1

When I composed this, about 2 months ago, the link-local address for gif1 was
somehow different than it is now - back then, it was inherited from ex0, not
ral0. Both network cards were present at that time, the only difference 
between now and then is that I used to have an rtk0 interface as well, which
got replaced with the on-board nfe0. 

What caused this change?