tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: IPv6 socket behaviour different to IPv4?


On 01/06/2014 9:20, Darren Reed wrote:
I'm trying to get the IPFilter test suite up and running on NetBSD
and I've come to my first hurdle.

netbsd ~/ipf-test-suite# wget -O /dev/null
--2014-06-01 17:43:55--
           => '/dev/null'
Connecting to connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /pub ... done.
==> SIZE test_data.txt ... 68
==> PASV ... done.    ==> RETR test_data.txt ... done.
Length: 68 (unauthoritative)

68          --.-K/s   in 0s

2014-06-01 17:43:56 (3.89 MB/s) - '/dev/null' saved [68]

netbsd ~/ipf-test-suite# wget -O /dev/null
--2014-06-01 17:44:23--  ftp://[192:168:200::2]//pub/test_data.txt
           => '/dev/null'
Connecting to [192:168:200::2]:21... failed: Can't assign requested address.

What actually gets tried?

  3354      1 wget     write(0x2, 0xffffffffffffaf70, 0x5d) = 93
       "--2014-06-01 17:45:48--
ftp://[192:168:200::2]//pub/test_data.txt\n  (try: 2) => '/dev/null"
  3354      1 wget     write(0x2, 0xffffffffffffab20, 0x25) = 37
       "Connecting to [192:168:200::2]:21... "
  3354      1 wget     __socket30(0x18, 0x1, 0)    = 4
  3354      1 wget     connect(0x4, 0xffffffffffffada0, 0x1c) Err#49
  3354      1 wget     close(0x4)                  = 0

so it presumably gets an IPv6 socket but that then connect fails because
the network interface is down?

        address: 08:00:20:b6:cd:99
        media: Ethernet autoselect (none)
        status: no carrier
        inet netmask 0xffffff00 broadcast
inet6 fe80::a00:20ff:feb6:cd99%hme0 prefixlen 64 detached scopeid 0x2
        inet6 192:168:200::2 prefixlen 48 detached

So the "IN6_IFF_DETACHED" flag is set from usr/src/sys/netinet/in6.c here:
        if (ifp->if_link_state == LINK_STATE_DOWN) {
                ia->ia6_flags |= IN6_IFF_DETACHED;

Which means that the kernel never finds an active address to use when
it calls in6_ifawithifp().

Should the behaviour of the kernel be changed such that it behaves the
same way for IPv6 sockets connecting to IP addresses on network intefaces
that are down as it does for IPv4 sockets?

Or should the IPv4 behaviour be changed?

Or just leave it as it is?

This is a good question!
Traditionally userland manages every IPv4 address whereas the kernel manages linklocal IPv6 addresses and maybe a few other types as well. Because of this, there is the need to manage network changes for these addresses and this is what you are seeing.
I have no opinion on the correct behavior re your socket query though.


Home | Main Index | Thread Index | Old Index