public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] conf: Warn if we can't advertise any nameserver via DHCP, NDP, or DHCPv6
@ 2024-03-12 18:21 Stefano Brivio
  2024-03-14  2:20 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Stefano Brivio @ 2024-03-12 18:21 UTC (permalink / raw)
  To: passt-dev; +Cc: David Gibson

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] conf: Warn if we can't advertise any nameserver via DHCP, NDP, or DHCPv6
  2024-03-12 18:21 [PATCH] conf: Warn if we can't advertise any nameserver via DHCP, NDP, or DHCPv6 Stefano Brivio
@ 2024-03-14  2:20 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2024-03-14  2:20 UTC (permalink / raw)
  To: Stefano Brivio; +Cc: passt-dev

[-- Attachment #1: Type: text/plain, Size: 1556 bytes --]

On Tue, Mar 12, 2024 at 07:21:10PM +0100, Stefano Brivio wrote:
> 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>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  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");
> +	}
>  }
>  
>  /**

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-14  2:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-12 18:21 [PATCH] conf: Warn if we can't advertise any nameserver via DHCP, NDP, or DHCPv6 Stefano Brivio
2024-03-14  2:20 ` David Gibson

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).