Skip to content

Commit 69d4775

Browse files
committed
Remove the "extra_dns" IPs
These were a remnant of an earlier attempt to make DNS more reliable. The idea was to map the "extra_dns" IPs onto the real external DNS IPs and use the VM's resolvers to query them. Unfortunately this failed because many common resolvers (including the musl one) only use the first 3 IPs and a Mac/Windows host may have more than that. On Windows we use a resolver library and on Mac we use the macOS APIs directly, exposing both as a single DNS IP. This code is redundant and can be removed. Signed-off-by: David Scott <[email protected]>
1 parent 6f781b9 commit 69d4775

File tree

4 files changed

+5
-24
lines changed

4 files changed

+5
-24
lines changed

src/hostnet/configuration.ml

+1-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ type t = {
4444
(* TODO: remove this from the record since it is not constant across all clients *)
4545
lowest_ip: Ipaddr.V4.t;
4646
highest_ip: Ipaddr.V4.t;
47-
extra_dns: Ipaddr.V4.t list;
4847
dhcp_json_path: string option;
4948
dhcp_configuration: Dhcp_configuration.t option;
5049
mtu: int;
@@ -55,7 +54,7 @@ type t = {
5554
}
5655

5756
let to_string t =
58-
Printf.sprintf "server_macaddr = %s; max_connection = %s; dns_path = %s; dns = %s; resolver = %s; domain = %s; allowed_bind_addresses = %s; gateway_ip = %s; lowest_ip = %s; highest_ip = %s; extra_dns = %s; dhcp_json_path = %s; dhcp_configuration = %s; mtu = %d; http_intercept = %s; http_intercept_path = %s; port_max_idle_time = %s; host_names = %s"
57+
Printf.sprintf "server_macaddr = %s; max_connection = %s; dns_path = %s; dns = %s; resolver = %s; domain = %s; allowed_bind_addresses = %s; gateway_ip = %s; lowest_ip = %s; highest_ip = %s; dhcp_json_path = %s; dhcp_configuration = %s; mtu = %d; http_intercept = %s; http_intercept_path = %s; port_max_idle_time = %s; host_names = %s"
5958
(Macaddr.to_string t.server_macaddr)
6059
(match t.max_connections with None -> "None" | Some x -> string_of_int x)
6160
(match t.dns_path with None -> "None" | Some x -> x)
@@ -66,7 +65,6 @@ let to_string t =
6665
(Ipaddr.V4.to_string t.gateway_ip)
6766
(Ipaddr.V4.to_string t.lowest_ip)
6867
(Ipaddr.V4.to_string t.highest_ip)
69-
(String.concat ", " (List.map Ipaddr.V4.to_string t.extra_dns))
7068
(match t.dhcp_json_path with None -> "None" | Some x -> x)
7169
(match t.dhcp_configuration with None -> "None" | Some x -> Dhcp_configuration.to_string x)
7270
t.mtu
@@ -81,7 +79,6 @@ let no_dns_servers =
8179
let default_lowest_ip = Ipaddr.V4.of_string_exn "192.168.65.2"
8280
let default_gateway_ip = Ipaddr.V4.of_string_exn "192.168.65.1"
8381
let default_highest_ip = Ipaddr.V4.of_string_exn "192.168.65.254"
84-
let default_extra_dns = []
8582
(* The default MTU is limited by the maximum message size on a Hyper-V
8683
socket. On currently available windows versions, we need to stay
8784
below 8192 bytes *)
@@ -103,7 +100,6 @@ let default = {
103100
gateway_ip = default_gateway_ip;
104101
lowest_ip = default_lowest_ip;
105102
highest_ip = default_highest_ip;
106-
extra_dns = default_extra_dns;
107103
dhcp_json_path = None;
108104
dhcp_configuration = None;
109105
mtu = default_mtu;

src/hostnet/hostnet_dhcp.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module Make (Clock: Mirage_clock_lwt.MCLOCK) (Netif: Mirage_net_lwt.S) = struct
4646
resolved in the future *)
4747
let low_ip, high_ip =
4848
let open Ipaddr.V4 in
49-
let all_static_ips = c.Configuration.gateway_ip :: c.Configuration.lowest_ip :: c.Configuration.extra_dns in
49+
let all_static_ips = [ c.Configuration.gateway_ip; c.Configuration.lowest_ip ] in
5050
let highest = maximum_ip all_static_ips in
5151
let i32 = to_int32 highest in
5252
of_int32 @@ Int32.succ i32, of_int32 @@ Int32.succ @@ Int32.succ i32 in
@@ -73,7 +73,7 @@ module Make (Clock: Mirage_clock_lwt.MCLOCK) (Netif: Mirage_net_lwt.S) = struct
7373
| _, _ -> Configuration.default_domain in
7474
let options = [
7575
Dhcp_wire.Routers [ c.Configuration.gateway_ip ];
76-
Dhcp_wire.Dns_servers (c.Configuration.gateway_ip :: c.Configuration.extra_dns);
76+
Dhcp_wire.Dns_servers [ c.Configuration.gateway_ip ];
7777
Dhcp_wire.Ntp_servers [ c.Configuration.gateway_ip ];
7878
Dhcp_wire.Broadcast_addr (Ipaddr.V4.Prefix.broadcast prefix);
7979
Dhcp_wire.Subnet_mask (Ipaddr.V4.Prefix.netmask prefix);

src/hostnet/slirp.ml

+2-11
Original file line numberDiff line numberDiff line change
@@ -862,12 +862,12 @@ struct
862862
let local_arp_table = [
863863
c.Configuration.lowest_ip, client_macaddr;
864864
c.Configuration.gateway_ip, c.Configuration.server_macaddr;
865-
] @ (List.map (fun ip -> ip, c.Configuration.server_macaddr) c.Configuration.extra_dns) in
865+
] in
866866
Global_arp_ethif.connect switch
867867
>>= fun global_arp_ethif ->
868868

869869
(* Listen on local IPs *)
870-
let local_ips = c.Configuration.gateway_ip :: c.Configuration.extra_dns in
870+
let local_ips = [ c.Configuration.gateway_ip ] in
871871

872872
let dhcp = Dhcp.make ~configuration:c clock switch in
873873

@@ -1305,15 +1305,6 @@ struct
13051305
Active_config.map (Configuration.Parse.ipv4 Configuration.default_highest_ip) string_highest_ips
13061306
>>= fun highest_ips ->
13071307
on_change highest_ips (fun highest_ip -> update (fun c -> { c with highest_ip }));
1308-
let extra_dns_ips_path = driver @ [ "slirp"; "extra_dns" ] in
1309-
Config.string config ~default:""
1310-
extra_dns_ips_path
1311-
>>= fun string_extra_dns_ips ->
1312-
Active_config.map
1313-
(fun x -> Lwt.return @@ Configuration.Parse.ipv4_list (List.map Ipaddr.V4.of_string_exn Configuration.default_extra_dns) x)
1314-
string_extra_dns_ips
1315-
>>= fun extra_dns_ips ->
1316-
on_change extra_dns_ips (fun extra_dns -> update (fun c -> { c with extra_dns }));
13171308
let resolver_path = driver @ [ "slirp"; "resolver" ] in
13181309
Config.string_option config resolver_path
13191310
>>= fun string_resolver_settings ->

src/hostnet_test/slirp_stack.ml

-6
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,11 @@ module DNS = Dns_resolver_mirage.Make(Host.Time)(Client)
134134

135135
let primary_dns_ip = Ipaddr.V4.of_string_exn "192.168.65.1"
136136

137-
let extra_dns_ip = List.map Ipaddr.V4.of_string_exn [
138-
"192.168.65.3"; "192.168.65.4"; "192.168.65.5"; "192.168.65.6";
139-
"192.168.65.7"; "192.168.65.8"; "192.168.65.9"; "192.168.65.10";
140-
]
141-
142137
let preferred_ip1 = Ipaddr.V4.of_string_exn "192.168.65.250"
143138

144139
let config =
145140
let configuration = {
146141
Configuration.default with
147-
extra_dns = extra_dns_ip;
148142
domain = Some "local";
149143
} in
150144
Mclock.connect () >>= fun clock ->

0 commit comments

Comments
 (0)