Add compat.linux.ignore_ip_recverr sysctl. This is a workaround

for missing IP_RECVERR setsockopt(2) support. Without it, DNS
resolution is broken for glibc >= 2.30 (glibc BZ #24047).

From the user point of view this fixes "yum update" on recent
CentOS 8.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23234
This commit is contained in:
Edward Tomasz Napierala 2020-01-28 13:51:53 +00:00
parent 882f88ff77
commit da6d8ae6d8
4 changed files with 15 additions and 0 deletions

View File

@ -62,6 +62,10 @@ static unsigned linux_osd_jail_slot;
SYSCTL_NODE(_compat, OID_AUTO, linux, CTLFLAG_RW, 0, "Linux mode");
int linux_ignore_ip_recverr = 1;
SYSCTL_INT(_compat_linux, OID_AUTO, ignore_ip_recverr, CTLFLAG_RWTUN,
&linux_ignore_ip_recverr, 0, "Ignore enabling IP_RECVERR");
int linux_preserve_vstatus = 0;
SYSCTL_INT(_compat_linux, OID_AUTO, preserve_vstatus, CTLFLAG_RWTUN,
&linux_preserve_vstatus, 0, "Preserve VSTATUS termios(4) flag");

View File

@ -62,6 +62,7 @@ int linux_kernver(struct thread *td);
#define linux_use26(t) (linux_kernver(t) >= LINUX_KERNVER_2006000)
extern int linux_ignore_ip_recverr;
extern int linux_preserve_vstatus;
#endif /* _LINUX_MIB_H_ */

View File

@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
#endif
#include <compat/linux/linux_common.h>
#include <compat/linux/linux_file.h>
#include <compat/linux/linux_mib.h>
#include <compat/linux/linux_socket.h>
#include <compat/linux/linux_timer.h>
#include <compat/linux/linux_util.h>
@ -1424,6 +1425,14 @@ linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args)
}
break;
case IPPROTO_IP:
if (args->optname == LINUX_IP_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_ip_sockopt(args->optname);
break;
case IPPROTO_IPV6:

View File

@ -202,6 +202,7 @@ int linux_accept(struct thread *td, struct linux_accept_args *args);
#define LINUX_IP_TTL 2
#define LINUX_IP_HDRINCL 3
#define LINUX_IP_OPTIONS 4
#define LINUX_IP_RECVERR 11
#define LINUX_IP_MULTICAST_IF 32
#define LINUX_IP_MULTICAST_TTL 33