From f729d881c749db5f146f3dad9e331a3bd97fe0ab Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 6 Apr 2017 12:41:07 +0200 Subject: [PATCH] rc: align the behaviour of IPv4 and IPv6 IP renewal PR: https://github.com/opnsense/core/pull/1524 --- src/etc/rc.newwanip | 6 +---- src/etc/rc.newwanipv6 | 51 +++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/etc/rc.newwanip b/src/etc/rc.newwanip index 4c37f398a..9c7ac54fc 100755 --- a/src/etc/rc.newwanip +++ b/src/etc/rc.newwanip @@ -94,11 +94,7 @@ if ($curwanip == "0.0.0.0" || !is_ipaddr($curwanip)) { } } -if (file_exists("/var/db/{$interface}_cacheip")) { - $oldip = file_get_contents("/var/db/{$interface}_cacheip"); -} else { - $oldip = "0.0.0.0"; -} +$oldip = @file_get_contents("/var/db/{$interface}_cacheip"); system_resolvconf_generate(); diff --git a/src/etc/rc.newwanipv6 b/src/etc/rc.newwanipv6 index 8cc840df8..c1079568a 100755 --- a/src/etc/rc.newwanipv6 +++ b/src/etc/rc.newwanipv6 @@ -83,12 +83,12 @@ if (!empty($new_domain_name_servers)) { } if (count($valid_ns) > 0) { - file_put_contents("/var/etc/nameserver_v6{$interface}", implode("\n", $valid_ns)); + @file_put_contents("/var/etc/nameserver_v6{$interface}", implode("\n", $valid_ns)); } } $new_domain_name = getenv("new_domain_name"); if (!empty($new_domain_name)) { - file_put_contents("/var/etc/searchdomain_v6{$interface}", $new_domain_name); + @file_put_contents("/var/etc/searchdomain_v6{$interface}", $new_domain_name); } /* write current WAN IPv6 to file */ @@ -98,10 +98,7 @@ if (is_ipaddrv6($curwanipv6)) { log_error("rc.newwanipv6: on (IP address: {$curwanipv6}) (interface: {$interface}) (real interface: {$interface_real})."); -$oldipv6 = ""; -if (file_exists("/var/db/{$interface}_cacheipv6")) { - $oldipv6 = file_get_contents("/var/db/{$interface}_cacheipv6"); -} +$oldipv6 = @file_get_contents("/var/db/{$interface}_cacheipv6"); $grouptmp = link_interface_to_group($interface); if (!empty($grouptmp)) { @@ -110,30 +107,32 @@ if (!empty($grouptmp)) { link_interface_to_track6($interface, "update"); system_resolvconf_generate(); -system_routing_configure($interface); -setup_gateways_monitor(); -/* signal filter reload */ -filter_configure(); +/* + * We need to force sync VPNs on such even when the IP is the same for dynamic interfaces. + * Even with the same IP the VPN software is unhappy with the IP disappearing, and we + * could be failing back in which case we need to switch IPs back anyhow. + */ +if (!is_ipaddr($oldipv6) || $curwanipv6 != $oldipv6 || !is_ipaddrv6($config['interfaces'][$interface]['ipaddrv6'])) { + system_routing_configure($interface); + setup_gateways_monitor(); -if (is_ipaddrv6($oldipv6)) { - if ($curwanipv6 == $oldipv6) { - // Still need to sync VPNs on PPPoE and such, as even with the same IP the VPN software is unhappy with the IP disappearing. - if (in_array($config['interfaces'][$interface]['ipaddrv6'], array('pppoe', 'pptp', 'ppp'))) { - /* XXX migrate this: we should unify the reload */ - ipsec_configure_do(false, $inteface); - openvpn_configure_do(false, $interface); + if (is_ipaddrv6($oldipv6)) { + if (does_interface_exist($interface_real)) { + mwexec("/sbin/ifconfig {$interface_real} inet6 {$oldipv6} delete"); } - return; - } elseif (does_interface_exist($interface_real)) { - mwexec("/sbin/ifconfig {$interface_real} inet6 {$oldipv6} delete"); } - file_put_contents("/var/db/{$interface}_cacheipv6", $curwanipv6); + if (is_ipaddrv6($curwanip)) { + @file_put_contents("/var/db/{$interface}_cacheipv6", $curwanipv6); + } + + /* reload plugins */ + plugins_configure('interface', false, array($interface)); + + /* reload graphing functions */ + rrd_configure(); } -/* reload plugins */ -plugins_configure('interface', false, array($interface)); - -/* reload graphing functions */ -rrd_configure(); +/* reload filter, don't try to sync to carp slave */ +filter_configure_sync();