@@ -474,7 +474,7 @@ struct
474474 clock : Clock .t ;
475475 endpoint : Endpoint .t ;
476476 udp_nat : Udp_nat .t ;
477- dns_ips : Ipaddr.V4 . t list ;
477+ dns_ips : Ipaddr .t list ;
478478 }
479479 (* * Proxies connections to services on localhost on the host *)
480480
@@ -989,11 +989,11 @@ struct
989989 >> = fun switch ->
990990
991991 (* Serve a static ARP table *)
992- let local_arp_table = [
993- c.Configuration. lowest_ip, client_macaddr;
994- c.Configuration. gateway_ip, c.Configuration. server_macaddr;
995- c.Configuration. host_ip, c.Configuration. server_macaddr;
996- ] in
992+ let local_arp_table =
993+ ( c.Configuration. lowest_ip, client_macaddr)
994+ :: ( c.Configuration. gateway_ip, c.Configuration. server_macaddr)
995+ :: ( if Ipaddr.V4. (compare unspecified c.Configuration. host_ip = 0 ) then [] else [ c. Configuration. host_ip , c.Configuration. server_macaddr])
996+ in
997997 Global_arp_ethif. connect switch
998998 >> = fun global_arp_ethif ->
999999
@@ -1155,7 +1155,11 @@ struct
11551155 Global_arp. input arp (Cstruct. shift buf Ethif_wire. sizeof_ethernet)
11561156 | Ok (Ethernet { payload = Ipv4 ({ dst; _ } as ipv4 ); _ } ) ->
11571157 (* For any new IP destination, create a stack to proxy for
1158- the remote system *)
1158+ the remote system *)
1159+ let localhost_ips =
1160+ if Ipaddr.V4. (compare unspecified c.Configuration. host_ip) = 0
1161+ then []
1162+ else [ Ipaddr. V4 c.Configuration. host_ip ] in
11591163 if dst = c.Configuration. gateway_ip then begin
11601164 begin
11611165 let open Lwt_result.Infix in
@@ -1188,7 +1192,7 @@ struct
11881192 end in
11891193 Udp_nat. set_send_reply ~t: udp_nat ~send_reply ;
11901194 Gateway. create clock endpoint udp_nat [ c.Configuration. gateway_ip ]
1191- c.Configuration. host_names [ Ipaddr. V4 c. Configuration. host_ip ]
1195+ c.Configuration. host_names localhost_ips
11921196 end >> = function
11931197 | Error e ->
11941198 Log. err (fun f ->
@@ -1200,13 +1204,13 @@ struct
12001204 | Ok () -> ()
12011205 | Error e ->
12021206 Log. err (fun f -> f " failed to read TCP/IP input: %a" pp_error e);
1203- end else if dst = c.Configuration. host_ip then begin
1207+ end else if dst = c.Configuration. host_ip && Ipaddr.V4. (compare unspecified c. Configuration. host_ip <> 0 ) then begin
12041208 begin
12051209 let open Lwt_result.Infix in
12061210 find_endpoint dst >> = fun endpoint ->
12071211 Log. debug (fun f ->
12081212 f " creating localhost TCP/IP proxy for %a" Ipaddr.V4. pp_hum dst);
1209- Localhost. create clock endpoint udp_nat [ c. Configuration. host_ip ]
1213+ Localhost. create clock endpoint udp_nat localhost_ips
12101214 end >> = function
12111215 | Error e ->
12121216 Log. err (fun f ->
@@ -1225,7 +1229,7 @@ struct
12251229 Log. debug (fun f ->
12261230 f " create remote TCP/IP proxy for %a" Ipaddr.V4. pp_hum dst);
12271231 Remote. create endpoint udp_nat icmp_nat
1228- c.Configuration. host_names [ Ipaddr. V4 c. Configuration. host_ip ]
1232+ c.Configuration. host_names localhost_ips
12291233 end >> = function
12301234 | Error e ->
12311235 Log. err (fun f ->
@@ -1465,11 +1469,10 @@ struct
14651469 Log. info (fun f -> f " Configuration %s" (Configuration. to_string c));
14661470 let global_arp_table : arp_table = {
14671471 mutex = Lwt_mutex. create() ;
1468- table = [
1469- c.Configuration. gateway_ip, c.Configuration. server_macaddr;
1470- c.Configuration. host_ip, c.Configuration. server_macaddr;
1471- ];
1472-
1472+ table =
1473+ (c.Configuration. gateway_ip, c.Configuration. server_macaddr)
1474+ :: (if Ipaddr.V4. (compare unspecified c.Configuration. host_ip) = 0 then []
1475+ else [c.Configuration. host_ip, c.Configuration. server_macaddr ]);
14731476 } in
14741477 let client_uuids : uuid_table = {
14751478 mutex = Lwt_mutex. create() ;
0 commit comments