tech-net archive

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

bind() to IPv6 link-local multicast group gives EADDRNOTAVAIL



Hi all,

I'm trying to troubleshoot an IPv6 multicast problem I'm experiencing on
NetBSD 6.1_STABLE.  When I run the following Python (2.6 or 2.7) script:

    import socket
    ip = 'ff02::101%re1' # replace re1 with the name of your interface
    port = 8123
    a = socket.getaddrinfo(ip, port, 0, socket.SOCK_DGRAM)[0]
    s = socket.socket(*a[0:3])
    addr = a[4]
    #addr = ('::',) + a[4][1:]
    s.bind(addr)

I get the following error:

    Traceback (most recent call last):
      File "./minimal.py", line 8, in <module>
        s.bind(addr)
      File "<string>", line 1, in bind
    socket.error: [Errno 49] Can't assign requested address

Note that errno 49 is EADDRNOTAVAIL.  I'm guessing (but haven't
verified) that the EADDRNOTAVAIL comes from in6_pcbbind_addr() at
src/sys/netinet6/in6_pcb.c line 246, due to ifa_ifwithaddr() returning
NULL (of course that would return NULL -- no interface has the multicast
IPv6 address assigned to it).

The same script works on Linux as expected.  A similar program written
in C behaves like the Python script.

If I uncomment the commented line (line 7), there is no exception.
However, if I then join the multicast group (IPV6_JOIN_GROUP sockopt)
and call recvfrom(), I get all packets received by the system that were
sent to UDP port 8123, not just packets sent to the ff02::101%re1
multicast group.

It seems to me like in6_pcbbind_addr() should have another 'else if'
condition before line 241:

    } else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) {
        ...

Or am I doing something wrong?

Thanks,
Richard


Home | Main Index | Thread Index | Old Index