aboutgitcodebugslistschat
path: root/ndp.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-02-18 04:03:53 +0100
committerStefano Brivio <sbrivio@redhat.com>2022-02-21 13:41:13 +0100
commit89678c515755403277938e34984f3faf4863d593 (patch)
tree2e704fe4f036cc017e27be5103098b70e4954c75 /ndp.c
parent01ae772dcc4ba7930179521bb22712bb4256bb03 (diff)
downloadpasst-89678c515755403277938e34984f3faf4863d593.tar
passt-89678c515755403277938e34984f3faf4863d593.tar.gz
passt-89678c515755403277938e34984f3faf4863d593.tar.bz2
passt-89678c515755403277938e34984f3faf4863d593.tar.lz
passt-89678c515755403277938e34984f3faf4863d593.tar.xz
passt-89678c515755403277938e34984f3faf4863d593.tar.zst
passt-89678c515755403277938e34984f3faf4863d593.zip
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>
Diffstat (limited to 'ndp.c')
-rw-r--r--ndp.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ndp.c b/ndp.c
index 386098c..6b1c1a8 100644
--- a/ndp.c
+++ b/ndp.c
@@ -127,6 +127,9 @@ int ndp(struct ctx *c, struct ethhdr *eh, size_t len)
p += 4;
}
+ if (c->no_dhcp_dns)
+ goto dns_done;
+
for (n = 0; !IN6_IS_ADDR_UNSPECIFIED(&c->dns6[n]); n++);
if (n) {
*p++ = 25; /* RDNSS */
@@ -144,7 +147,7 @@ int ndp(struct ctx *c, struct ethhdr *eh, size_t len)
dns_s_len += strlen(c->dns_search[n].n) + 2;
}
- if (dns_s_len) {
+ if (!c->no_dhcp_dns_search && dns_s_len) {
*p++ = 31; /* DNSSL */
*p++ = (len + 8 - 1) / 8 + 1; /* length */
p += 2; /* reserved */
@@ -171,6 +174,7 @@ int ndp(struct ctx *c, struct ethhdr *eh, size_t len)
p += 8 - dns_s_len % 8;
}
+dns_done:
*p++ = 1; /* source ll */
*p++ = 1; /* length */
memcpy(p, c->mac, ETH_ALEN);