From ba969e6771c990f3da296176ee99746262c2fb31 Mon Sep 17 00:00:00 2001 From: Luiz Souza Date: Sat, 12 Aug 2017 00:36:46 -0500 Subject: Fix a couple of 'route: writing to routing socket: Invalid argument' warnings during the boot. Use the correct variable and only add the route when the hostname is resolved (if the remote address is a hostname). route: writing to routing socket: Invalid argument --- src/etc/inc/vpn.inc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/etc') diff --git a/src/etc/inc/vpn.inc b/src/etc/inc/vpn.inc index 6390aed..8eb2c3c 100644 --- a/src/etc/inc/vpn.inc +++ b/src/etc/inc/vpn.inc @@ -862,7 +862,7 @@ EOD; if (is_ipaddr($right_spec)) { $sourcehost = $right_spec; } else { - $sourcehost = $rgmap['remote-gateway']; + $sourcehost = $rgmap[$right_spec]; } if (substr($ph1ent['interface'], 0, 4) == "_vip") { @@ -888,7 +888,8 @@ EOD; $subnet_bits = get_interface_subnet($vpninterface); $subnet_ip = gen_subnetv4($interfaceip, $subnet_bits); /* if the remote gateway is in the local subnet, then don't add a route */ - if (!ip_in_subnet($sourcehost, "{$subnet_ip}/{$subnet_bits}")) { + if (is_ipaddrv4($sourcehost) && + !ip_in_subnet($sourcehost, "{$subnet_ip}/{$subnet_bits}")) { if (is_ipaddrv4($gatewayip)) { // log_error("IPSEC interface is not WAN but {$ifacesuse}, adding static route for VPN endpoint {$rgip} via {$gatewayip}"); route_add_or_change("-host {$sourcehost} {$gatewayip}"); @@ -902,7 +903,8 @@ EOD; $subnet_bits = get_interface_subnetv6($vpninterface); $subnet_ip = gen_subnetv6($interfaceip, $subnet_bits); /* if the remote gateway is in the local subnet, then don't add a route */ - if (!ip_in_subnet($sourcehost, "{$subnet_ip}/{$subnet_bits}")) { + if (is_ipaddrv6($sourcehost) && + !ip_in_subnet($sourcehost, "{$subnet_ip}/{$subnet_bits}")) { if (is_ipaddrv6($gatewayip)) { // log_error("IPSEC interface is not WAN but {$ifacesuse}, adding static route for VPN endpoint {$rgip} via {$gatewayip}"); route_add_or_change("-inet6 -host {$sourcehost} {$gatewayip}"); -- cgit v1.1