Comment 10 for bug 369008

Revision history for this message
Craig McQueen (cmcqueen1975) wrote :

Okay I think I've found a problem with getaddrinfo() when the AF_INET6 family is specified. For example, Python's socket.getaddrinfo() provides scope ID if _all_ families are looked-up, but it returns scope ID of 0 if only IPv6 family is looked up. E.g. in Python:

>>> import socket
>>> from pprint import pprint
>>> a = socket.getaddrinfo("craig-linux.local", None)
>>> pprint(a)
[(10, 1, 6, '', ('fe80::21b:21ff:febb:73b2%eth2', 0, 0, 3)),
 (10, 2, 17, '', ('fe80::21b:21ff:febb:73b2%eth2', 0, 0, 3)),
 (10, 3, 0, '', ('fe80::21b:21ff:febb:73b2%eth2', 0, 0, 3)),
 (2, 1, 6, '', ('192.168.5.3', 0)),
 (2, 2, 17, '', ('192.168.5.3', 0)),
 (2, 3, 0, '', ('192.168.5.3', 0))]
>>> a = socket.getaddrinfo("craig-linux.local", None, socket.AF_INET6)
>>> pprint(a)
[(10, 1, 6, '', ('fe80::21b:21ff:febb:73b2', 0, 0, 0)),
 (10, 2, 17, '', ('fe80::21b:21ff:febb:73b2', 0, 0, 0)),
 (10, 3, 0, '', ('fe80::21b:21ff:febb:73b2', 0, 0, 0))]

So for some reason the scope ID is present when doing all-families look-up, but lacking in the IPv6-only family look-up.

ping6 fails because it is specifying AF_INET6.

I've got a test server listening on both IPv4 and IPv6. If I connect to it with "telnet craig-linux.local 12100" then it is able to connect successfully to the IPv6 address. But if I specify the -6 switch, "telnet -6 craig-linux.local 12100" then it fails to connect.