Loading nixos/modules/profiles/nix-builder-vm.nix +0 −8 Original line number Diff line number Diff line Loading @@ -111,14 +111,6 @@ in }; }; # DNS fails for QEMU user networking (SLiRP) on macOS. See: # # https://github.com/utmapp/UTM/issues/2353 # # This works around that by using a public DNS server other than the DNS # server that QEMU provides (normally 10.0.2.3) networking.nameservers = [ "8.8.8.8" ]; # The linux builder is a lightweight VM for remote building; not evaluation. nix.channel.enable = false; Loading pkgs/by-name/li/libslirp/fix-dns-for-darwin.patch 0 → 100644 +46 −0 Original line number Diff line number Diff line From 735904142f95d0500c0eae6bf763e4ad24b6b9fd Mon Sep 17 00:00:00 2001 From: Samuel Thibault <samuel.thibault@ens-lyon.org> Date: Wed, 26 Mar 2025 08:42:35 +0100 Subject: [PATCH] apple: Fix getting IPv4 DNS server address when IPv4 and IPv4 are interleaved When getting an IPv4 DNS server address, if libresolv returns IPv4 IPv6 IPv4 IPv6 (or just IPv4 and IPv6) we would still have found == 1 on the second iteration and thus take the IPv6 even if it's not the proper af. We can as well just completely ignore the non-matching af entries. Fixes #85 --- src/slirp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/slirp.c b/src/slirp.c index bccee53..62a018a 100644 --- a/src/slirp.c +++ b/src/slirp.c @@ -289,9 +289,12 @@ static int get_dns_addr_libresolv(int af, void *pdns_addr, void *cached_addr, found = 0; DEBUG_MISC("IP address of your DNS(s):"); for (int i = 0; i < count; i++) { - if (af == servers[i].sin.sin_family) { - found++; + if (af != servers[i].sin.sin_family) { + continue; } + + found++; + if (af == AF_INET) { addr = &servers[i].sin.sin_addr; } else { // af == AF_INET6 -- GitLab pkgs/by-name/li/libslirp/package.nix +6 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,12 @@ stdenv.mkDerivation rec { sha256 = "sha256-Eqdw6epFkLv4Dnw/s1pcKW0P70ApZwx/J2VkCwn50Ew="; }; patches = [ # https://gitlab.freedesktop.org/slirp/libslirp/-/commit/735904142f95d0500c0eae6bf763e4ad24b6b9fd # Vendorized due to frequent instability of the upstream repository. ./fix-dns-for-darwin.patch ]; separateDebugInfo = true; nativeBuildInputs = [ Loading Loading
nixos/modules/profiles/nix-builder-vm.nix +0 −8 Original line number Diff line number Diff line Loading @@ -111,14 +111,6 @@ in }; }; # DNS fails for QEMU user networking (SLiRP) on macOS. See: # # https://github.com/utmapp/UTM/issues/2353 # # This works around that by using a public DNS server other than the DNS # server that QEMU provides (normally 10.0.2.3) networking.nameservers = [ "8.8.8.8" ]; # The linux builder is a lightweight VM for remote building; not evaluation. nix.channel.enable = false; Loading
pkgs/by-name/li/libslirp/fix-dns-for-darwin.patch 0 → 100644 +46 −0 Original line number Diff line number Diff line From 735904142f95d0500c0eae6bf763e4ad24b6b9fd Mon Sep 17 00:00:00 2001 From: Samuel Thibault <samuel.thibault@ens-lyon.org> Date: Wed, 26 Mar 2025 08:42:35 +0100 Subject: [PATCH] apple: Fix getting IPv4 DNS server address when IPv4 and IPv4 are interleaved When getting an IPv4 DNS server address, if libresolv returns IPv4 IPv6 IPv4 IPv6 (or just IPv4 and IPv6) we would still have found == 1 on the second iteration and thus take the IPv6 even if it's not the proper af. We can as well just completely ignore the non-matching af entries. Fixes #85 --- src/slirp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/slirp.c b/src/slirp.c index bccee53..62a018a 100644 --- a/src/slirp.c +++ b/src/slirp.c @@ -289,9 +289,12 @@ static int get_dns_addr_libresolv(int af, void *pdns_addr, void *cached_addr, found = 0; DEBUG_MISC("IP address of your DNS(s):"); for (int i = 0; i < count; i++) { - if (af == servers[i].sin.sin_family) { - found++; + if (af != servers[i].sin.sin_family) { + continue; } + + found++; + if (af == AF_INET) { addr = &servers[i].sin.sin_addr; } else { // af == AF_INET6 -- GitLab
pkgs/by-name/li/libslirp/package.nix +6 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,12 @@ stdenv.mkDerivation rec { sha256 = "sha256-Eqdw6epFkLv4Dnw/s1pcKW0P70ApZwx/J2VkCwn50Ew="; }; patches = [ # https://gitlab.freedesktop.org/slirp/libslirp/-/commit/735904142f95d0500c0eae6bf763e4ad24b6b9fd # Vendorized due to frequent instability of the upstream repository. ./fix-dns-for-darwin.patch ]; separateDebugInfo = true; nativeBuildInputs = [ Loading