Commit dcb0f60d authored by Franco Fichtner's avatar Franco Fichtner

interfaces: small steps towards better PPPoE IPv6 handling #1403

(cherry picked from commit 8ebc1223)
parent 2c8b2d13
...@@ -1238,8 +1238,11 @@ function interface_bring_down($interface = "wan", $destroy = false, $ifacecfg = ...@@ -1238,8 +1238,11 @@ function interface_bring_down($interface = "wan", $destroy = false, $ifacecfg =
@unlink("/var/db/{$interface}ip"); @unlink("/var/db/{$interface}ip");
@unlink("/var/db/{$interface}ipv6"); @unlink("/var/db/{$interface}ipv6");
@unlink("/var/etc/nameserver_{$realif}"); @unlink("/var/etc/nameserver_{$realif}");
@unlink("/var/etc/nameserver_v6{$realif}");
@unlink("/var/etc/searchdomain_{$realif}"); @unlink("/var/etc/searchdomain_{$realif}");
@unlink("/var/etc/searchdomain_v6{$realif}");
@unlink("/tmp/{$realif}up"); @unlink("/tmp/{$realif}up");
@unlink("/tmp/{$realif}upv6");
@unlink("/tmp/{$realif}_router"); @unlink("/tmp/{$realif}_router");
@unlink("/tmp/{$realif}_routerv6"); @unlink("/tmp/{$realif}_routerv6");
......
...@@ -63,16 +63,16 @@ if (empty($interface)) { ...@@ -63,16 +63,16 @@ if (empty($interface)) {
} }
//Do not process while booting //Do not process while booting
if (file_exists("/var/run/booting") && $config['interfaces'][$interface]['ipaddrv6'] != "dhcp6") if (file_exists("/var/run/booting") && $config['interfaces'][$interface]['ipaddrv6'] != "dhcp6") {
return; return;
}
/* /*
* NOTE: Take care of openvpn and similar if you generate the event to reconfigure an interface. * NOTE: Take care of openvpn and similar if you generate the event to reconfigure an interface.
* i.e. OpenVPN might be in tap mode and not have an ip. * i.e. OpenVPN might be in tap mode and not have an ip.
*/ */
if ((empty($curwanipv6) || !is_ipaddrv6($curwanipv6)) && substr($interface_real, 0, 4) != "ovpn") { if ((empty($curwanipv6) || !is_ipaddrv6($curwanipv6)) && substr($interface_real, 0, 4) != "ovpn") {
log_error("rc.newwanipv6: Failed to update {$interface_descr}[{$interface}] IPv6, restarting..."); log_error("rc.newwanipv6: Failed to detect IPv6 for {$interface_descr}[{$interface}]");
// configd_run("interface reconfigure {$interface}");
return; return;
} }
...@@ -85,26 +85,31 @@ if (!empty($new_domain_name_servers)) { ...@@ -85,26 +85,31 @@ if (!empty($new_domain_name_servers)) {
$valid_ns[] = trim($ns); $valid_ns[] = trim($ns);
} }
if (count($valid_ns > 0)) 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"); $new_domain_name = getenv("new_domain_name");
if (!empty($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 */ /* write current WAN IPv6 to file */
if (is_ipaddrv6($curwanipv6)) if (is_ipaddrv6($curwanipv6)) {
@file_put_contents("/var/db/{$interface}_ipv6", $curwanipv6); @file_put_contents("/var/db/{$interface}_ipv6", $curwanipv6);
}
log_error("rc.newwanipv6: on (IP address: {$curwanipv6}) (interface: {$interface}) (real interface: {$interface_real})."); log_error("rc.newwanipv6: on (IP address: {$curwanipv6}) (interface: {$interface}) (real interface: {$interface_real}).");
$oldipv6 = ""; $oldipv6 = "";
if (file_exists("/var/db/{$interface}_cacheipv6")) 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); $grouptmp = link_interface_to_group($interface);
if (!empty($grouptmp)) if (!empty($grouptmp)) {
array_walk($grouptmp, 'interface_group_add_member'); array_walk($grouptmp, 'interface_group_add_member');
}
link_interface_to_track6($interface, "update"); link_interface_to_track6($interface, "update");
system_resolvconf_generate(); system_resolvconf_generate();
...@@ -124,12 +129,14 @@ if (is_ipaddrv6($oldipv6)) { ...@@ -124,12 +129,14 @@ if (is_ipaddrv6($oldipv6)) {
} }
/* start OpenVPN server & clients */ /* start OpenVPN server & clients */
if (substr($interface_real, 0, 4) != "ovpn") if (substr($interface_real, 0, 4) != "ovpn") {
openvpn_resync_all($interface); openvpn_resync_all($interface);
}
} }
return; return;
} else if (does_interface_exist($interface_real)) } elseif (does_interface_exist($interface_real)) {
mwexec("/sbin/ifconfig {$interface_real} inet6 {$oldipv6} delete"); mwexec("/sbin/ifconfig {$interface_real} inet6 {$oldipv6} delete");
}
file_put_contents("/var/db/{$interface}_cacheipv6", $curwanipv6); file_put_contents("/var/db/{$interface}_cacheipv6", $curwanipv6);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment