Comment 6 for bug 1857811

Revision history for this message
Laurent Vivier (laurent-vivier) wrote :

I've copied the file portage-2.3.84/build/lib.linux-x86_64-3.7/portage/util/netlink.py from portage to my local directory and run the following script:

cat > rtnetlink.py <<EOF
import socket

__has_ipv6 = None

def _has_ipv6():
        """
        Test that both userland and kernel support IPv6, by attempting
        to create a socket and listen on any unused port of the IPv6
        ::1 loopback address.

        @rtype: bool
        @return: True if IPv6 is supported, False otherwise.
        """
        global __has_ipv6

        if __has_ipv6 is None:
                if socket.has_ipv6:
                        sock = None
                        try:
                                # With ipv6.disable=0 and ipv6.disable_ipv6=1, socket creation
                                # succeeds, but then the bind call fails with this error:
                                # [Errno 99] Cannot assign requested address.
                                sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
                                sock.bind(('::1', 0))
                        except EnvironmentError:
                                __has_ipv6 = False
                        else:
                                __has_ipv6 = True
                        finally:
                                # python2.7 sockets do not support context management protocol
                                if sock is not None:
                                        sock.close()
                else:
                        __has_ipv6 = False

        return __has_ipv6

def _configure_loopback_interface():
        """
        Configure the loopback interface.
        """

        from netlink import RtNetlink
        try:
                with RtNetlink() as rtnl:
                        ifindex = rtnl.get_link_ifindex(b'lo')
                        rtnl.set_link_up(ifindex)
                        rtnl.add_address(ifindex, socket.AF_INET, '10.0.0.1', 8)
                        if _has_ipv6():
                                rtnl.add_address(ifindex, socket.AF_INET6, 'fd::1', 8)
        except EnvironmentError as e:
                print("Unable to configure loopback interface: %s\n" % e.strerror)

_configure_loopback_interface()
EOF

And I have no error in an aarch64/ubunut eoan chroot.

sudo QEMU_STRACE= unshare --net chroot chroot/arm64/eoan python3 rtnetlink.py
...
675051 socket(PF_NETLINK,,NETLINK_ROUTE) = 3
675051 bind(3,{nl_family=AF_NETLINK,nl_pid=0,nl_groups=0}, 12) = 0
675051 sendto(3,274891222784,38,0,274886293096,12) = 38
...

sudo strace -yyy unshare --net chroot chroot/arm64/eoan python3 rtnetlink.py

..
socket(AF_NETLINK, SOCK_DGRAM|SOCK_CLOEXEC, NETLINK_ROUTE) = 3<NETLINK:[26260481]>
bind(3<NETLINK:[26260481]>, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 0
sendto(3<NETLINK:[26260481]>, {{len=38, type=0x12 /* NLMSG_??? */, flags=NLM_F_REQUEST, seq=1, pid=0}, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x03\x00\x6c\x6f"}, 38, 0, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 38
...

So I need to know which version you are using (qemu, kernel host).