From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id DA0475A0278; Tue, 12 Mar 2024 08:21:36 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH] conf: Handle addresses passed via --dns just like the ones from resolv.conf Date: Tue, 12 Mar 2024 08:21:36 +0100 Message-Id: <20240312072136.225197-1-sbrivio@redhat.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 6SC6J77KFB5YII6YYXB64IEWLCBVCSV2 X-Message-ID-Hash: 6SC6J77KFB5YII6YYXB64IEWLCBVCSV2 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: Paul Holzinger 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: ...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 Link: https://bugs.passt.top/show_bug.cgi?id=82 Fixes: 89678c515755 ("conf, udp: Introduce basic DNS forwarding") Signed-off-by: Stefano Brivio --- 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; } -- 2.39.2