1
0
Fork 0
mirror of https://passt.top/passt synced 2025-06-14 19:35:35 +02:00

conf, udp: Drop mostly duplicated dns_send arrays, rename related fields

Given that we use just the first valid DNS resolver address
configured, or read from resolv.conf(5) on the host, to forward DNS
queries to, in case --dns-forward is used, we don't need to duplicate
dns[] to dns_send[]:

- rename dns_send[] back to dns[]: those are the resolvers we
  advertise to the guest/container

- for forwarding purposes, instead of dns[], use a single field (for
  each protocol version): dns_host

- and rename dns_fwd to dns_match, so that it's clear this is the
  address we are matching DNS queries against, to decide if they need
  to be forwarded

Suggested-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Stefano Brivio 2022-11-10 20:30:03 +01:00
parent 4129764eca
commit 3a2afde87d
6 changed files with 62 additions and 71 deletions

20
passt.h
View file

@ -101,9 +101,9 @@ enum passt_modes {
* @addr_seen: Latest IPv4 address seen as source from tap
* @prefixlen: IPv4 prefix length (netmask)
* @gw: Default IPv4 gateway, network order
* @dns: Host IPv4 DNS addresses, zero-terminated, network order
* @dns_send: Offered IPv4 DNS, zero-terminated, network order
* @dns_fwd: Address forwarded (UDP) to first IPv4 DNS, network order
* @dns: DNS addresses for DHCP, zero-terminated, network order
* @dns_match: Forward DNS query if sent to this address, network order
* @dns_host: Use this DNS on the host for forwarding, network order
*/
struct ip4_ctx {
struct in_addr addr;
@ -111,8 +111,8 @@ struct ip4_ctx {
int prefix_len;
struct in_addr gw;
struct in_addr dns[MAXNS + 1];
struct in_addr dns_send[MAXNS + 1];
struct in_addr dns_fwd;
struct in_addr dns_match;
struct in_addr dns_host;
};
/**
@ -122,9 +122,9 @@ struct ip4_ctx {
* @addr_seen: Latest IPv6 global/site address seen as source from tap
* @addr_ll_seen: Latest IPv6 link-local address seen as source from tap
* @gw: Default IPv6 gateway
* @dns: Host IPv6 DNS addresses, zero-terminated
* @dns_send: Offered IPv6 DNS addresses, zero-terminated
* @dns_fwd: Address forwarded (UDP) to first IPv6 DNS, network order
* @dns: DNS addresses for DHCPv6 and NDP, zero-terminated
* @dns_match: Forward DNS query if sent to this address
* @dns_host: Use this DNS on the host for forwarding
*/
struct ip6_ctx {
struct in6_addr addr;
@ -133,8 +133,8 @@ struct ip6_ctx {
struct in6_addr addr_ll_seen;
struct in6_addr gw;
struct in6_addr dns[MAXNS + 1];
struct in6_addr dns_send[MAXNS + 1];
struct in6_addr dns_fwd;
struct in6_addr dns_match;
struct in6_addr dns_host;
};
#include <netinet/if_ether.h>