tech-net archive

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

IPv6 scopeid not supported?



Hi all,
While trying to get ntp running on an IPv6 network using multicast I ran in to a bit of a problem. It looks like the sin6_scope_id field in struct sockaddr_in6 isn't used by bind(2), resulting in multicast listeners only being able to listen the first interface. This is especially troublesome if your first interface is fwip0.

Is this known, expected? I can't find a PR for anything mentioning "scope".

My sample program works just fine on Archangel which has a running interface with scopeid 0x01, and fails on Hobble, which doesn't. Note that the scopeid 0x02 is compiled in to it both times, and both machines have running interface with scopeid 0x02.

Cheers,
Lloyd

==============8<==============
#include <sys/time.h>
#include <sys/socket.h>

#include <netinet/in.h>

#include <stdio.h>

main()
{
        int errval;
        int fd;
        struct sockaddr_in6 addr;

        addr.sin6_len = sizeof addr;
        addr.sin6_family = AF_INET6;
        addr.sin6_port = htons (1230);
        addr.sin6_flowinfo = 0;
        inet_pton (AF_INET6, "ff02::101", &addr.sin6_addr);
        addr.sin6_scope_id = 2;

        fd = socket (PF_INET6, SOCK_DGRAM, 0);
        if (fd < 0)
                err (2, "socket");

        errval = bind (fd, (struct sockaddr *)&addr, sizeof addr);
        err (1, "bind");
}
==============8<==============
hobble-5.99.39$ uname -a
NetBSD hobble.must-have-coffee.gen.nz 5.99.39 NetBSD 5.99.39 (GENERIC) #0: Sun Oct 10 01:26:03 NZDT 2010 lloyd%thallid.must-have-@localhost coffee.gen.nz:/vol/scratch/build/obj.macppc/sys/arch/macppc/compile/ GENERIC macppc
hobble-5.99.39$ ifconfig -a
fwip0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        address: 00:0d:93:ff:fe:60:8c:16
gem0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        capabilities=800<TCP4CSUM_Tx>
        enabled=0
        address: 00:0d:93:60:8c:16
        media: Ethernet autoselect (100baseTX full-duplex)
        status: active
        inet 10.0.1.49 netmask 0xffffff00 broadcast 10.0.1.255
        inet6 fe80::20d:93ff:fe60:8c16%gem0 prefixlen 64 scopeid 0x2
        inet6 2002:cb61:d534:3:20d:93ff:fe60:8c16 prefixlen 64
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33192
        inet 127.0.0.1 netmask 0xff000000
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
==============8<==============
archangel-5.1_RC3$ uname -a
NetBSD archangel.must-have-coffee.gen.nz 5.1_RC3 NetBSD 5.1_RC3 (GENERIC) #0: Mon Jun 28 10:02:18 NZST 2010 lloyd%thallid.must-have-coffee.gen.nz@localhost :/vol/scratch/build5/obj.sparc64/sys/arch/sparc64/compile/GENERIC sparc64
archangel-5.1_RC3$ ifconfig -a
hme0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500 capabilities=3c00<TCP4CSUM_Rx,TCP4CSUM_Tx,UDP4CSUM_Rx,UDP4CSUM_Tx>
        enabled=3c00<TCP4CSUM_Rx,TCP4CSUM_Tx,UDP4CSUM_Rx,UDP4CSUM_Tx>
        address: 08:00:20:b0:7a:28
        media: Ethernet autoselect (100baseTX full-duplex)
        status: active
        inet 10.0.1.22 netmask 0xffffff00 broadcast 10.0.1.255
        inet6 fe80::a00:20ff:feb0:7a28%hme0 prefixlen 64 scopeid 0x1
        inet6 2002:cb61:d534:3:a00:20ff:feb0:7a28 prefixlen 64
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33136
        inet 127.0.0.1 netmask 0xff000000
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2




Home | Main Index | Thread Index | Old Index