* [PATCH] conf: Handle addresses passed via --dns just like the ones from resolv.conf
@ 2024-03-12 7:21 Stefano Brivio
2024-03-12 10:20 ` Paul Holzinger
2024-03-14 2:17 ` David Gibson
0 siblings, 2 replies; 5+ messages in thread
From: Stefano Brivio @ 2024-03-12 7:21 UTC (permalink / raw)
To: passt-dev; +Cc: Paul Holzinger
...that is, call add_dns4() and add_dns6() instead of simply adding
those to the list of servers we advertise.
Most importantly, this will set the 'dns_host' field for the matching
IP version, so that, as mentioned in the man page, servers passed via
--dns are used for DNS mapping as well, if used in combination with
--dns-forward.
Reported-by: Paul Holzinger <pholzing@redhat.com>
Link: https://bugs.passt.top/show_bug.cgi?id=82
Fixes: 89678c515755 ("conf, udp: Introduce basic DNS forwarding")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
conf.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/conf.c b/conf.c
index c50c039..17c667a 100644
--- a/conf.c
+++ b/conf.c
@@ -1164,11 +1164,11 @@ void conf(struct ctx *c, int argc, char **argv)
};
char userns[PATH_MAX] = { 0 }, netns[PATH_MAX] = { 0 };
bool copy_addrs_opt = false, copy_routes_opt = false;
+ struct in6_addr *dns6 = c->ip6.dns, dns6_tmp;
+ struct in_addr *dns4 = c->ip4.dns, dns4_tmp;
enum fwd_ports_mode fwd_default = FWD_NONE;
bool v4_only = false, v6_only = false;
- struct in6_addr *dns6 = c->ip6.dns;
struct fqdn *dnss = c->dns_search;
- struct in_addr *dns4 = c->ip4.dns;
unsigned int ifi4 = 0, ifi6 = 0;
const char *logfile = NULL;
const char *optstring;
@@ -1554,14 +1554,14 @@ void conf(struct ctx *c, int argc, char **argv)
die("Conflicting DNS options");
if (dns4 - &c->ip4.dns[0] < ARRAY_SIZE(c->ip4.dns) &&
- inet_pton(AF_INET, optarg, dns4)) {
- dns4++;
+ inet_pton(AF_INET, optarg, &dns4_tmp)) {
+ add_dns4(c, &dns4_tmp, &dns4);
break;
}
if (dns6 - &c->ip6.dns[0] < ARRAY_SIZE(c->ip6.dns) &&
- inet_pton(AF_INET6, optarg, dns6)) {
- dns6++;
+ inet_pton(AF_INET6, optarg, &dns6_tmp)) {
+ add_dns6(c, &dns6_tmp, &dns6);
break;
}
--
@@ -1164,11 +1164,11 @@ void conf(struct ctx *c, int argc, char **argv)
};
char userns[PATH_MAX] = { 0 }, netns[PATH_MAX] = { 0 };
bool copy_addrs_opt = false, copy_routes_opt = false;
+ struct in6_addr *dns6 = c->ip6.dns, dns6_tmp;
+ struct in_addr *dns4 = c->ip4.dns, dns4_tmp;
enum fwd_ports_mode fwd_default = FWD_NONE;
bool v4_only = false, v6_only = false;
- struct in6_addr *dns6 = c->ip6.dns;
struct fqdn *dnss = c->dns_search;
- struct in_addr *dns4 = c->ip4.dns;
unsigned int ifi4 = 0, ifi6 = 0;
const char *logfile = NULL;
const char *optstring;
@@ -1554,14 +1554,14 @@ void conf(struct ctx *c, int argc, char **argv)
die("Conflicting DNS options");
if (dns4 - &c->ip4.dns[0] < ARRAY_SIZE(c->ip4.dns) &&
- inet_pton(AF_INET, optarg, dns4)) {
- dns4++;
+ inet_pton(AF_INET, optarg, &dns4_tmp)) {
+ add_dns4(c, &dns4_tmp, &dns4);
break;
}
if (dns6 - &c->ip6.dns[0] < ARRAY_SIZE(c->ip6.dns) &&
- inet_pton(AF_INET6, optarg, dns6)) {
- dns6++;
+ inet_pton(AF_INET6, optarg, &dns6_tmp)) {
+ add_dns6(c, &dns6_tmp, &dns6);
break;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] conf: Handle addresses passed via --dns just like the ones from resolv.conf
2024-03-12 7:21 [PATCH] conf: Handle addresses passed via --dns just like the ones from resolv.conf Stefano Brivio
@ 2024-03-12 10:20 ` Paul Holzinger
2024-03-14 2:17 ` David Gibson
1 sibling, 0 replies; 5+ messages in thread
From: Paul Holzinger @ 2024-03-12 10:20 UTC (permalink / raw)
To: Stefano Brivio; +Cc: passt-dev
On 12/03/2024 08:21, Stefano Brivio wrote:
> ...that is, call add_dns4() and add_dns6() instead of simply adding
> those to the list of servers we advertise.
>
> Most importantly, this will set the 'dns_host' field for the matching
> IP version, so that, as mentioned in the man page, servers passed via
> --dns are used for DNS mapping as well, if used in combination with
> --dns-forward.
>
> Reported-by: Paul Holzinger <pholzing@redhat.com>
> Link: https://bugs.passt.top/show_bug.cgi?id=82
> Fixes: 89678c515755 ("conf, udp: Introduce basic DNS forwarding")
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Paul Holzinger <pholzing@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] conf: Handle addresses passed via --dns just like the ones from resolv.conf
2024-03-12 7:21 [PATCH] conf: Handle addresses passed via --dns just like the ones from resolv.conf Stefano Brivio
2024-03-12 10:20 ` Paul Holzinger
@ 2024-03-14 2:17 ` David Gibson
2024-03-14 4:54 ` Stefano Brivio
1 sibling, 1 reply; 5+ messages in thread
From: David Gibson @ 2024-03-14 2:17 UTC (permalink / raw)
To: Stefano Brivio; +Cc: passt-dev, Paul Holzinger
[-- Attachment #1: Type: text/plain, Size: 2493 bytes --]
On Tue, Mar 12, 2024 at 08:21:36AM +0100, Stefano Brivio wrote:
> ...that is, call add_dns4() and add_dns6() instead of simply adding
> those to the list of servers we advertise.
>
> Most importantly, this will set the 'dns_host' field for the matching
> IP version, so that, as mentioned in the man page, servers passed via
> --dns are used for DNS mapping as well, if used in combination with
> --dns-forward.
>
> Reported-by: Paul Holzinger <pholzing@redhat.com>
> Link: https://bugs.passt.top/show_bug.cgi?id=82
> Fixes: 89678c515755 ("conf, udp: Introduce basic DNS forwarding")
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
This does subtly change semantics: addresses given to --dns are now
host addresses, rather than guest addresses. I think the new meaning
is less cryptic, though.
> ---
> conf.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/conf.c b/conf.c
> index c50c039..17c667a 100644
> --- a/conf.c
> +++ b/conf.c
> @@ -1164,11 +1164,11 @@ void conf(struct ctx *c, int argc, char **argv)
> };
> char userns[PATH_MAX] = { 0 }, netns[PATH_MAX] = { 0 };
> bool copy_addrs_opt = false, copy_routes_opt = false;
> + struct in6_addr *dns6 = c->ip6.dns, dns6_tmp;
> + struct in_addr *dns4 = c->ip4.dns, dns4_tmp;
> enum fwd_ports_mode fwd_default = FWD_NONE;
> bool v4_only = false, v6_only = false;
> - struct in6_addr *dns6 = c->ip6.dns;
> struct fqdn *dnss = c->dns_search;
> - struct in_addr *dns4 = c->ip4.dns;
> unsigned int ifi4 = 0, ifi6 = 0;
> const char *logfile = NULL;
> const char *optstring;
> @@ -1554,14 +1554,14 @@ void conf(struct ctx *c, int argc, char **argv)
> die("Conflicting DNS options");
>
> if (dns4 - &c->ip4.dns[0] < ARRAY_SIZE(c->ip4.dns) &&
> - inet_pton(AF_INET, optarg, dns4)) {
> - dns4++;
> + inet_pton(AF_INET, optarg, &dns4_tmp)) {
> + add_dns4(c, &dns4_tmp, &dns4);
> break;
> }
>
> if (dns6 - &c->ip6.dns[0] < ARRAY_SIZE(c->ip6.dns) &&
> - inet_pton(AF_INET6, optarg, dns6)) {
> - dns6++;
> + inet_pton(AF_INET6, optarg, &dns6_tmp)) {
> + add_dns6(c, &dns6_tmp, &dns6);
> break;
> }
>
--
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] 5+ messages in thread
* Re: [PATCH] conf: Handle addresses passed via --dns just like the ones from resolv.conf
2024-03-14 2:17 ` David Gibson
@ 2024-03-14 4:54 ` Stefano Brivio
2024-03-14 5:08 ` David Gibson
0 siblings, 1 reply; 5+ messages in thread
From: Stefano Brivio @ 2024-03-14 4:54 UTC (permalink / raw)
To: David Gibson; +Cc: passt-dev, Paul Holzinger
On Thu, 14 Mar 2024 13:17:02 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:
> On Tue, Mar 12, 2024 at 08:21:36AM +0100, Stefano Brivio wrote:
> > ...that is, call add_dns4() and add_dns6() instead of simply adding
> > those to the list of servers we advertise.
> >
> > Most importantly, this will set the 'dns_host' field for the matching
> > IP version, so that, as mentioned in the man page, servers passed via
> > --dns are used for DNS mapping as well, if used in combination with
> > --dns-forward.
> >
> > Reported-by: Paul Holzinger <pholzing@redhat.com>
> > Link: https://bugs.passt.top/show_bug.cgi?id=82
> > Fixes: 89678c515755 ("conf, udp: Introduce basic DNS forwarding")
> > Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
>
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>
> This does subtly change semantics: addresses given to --dns are now
> host addresses, rather than guest addresses. I think the new meaning
> is less cryptic, though.
Right, yes. But as we introduced the feature, the man page said, from
the beginning:
-D, --dns addr
Use addr (IPv4 or IPv6) for DHCP, DHCPv6, NDP or DNS forwarding [...]
so we have to change/fix semantics, I guess.
--
Stefano
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] conf: Handle addresses passed via --dns just like the ones from resolv.conf
2024-03-14 4:54 ` Stefano Brivio
@ 2024-03-14 5:08 ` David Gibson
0 siblings, 0 replies; 5+ messages in thread
From: David Gibson @ 2024-03-14 5:08 UTC (permalink / raw)
To: Stefano Brivio; +Cc: passt-dev, Paul Holzinger
[-- Attachment #1: Type: text/plain, Size: 1652 bytes --]
On Thu, Mar 14, 2024 at 05:54:10AM +0100, Stefano Brivio wrote:
> On Thu, 14 Mar 2024 13:17:02 +1100
> David Gibson <david@gibson.dropbear.id.au> wrote:
>
> > On Tue, Mar 12, 2024 at 08:21:36AM +0100, Stefano Brivio wrote:
> > > ...that is, call add_dns4() and add_dns6() instead of simply adding
> > > those to the list of servers we advertise.
> > >
> > > Most importantly, this will set the 'dns_host' field for the matching
> > > IP version, so that, as mentioned in the man page, servers passed via
> > > --dns are used for DNS mapping as well, if used in combination with
> > > --dns-forward.
> > >
> > > Reported-by: Paul Holzinger <pholzing@redhat.com>
> > > Link: https://bugs.passt.top/show_bug.cgi?id=82
> > > Fixes: 89678c515755 ("conf, udp: Introduce basic DNS forwarding")
> > > Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> >
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> >
> > This does subtly change semantics: addresses given to --dns are now
> > host addresses, rather than guest addresses. I think the new meaning
> > is less cryptic, though.
>
> Right, yes. But as we introduced the feature, the man page said, from
> the beginning:
>
> -D, --dns addr
> Use addr (IPv4 or IPv6) for DHCP, DHCPv6, NDP or DNS forwarding [...]
>
> so we have to change/fix semantics, I guess.
Right, it's not really clear from the man page whether it's a host or
guest address.
--
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] 5+ messages in thread
end of thread, other threads:[~2024-03-14 5:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-12 7:21 [PATCH] conf: Handle addresses passed via --dns just like the ones from resolv.conf Stefano Brivio
2024-03-12 10:20 ` Paul Holzinger
2024-03-14 2:17 ` David Gibson
2024-03-14 4:54 ` Stefano Brivio
2024-03-14 5:08 ` 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).