From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=fail (p=none dis=none) header.from=gmail.com Received: from mail-dy1-x1335.google.com (mail-dy1-x1335.google.com [IPv6:2607:f8b0:4864:20::1335]) by passt.top (Postfix) with ESMTPS id 2D4145A0272 for ; Fri, 04 Dec 2026 08:31:33 +0100 (CET) Received: by mail-dy1-x1335.google.com with SMTP id 5a478bee46e88-387504e1934so675349eec.1 for ; Thu, 03 Dec 2026 23:31:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796369492; x=1796974292; darn=passt.top; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Iy6o5bdskqzboZIDBBS7kbX9tLCyV+ZaRKhvPZIeE3I=; b=dGo2LLr0he5k7VoUxpunq3rPc+r8aMu33SVNKUsymyiYXMtEuIvGeFHhy3wpWVA8lC 6BPZRPU76RhPYJFh3Eff1aSwTbEYM4Xns8UfjB3qujwNu/I9R3HZ4Ofc3rZovZbmLoFa aZlhnUv81KwZHHO842fBQW++bVm0YZX/2QcItFfxQd8U89Epx/cOCS8jKdg37z5Sl6W+ m9nodIQ+5cu0oMmO0cSkMq0I7F366thofXL9P2olgXndch7clGoAaISz0a+o4YaN48Ut Ew12KFkgEU+CdPM8BzGjnD5/mnl4RyyyoTD+KKp3iYI/F8GxEwVa3dMB+uuHfbL5WP+0 PRQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796369492; x=1796974292; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Iy6o5bdskqzboZIDBBS7kbX9tLCyV+ZaRKhvPZIeE3I=; b=sRQJLtzmKJmwA/vnjhMkXLQs47pPl7d0GatwW6Tx/yavnVl3MY8K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i3i4vvzLKBhepU04doEoSTlikwruF0uAf4QYVAUkIms 5KQUZTTWTzpcvCt+lL6JGVULuRUCC46ptNpC3LnQ2hhjCflFHran2JhKQ9/P7zEkQ9lzHCZM= X-Received: by 2002:a05:7300:599a:b0:387:4c40:b7a0 with SMTP id 5a478bee46e88-3875212ba58mr1247971eec.14.1796369491414; Thu, 03 Dec 2026 23:31:31 -0800 (PST) Received: from localhost ([2401:4900:ac83:740:c496:868c:8c47:7d5]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875218c6a6sm4946702eec.5.2026.12.03.23.31.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Dec 2026 23:31:31 -0800 (PST) From: Aditya Merchant To: passt-dev@passt.top Subject: [PATCH 2/3] conf: Forget host nameserver once it's removed from resolv.conf Date: Fri, 4 Dec 2026 13:01:18 +0530 Message-ID: <20261204073119.31027-3-adityamerchant08@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20261204073119.31027-1-adityamerchant08@gmail.com> References: <20261204073119.31027-1-adityamerchant08@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MailFrom: adityamerchant08@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation Message-ID-Hash: NRMIZFZ3LZ46Q7Q43YTXAPDZZOENVDBL X-Message-ID-Hash: NRMIZFZ3LZ46Q7Q43YTXAPDZZOENVDBL X-Mailman-Approved-At: Fri, 04 Dec 2026 08:54:10 +0100 CC: Stefano Brivio , David Gibson , Paul Holzinger , Laurent Vivier X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: When we follow changes to resolv.conf, and it doesn't list a nameserver for an IP version anymore, conf_resolv_update() keeps the one we had before, and we keep redirecting DNS queries to it. That's not what we do at start-up, where get_dns() leaves .dns_host unspecified if there's no nameserver for that IP version, and it's probably not what users expect either: a nameserver might have been removed for a reason. Clear .dns_host in that case, so that we stop redirecting DNS queries for that IP version, until a nameserver is listed again. Extend the dns_host_follow test to check this. As that takes a few more steps, keep pasta running until a file shows up, instead of for a fixed time, which could end before the last step. Suggested-by: Stefano Brivio Link: https://archives.passt.top/passt-dev/20261130013439.0a40738a@elisabeth/ Signed-off-by: Aditya Merchant --- conf.c | 14 ++++++++++++++ test/pasta_options/dns_host_follow | 10 ++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/conf.c b/conf.c index d3976d3..7a271ff 100644 --- a/conf.c +++ b/conf.c @@ -352,11 +352,20 @@ static int conf_resolv_update(struct ctx *c) } close(fd); + /* If resolv.conf doesn't list a nameserver for an IP version anymore, + * forget the one we had, as if we started now: we don't redirect DNS + * queries for that IP version until a nameserver shows up again + */ if (c->ip4.dns_host_resolv && found4 && !IN4_ARE_ADDR_EQUAL(&ns4, &c->ip4.dns_host)) { c->ip4.dns_host = ns4; info("Forwarding DNS queries to new host nameserver %s", inet_ntop(AF_INET, &ns4, addr, sizeof(addr))); + } else if (c->ip4.dns_host_resolv && !found4 && + !IN4_IS_ADDR_UNSPECIFIED(&c->ip4.dns_host)) { + info("Stopped forwarding DNS queries to removed nameserver %s", + inet_ntop(AF_INET, &c->ip4.dns_host, addr, sizeof(addr))); + c->ip4.dns_host = in4addr_any; } if (c->ip6.dns_host_resolv && found6 && @@ -364,6 +373,11 @@ static int conf_resolv_update(struct ctx *c) c->ip6.dns_host = ns6; info("Forwarding DNS queries to new host nameserver %s", inet_ntop(AF_INET6, &ns6, addr, sizeof(addr))); + } else if (c->ip6.dns_host_resolv && !found6 && + !IN6_IS_ADDR_UNSPECIFIED(&c->ip6.dns_host)) { + info("Stopped forwarding DNS queries to removed nameserver %s", + inet_ntop(AF_INET6, &c->ip6.dns_host, addr, sizeof(addr))); + c->ip6.dns_host = in6addr_any; } return 0; diff --git a/test/pasta_options/dns_host_follow b/test/pasta_options/dns_host_follow index 2d7ac6d..d8cc232 100644 --- a/test/pasta_options/dns_host_follow +++ b/test/pasta_options/dns_host_follow @@ -13,16 +13,22 @@ htools unshare mount grep test Host nameserver follows changes to resolv.conf set DIR __STATEDIR__/resolv set LOG_FILE __STATEDIR__/resolv.log +set DONE __STATEDIR__/resolv.done passt unshare -rUm passt mkdir -p __DIR__/upper __DIR__/work passt mount -t overlay -o lowerdir=/etc,upperdir=__DIR__/upper,workdir=__DIR__/work none /etc passt echo "nameserver 192.0.2.1" > /etc/r && mv /etc/r /etc/resolv.conf -passt ./pasta -d -l __LOG_FILE__ --dns-forward 192.0.2.53 -- sleep 3 2>/dev/null & +passt ./pasta -d -l __LOG_FILE__ --dns-forward 192.0.2.53 -- sh -c 'while [ ! -e __DONE__ ]; do sleep 0.1; done' 2>/dev/null & sleep 1 passt echo "nameserver 192.0.2.2" > /etc/r && mv /etc/r /etc/resolv.conf sleep 1 check grep -q "new host nameserver 192.0.2.2" __LOG_FILE__ -passt wait + +test Host nameserver removed from resolv.conf is forgotten +passt echo "nameserver 2001:db8::1" > /etc/r && mv /etc/r /etc/resolv.conf +sleep 1 +passt touch __DONE__ && wait +check grep -q "removed nameserver 192.0.2.2" __LOG_FILE__ passt umount /etc passt exit -- 2.50.1 (Apple Git-155)