News for hackers. Stuff that matters.
Re:eBPF Mystery: When is IPv4 not IPv4? When it's pretending... by zzq1015 on Friday May 09, 2025 @04:40AM (#43934897)
For Linux, there's a kernel setting for that.

Just run

  sysctl -w net.ipv6.bindv6only=1
so IPv6 will not include IPv4-mapped addresses.

https://www.kernel.org/doc/Documentation/networking/ip-sysct...

Re:eBPF Mystery: When is IPv4 not IPv4? When it's pretending... by eqvinox on Friday May 09, 2025 @07:04AM (#43935504)
This affects -to my best knowledge- only bind()ing, not outgoing connect()ing. As the name implies, really.

(I should try this, not entirely sure tbh.)

It won't help you though if the resolver library gives you a ::ffff:ma.p.p.ed address (yes they can do that), then you just fail to connect…

Re:eBPF Mystery: When is IPv4 not IPv4? When it's pretending... by aaronmdjones on Friday May 09, 2025 @08:36AM (#43936054)
I did try this. connect(2) with an IPv4-mapped IPv6 address on an AF_INET6 socket with IPV6_V6ONLY set on it fails.
Re:eBPF Mystery: When is IPv4 not IPv4? When it's pretending... by eqvinox on Friday May 09, 2025 @06:44PM (#43941609)
Very good to know, Thanks for trying!
Re:eBPF Mystery: When is IPv4 not IPv4? When it's pretending... by majke on Friday May 09, 2025 @05:06AM (#43935037)
usually better to set IPV6_V6ONLY in the application itself.
Re:eBPF Mystery: When is IPv4 not IPv4? When it's pretending... by jcalvinowens on Saturday May 10, 2025 @12:15AM (#43943179)
It's important to emphasize it only changes the default behavior: unprivileged programs can still use setsockopt(..., IPPROTO_IPV6, IPV6_V6ONLY, ...) to override it. That's not a terribly uncommon thing to do, since different distros have historically used different defaults for the sysctl.