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.
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:
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
if socket.has_ipv6:
return __has_ipv6
def _configure_ loopback_ interface( ):
"""
Configure the loopback interface.
"""
from netlink import RtNetlink
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)
print( "Unable to configure loopback interface: %s\n" % e.strerror)
try:
except EnvironmentError as e:
_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 PF_NETLINK, ,NETLINK_ ROUTE) = 3 {nl_family= AF_NETLINK, nl_pid= 0,nl_groups= 0}, 12) = 0 3,274891222784, 38,0,2748862930 96,12) = 38
...
675051 socket(
675051 bind(3,
675051 sendto(
...
sudo strace -yyy unshare --net chroot chroot/arm64/eoan python3 rtnetlink.py
.. SOCK_CLOEXEC, NETLINK_ROUTE) = 3<NETLINK: [26260481] > NETLINK: [26260481] >, {sa_family= AF_NETLINK, nl_pid=0, nl_groups= 00000000} , 12) = 0 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
socket(AF_NETLINK, SOCK_DGRAM|
bind(3<
sendto(
...
So I need to know which version you are using (qemu, kernel host).