Summary: | accept(2): IPv4 connections fail (IPv6 connections succeed) with dual IPv4/IPv6 TCP servers | ||
---|---|---|---|
Product: | Base System | Reporter: | rec |
Component: | kern | Assignee: | freebsd-net (Nobody) <net> |
Status: | Closed Works As Intended | ||
Severity: | Affects Some People | CC: | bz, net, rscheff, tuexen |
Priority: | --- | Keywords: | needs-qa |
Version: | 12.1-RELEASE | ||
Hardware: | Any | ||
OS: | Any |
Description
rec
2020-08-10 16:55:30 UTC
I'll gladly admit to doing something stupid, but I can't see it. Seems odd that FreeBSD would have a problem here, so I have to assume I'm the one making the error. (In reply to rec from comment #1) try (as root): sysctl net.inet6.ip6.v6only=0 if your code then works you need to add ipv6_ipv4mapping="YES" into rc.conf Please report back to let us know if the issue persists or this can be closed. (In reply to rec from comment #1) Instead of changing a system wide setting you can also use the IPPROTO_IPV6-level socket option IPV6_V6ONLY to allow handling IPv4 traffic using the IPv6 socket by calling in make_listen(): int no = 0; setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, no, sizeof(int)); (In reply to Michael Tuexen from comment #3) I meant: setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &no, sizeof(no)); Just validated the suggestion from tuexen@: freebsd ~]# ./foo Trying Family=28, Socktype=1, Protocol=6 Connection from (28) ::1 Connection from (28) ::ffff:127.0.0.1 freebsd ~]# nc -6 ::1 5000 Hello ^C freebsd ~]# nc -4 127.0.0.1 5000 Hello ^C freebsd ~]# netstat -na Active Internet connections (including servers) Proto Recv-Q Send-Q Local Address Foreign Address (state) : : tcp46 0 0 *.5000 *.* LISTEN : : => works as designed (different defaults than Linux). Shall this bug be retired? |