conf, udp: Introduce basic DNS forwarding
For compatibility with libslirp/slirp4netns users: introduce a mechanism to map, in the UDP routines, an address facing guest or namespace to the first IPv4 or IPv6 address resulting from configuration as resolver. This can be enabled with the new --dns-forward option. This implies that sourcing and using DNS addresses and search lists, passed via command line or read from /etc/resolv.conf, is not bound anymore to DHCP/DHCPv6/NDP usage: for example, pasta users might just want to use addresses from /etc/resolv.conf as mapping target, while not passing DNS options via DHCP. Reflect this in all the involved code paths by differentiating DHCP/DHCPv6/NDP usage from DNS configuration per se, and in the new options --dhcp-dns, --dhcp-search for pasta, and --no-dhcp-dns, --no-dhcp-search for passt. This should be the last bit to enable substantial compatibility between slirp4netns.sh and slirp4netns(1): pass the --dns-forward option from the script too. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
7
dhcpv6.c
7
dhcpv6.c
@@ -394,6 +394,9 @@ static size_t dhcpv6_dns_fill(struct ctx *c, char *buf, int offset)
|
||||
char *p = NULL;
|
||||
int i;
|
||||
|
||||
if (c->no_dhcp_dns)
|
||||
goto search;
|
||||
|
||||
for (i = 0; !IN6_IS_ADDR_UNSPECIFIED(&c->dns6[i]); i++) {
|
||||
if (!i) {
|
||||
srv = (struct opt_dns_servers *)(buf + offset);
|
||||
@@ -410,6 +413,10 @@ static size_t dhcpv6_dns_fill(struct ctx *c, char *buf, int offset)
|
||||
if (srv)
|
||||
srv->hdr.l = htons(srv->hdr.l);
|
||||
|
||||
search:
|
||||
if (c->no_dhcp_dns_search)
|
||||
return offset;
|
||||
|
||||
for (i = 0; *c->dns_search[i].n; i++) {
|
||||
if (!i) {
|
||||
srch = (struct opt_dns_search *)(buf + offset);
|
||||
|
Reference in New Issue
Block a user