public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
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	[thread overview]
Message-ID: <20240312182110.510581-1-sbrivio@redhat.com> (raw)

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 <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 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");
+	}
 }
 
 /**
-- 
@@ -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


             reply	other threads:[~2024-03-12 18:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12 18:21 Stefano Brivio [this message]
2024-03-14  2:20 ` [PATCH] conf: Warn if we can't advertise any nameserver via DHCP, NDP, or DHCPv6 David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240312182110.510581-1-sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).