From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id D8C2C5A0272; Tue, 12 Mar 2024 19:21:10 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH] conf: Warn if we can't advertise any nameserver via DHCP, NDP, or DHCPv6 Date: Tue, 12 Mar 2024 19:21:10 +0100 Message-Id: <20240312182110.510581-1-sbrivio@redhat.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: LPHVA7HGG3ZPAZGQN5QLA6YEHYBOBUAA X-Message-ID-Hash: LPHVA7HGG3ZPAZGQN5QLA6YEHYBOBUAA X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson 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: We might have read from resolv.conf, or from the command line, a resolver that's reachable via loopback address, but that doesn't mean we can offer that via DHCP, NDP or DHCPv6: warn if there are no resolvers we can offer for a given IP version. Suggested-by: David Gibson Signed-off-by: Stefano Brivio --- conf.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/conf.c b/conf.c index 17c667a..ac9fb34 100644 --- a/conf.c +++ b/conf.c @@ -464,8 +464,21 @@ static void get_dns(struct ctx *c) close(fd); out: - if (!dns_set && !added) - warn("Couldn't get any nameserver address"); + if (!dns_set) { + if (!added) + warn("Couldn't get any nameserver address"); + + if (c->no_dhcp_dns) + return; + + if (c->ifi4 && !c->no_dhcp && + IN4_IS_ADDR_UNSPECIFIED(&c->ip4.dns[0])) + warn("No IPv4 nameserver available for DHCP"); + + if (c->ifi6 && ((!c->no_ndp && !c->no_ra) || !c->no_dhcpv6) && + IN6_IS_ADDR_UNSPECIFIED(&c->ip6.dns[0])) + warn("No IPv6 nameserver available for NDP/DHCPv6"); + } } /** -- 2.39.2