[Bug 279881] socket support for IPv4-mapped IPv6 misbehave
Date: Thu, 20 Jun 2024 16:30:32 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279881 Bug ID: 279881 Summary: socket support for IPv4-mapped IPv6 misbehave Product: Base System Version: 14.1-STABLE Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: zonyitoo@gmail.com When using IPv4-mapped IPv6 address with socket, no matter sysctl net.inet6.ip6.v6only was set to 0 or 1, operations will always success. Here is a test program in Python: import socket s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM, 0) s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0) s.connect(('::ffff:169.254.1.1', 53)) print(s.getsockname()) 1. No matter net.inet6.ip6.v6only was set to 0 or 1, the program above will always run without any errors. 2. No matter net.inet6.ip6.v6only was set to 0 or 1, delete the call setsockopt(IPV6_V6ONLY) will always run without any errors. (UNEXPECTED) 3. If changed the set(IPV6_V6ONLY) line to 1, then the connect() call will fail with an EINVAL error. (EXPECTED) Based on my experience on Linux, if sockopt IPV6_V6ONLY was not set explicitly, it should derived from the system's global configuration, in FreeBSD it should be net.inet6.ip6.v6only. Here is another problem, which I think it should be a special design in FreeBSD: If net.inet6.ip6.v6only was set to 1, even the problem like above could run without error, and then send packets to the target address (IPv4-mapped IPv6) with sendto(), the target socket couldn't receive the packet from recvfrom(). I suspected that it is because net.inet6.ip6.v6only=1 disables routing IPv4-mapped IPv6 to IPv4 target. Overall, in this issue I want to suggest: 1. sockopt IPV6_V6ONLY default value should derive from net.inet6.ip6.v6only 2. If sockopt IPV6_V6ONLY was set to 0 explicitly, then IPv4-mapped IPv6 packets send from or receive by this socket should be allowed / properly routed. -- You are receiving this mail because: You are the assignee for the bug.