git: ca63710d3668 - main - linux: ignore setsockopt(IPV6_RECVERR)
Date: Tue, 23 Apr 2024 04:52:44 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=ca63710d3668cf6f3cb4faf065d8b4eeffa028ad
commit ca63710d3668cf6f3cb4faf065d8b4eeffa028ad
Author: Lexi Winter <lexi@le-Fay.ORG>
AuthorDate: 2024-04-22 21:58:11 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-04-23 04:36:34 +0000
linux: ignore setsockopt(IPV6_RECVERR)
Under Linux, the socket options IP_RECVERR and IPV6_RECVERR are used to
receive socket errors via a dedicated 'error queue' which can be
retrieved via recvmsg(). FreeBSD does not support this functionality.
For IPv4, the sysctl compat.linux.ignore_ip_recverr can be set to 1 to
silently ignore attempts to set IP_RECVERR and return success to the
application, which is wrong, but is required for (among other things)
a functional DNS client in recent versions of glibc.
Add support for ignoring IPV6_RECVERR, controlled by the same sysctl.
This fixes DNS in Linux when using IPv6 resolvers.
Reviewed by: imp, Jose Luis Duran
Pull Request: https://github.com/freebsd/freebsd-src/pull/1118
---
sys/compat/linux/linux_socket.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index 1e578982fced..36cffc979802 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -501,6 +501,11 @@ linux_to_bsd_ip6_sockopt(int opt)
"unsupported IPv6 socket option IPV6_RECVFRAGSIZE (%d)",
opt);
return (-2);
+ case LINUX_IPV6_RECVERR:
+ LINUX_RATELIMIT_MSG_OPT1(
+ "unsupported IPv6 socket option IPV6_RECVERR (%d), you can not get extended reliability info in linux programs",
+ opt);
+ return (-2);
/* unknown sockopts */
default:
@@ -2112,6 +2117,14 @@ linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args)
name = linux_to_bsd_ip_sockopt(args->optname);
break;
case IPPROTO_IPV6:
+ if (args->optname == LINUX_IPV6_RECVERR &&
+ linux_ignore_ip_recverr) {
+ /*
+ * XXX: This is a hack to unbreak DNS resolution
+ * with glibc 2.30 and above.
+ */
+ return (0);
+ }
name = linux_to_bsd_ip6_sockopt(args->optname);
break;
case IPPROTO_TCP: