conf: Correct setting of dns_match address in add_dns6()

add_dns6() (but not add_dns4()) has a bug setting dns_match: it sets it to
the given address, rather than the gateway address.  This is doubly wrong:
 - We've just established the given address is a host loopback address
   the guest can't access
 - We've just set ip6.dns[] to tell the guest to use the gateway address,
   so it won't use the dns_match address we're setting

Correct this to use the gateway address, like IPv4.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2024-08-21 14:20:05 +10:00 committed by Stefano Brivio
parent 7c083ee41c
commit a6066f4e27

2
conf.c
View file

@ -408,7 +408,7 @@ static unsigned add_dns6(struct ctx *c, struct in6_addr *addr, unsigned idx)
added++; added++;
if (IN6_IS_ADDR_UNSPECIFIED(&c->ip6.dns_match)) if (IN6_IS_ADDR_UNSPECIFIED(&c->ip6.dns_match))
c->ip6.dns_match = *addr; c->ip6.dns_match = c->ip6.gw;
} }
} else { } else {
c->ip6.dns[idx] = *addr; c->ip6.dns[idx] = *addr;