From 682d280755ee7bd2140dca84b5ee21659a4ae580 Mon Sep 17 00:00:00 2001 From: David Wood Date: Thu, 24 Dec 2015 05:50:16 +0000 Subject: [PATCH 1/8] Make ppp-ipv6 the only way interface_dhcpv6_configure() is called on PPP interfaces --- etc/inc/interfaces.inc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index b4254346e2..c1a1fd4ccd 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3019,7 +3019,10 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven switch ($wancfg['ipaddrv6']) { case 'slaac': case 'dhcp6': - interface_dhcpv6_configure($interface, $wancfg); + // The ppp-ipv6 script calls interface_dhcpv6_configure() for PPP connections after IPv6CP is up + if (!interface_isppp_type($interface)) { + interface_dhcpv6_configure($interface, $wancfg); + } break; case '6rd': interface_6rd_configure($interface, $wancfg); From 918b19a62c602e19bbd53f47f4ba596ee8ee949c Mon Sep 17 00:00:00 2001 From: David Wood Date: Thu, 24 Dec 2015 07:10:20 +0000 Subject: [PATCH 2/8] Set temporary bogon (RFC 5737) IPv4 address to work round mpd5 IPv6CP issue causing random IPv6 interface identifier during boot Details at https://forum.pfsense.org/index.php?topic=101967.msg570519#msg570519 . --- etc/inc/interfaces.inc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index c1a1fd4ccd..caefa85e7b 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1818,6 +1818,19 @@ EOD; unlink("{$g['var_path']}/spool/lock/LCK..{$port}"); } + /* Set temporary bogon (RFC 5737) IPv4 address to work round mpd5 IPv6CP issue causing */ + /* random IPv6 interface identifier during boot. More details at */ + /* https://forum.pfsense.org/index.php?topic=101967.msg570519#msg570519 */ + /* N.B. The current work round only supports PPPoE */ + $tempaddr = false; + if (platform_booting() && $type == "pppoe" && is_array($ports) && !empty($ports[0])) { + $tempaddr = true; + $tempaddr_iface = get_real_interface($ports[0]); + if (!empty($tempaddr_iface)) { + mwexec("/sbin/ifconfig " . escapeshellarg($tempaddr_iface) . " inet 192.0.2.248/31 alias", true); + } + } + /* fire up mpd */ mwexec("/usr/local/sbin/mpd5 -b -k -d {$g['varetc_path']} -f mpd_{$interface}.conf -p {$g['varrun_path']}/" . escapeshellarg($ppp['type']) . "_{$interface}.pid -s ppp " . escapeshellarg($ppp['type']) . "client"); @@ -1838,6 +1851,13 @@ EOD; $i++; } + /* Remove work round temporary address */ + if ($tempaddr && !empty($tempaddr_iface)) { + mwexec("/sbin/ifconfig " . escapeshellarg($tempaddr_iface) . " inet 192.0.2.248/31 -alias", true); + unset ($tempaddr_iface); + } + unset ($tempaddr); + /* we only support the 3gstats.php for huawei modems for now. Will add more later. */ /* We should be able to launch the right version for each modem */ /* We can also guess the mondev from the manufacturer */ From e68cb72f3eeebe6d2c83080ec412201b9f2323a7 Mon Sep 17 00:00:00 2001 From: David Wood Date: Tue, 5 Jan 2016 13:05:35 +0000 Subject: [PATCH 3/8] Set temporary bogon (RFC 5737) IPv4 addresses when initialising PPP interfaces during boot to work round mpd5 IPv6CP issue causing random IPv6 interface identifiers Details at https://forum.pfsense.org/index.php?topic=101967.msg570519#msg570519 . --- etc/inc/interfaces.inc | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index caefa85e7b..69542f3346 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1818,17 +1818,24 @@ EOD; unlink("{$g['var_path']}/spool/lock/LCK..{$port}"); } - /* Set temporary bogon (RFC 5737) IPv4 address to work round mpd5 IPv6CP issue causing */ + /* Set temporary bogon (RFC 5737) IPv4 addresses to work round mpd5 IPv6CP issue causing */ /* random IPv6 interface identifier during boot. More details at */ /* https://forum.pfsense.org/index.php?topic=101967.msg570519#msg570519 */ - /* N.B. The current work round only supports PPPoE */ - $tempaddr = false; - if (platform_booting() && $type == "pppoe" && is_array($ports) && !empty($ports[0])) { - $tempaddr = true; - $tempaddr_iface = get_real_interface($ports[0]); - if (!empty($tempaddr_iface)) { - mwexec("/sbin/ifconfig " . escapeshellarg($tempaddr_iface) . " inet 192.0.2.248/31 alias", true); + if (platform_booting() && is_array($config['interfaces'])) { + $count = 0; + foreach ($config['interfaces'] as $tempifacename => $tempiface) { + if ((isset($tempiface['if'])) && (isset($tempiface['ipaddr']) || isset($tempiface['ipaddrv6'])) && !interface_isppp_type($tempifacename)) { + $tempaddr[$count]['if'] = $tempiface['if']; + $tempaddr[$count]['ipaddr'] = '192.0.2.' . strval (10 + ($count * 2)) . '/31'; + mwexec('/sbin/ifconfig ' . escapeshellarg($tempaddr[$count]['if']) . ' inet ' . escapeshellarg($tempaddr[$count]['ipaddr']) . ' alias', true); + $count++; + } + // Maximum /31 is is x.y.z.254/31 + if ($count > 122) { + break; + } } + unset($count); } /* fire up mpd */ @@ -1851,12 +1858,15 @@ EOD; $i++; } - /* Remove work round temporary address */ - if ($tempaddr && !empty($tempaddr_iface)) { - mwexec("/sbin/ifconfig " . escapeshellarg($tempaddr_iface) . " inet 192.0.2.248/31 -alias", true); - unset ($tempaddr_iface); + /* Remove all temporary bogon IPv4 addresses */ + if (is_array($tempaddr)) { + foreach ($tempaddr as $tempiface) { + if (isset($tempiface['if']) && isset($tempiface['ipaddr'])) { + mwexec('/sbin/ifconfig ' . escapeshellarg($tempiface['if']) . ' inet ' . escapeshellarg($tempiface['ipaddr']) . ' -alias', true); + } + } + unset ($tempaddr); } - unset ($tempaddr); /* we only support the 3gstats.php for huawei modems for now. Will add more later. */ /* We should be able to launch the right version for each modem */ From a31457d9614b7b3f57ea4864eca056a387a570c6 Mon Sep 17 00:00:00 2001 From: David Wood Date: Wed, 6 Jan 2016 01:42:54 +0000 Subject: [PATCH 4/8] Make ppp-ipv6 the only way interface_dhcpv6_configure() is called on PPP connections using PPP as the IPv6 parent interface --- etc/inc/interfaces.inc | 5 +++-- etc/rc.newwanip | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 69542f3346..3982a6752f 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3049,8 +3049,9 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven switch ($wancfg['ipaddrv6']) { case 'slaac': case 'dhcp6': - // The ppp-ipv6 script calls interface_dhcpv6_configure() for PPP connections after IPv6CP is up - if (!interface_isppp_type($interface)) { + // N.B. PPP connections using PPP as the IPv6 parent interface are excluded because the ppp-ipv6 script + // calls interface_dhcpv6_configure() for these connections after IPv6CP is up + if (!(interface_isppp_type($interface) && isset($wancfg['dhcp6usev4iface']))) { interface_dhcpv6_configure($interface, $wancfg); } break; diff --git a/etc/rc.newwanip b/etc/rc.newwanip index d992c7150b..6d86f036bb 100755 --- a/etc/rc.newwanip +++ b/etc/rc.newwanip @@ -159,7 +159,9 @@ switch($config['interfaces'][$interface]['ipaddrv6']) { interface_6rd_configure($interface, $config['interfaces'][$interface]); break; case "dhcp6": - if (isset($config['interfaces'][$interface]['dhcp6usev4iface'])) + // N.B. PPP connections using PPP as the IPv6 parent interface are excluded because the ppp-ipv6 script calls + // interface_dhcpv6_configure() for these connections after IPv6CP is up + if (isset($config['interfaces'][$interface]['dhcp6usev4iface']) && !interface_isppp_type($interface)) { interface_dhcpv6_configure($interface, $config['interfaces'][$interface]); break; } From 3bcd4ff62371fe7bc53145e55ccdd2d479475ee6 Mon Sep 17 00:00:00 2001 From: David Wood Date: Wed, 6 Jan 2016 02:03:07 +0000 Subject: [PATCH 5/8] Prevent ppp-ipv6 from taking any action when dhcp6 is active on the parent interface, not the PPP interface --- usr/local/sbin/ppp-ipv6 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/usr/local/sbin/ppp-ipv6 b/usr/local/sbin/ppp-ipv6 index a05a4c2d4c..b1cac73e46 100755 --- a/usr/local/sbin/ppp-ipv6 +++ b/usr/local/sbin/ppp-ipv6 @@ -25,6 +25,10 @@ function interface_ipv6_lower($interface_real) { switch ($ifcfg['ipaddrv6']) { case 'slaac': case 'dhcp6': + // Take no action if dhcp6 is active on the parent interface, not the PPP interface + if ($ifcfg['ipaddrv6']==='dhcp6' && !isset($ifcfg['dhcp6usev4iface'])) { + break; + } // bring down dhcp6c if it is running $pidv6 = find_dhcp6c_process($interface_real); if ($pidv6) { @@ -65,6 +69,10 @@ function interface_ipv6_raise($interface_real) { switch ($ifcfg['ipaddrv6']) { case 'slaac': case 'dhcp6': + // Take no action if dhcp6 is active on the parent interface, not the PPP interface + if ($ifcfg['ipaddrv6']==='dhcp6' && !isset($ifcfg['dhcp6usev4iface'])) { + break; + } $pidv6 = find_dhcp6c_process($interface_real); if (empty($pidv6)) { // only fire if router advertisements off From 5a640581b63121fbc92d721fa45b6b23c3bdebce Mon Sep 17 00:00:00 2001 From: David Wood Date: Wed, 6 Jan 2016 03:49:42 +0000 Subject: [PATCH 6/8] Stop enabling router advertisements by default --- etc/inc/interfaces.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 3982a6752f..8baebf9275 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3610,7 +3610,6 @@ function interface_dhcpv6_configure($interface = "wan", $wancfg) { @chmod("{$g['varetc_path']}/rtsold_{$wanif}_script.sh", 0755); /* accept router advertisements for this interface */ - set_single_sysctl("net.inet6.ip6.accept_rtadv", "1"); log_error("Accept router advertisements on interface {$wanif} "); mwexec("/sbin/ifconfig {$wanif} inet6 accept_rtadv"); From 20d6e88a88ae128f2c40a164e9b19e63e3c2e0f5 Mon Sep 17 00:00:00 2001 From: David Wood Date: Wed, 6 Jan 2016 09:19:52 +0000 Subject: [PATCH 7/8] Attempt to ensure interface_dhcpv6_configure() is called at the most appropriate time * ppp-ipv6 for PPP type with dhcp6usev4iface (or PPP without dhcp6usev4iface, as dhcp6usev4iface appears to be a no-op on this type of connection) * rc.newwanip for non-PPP type with dhcp6usev4iface (no change in this commit) * interface_configure() in all other cases --- etc/inc/interfaces.inc | 5 +++-- usr/local/sbin/ppp-ipv6 | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 8baebf9275..6eb6f6f67d 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3050,8 +3050,9 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven case 'slaac': case 'dhcp6': // N.B. PPP connections using PPP as the IPv6 parent interface are excluded because the ppp-ipv6 script - // calls interface_dhcpv6_configure() for these connections after IPv6CP is up - if (!(interface_isppp_type($interface) && isset($wancfg['dhcp6usev4iface']))) { + // calls interface_dhcpv6_configure() for these connections after IPv6CP is up, whilst rc.newwanip + // handles all non-PPP connections with 'dhcp6usev4iface' set + if (!(isset($wancfg['dhcp6usev4iface']) || $wancfg['ipaddr']==='ppp')) { interface_dhcpv6_configure($interface, $wancfg); } break; diff --git a/usr/local/sbin/ppp-ipv6 b/usr/local/sbin/ppp-ipv6 index b1cac73e46..b7bb9f2d6e 100755 --- a/usr/local/sbin/ppp-ipv6 +++ b/usr/local/sbin/ppp-ipv6 @@ -26,7 +26,7 @@ function interface_ipv6_lower($interface_real) { case 'slaac': case 'dhcp6': // Take no action if dhcp6 is active on the parent interface, not the PPP interface - if ($ifcfg['ipaddrv6']==='dhcp6' && !isset($ifcfg['dhcp6usev4iface'])) { + if ($ifcfg['ipaddrv6']==='dhcp6' && !(isset($ifcfg['dhcp6usev4iface']) || $ifcfg['ipaddr']==='ppp')) { break; } // bring down dhcp6c if it is running @@ -70,7 +70,7 @@ function interface_ipv6_raise($interface_real) { case 'slaac': case 'dhcp6': // Take no action if dhcp6 is active on the parent interface, not the PPP interface - if ($ifcfg['ipaddrv6']==='dhcp6' && !isset($ifcfg['dhcp6usev4iface'])) { + if ($ifcfg['ipaddrv6']==='dhcp6' && !(isset($ifcfg['dhcp6usev4iface']) || $ifcfg['ipaddr']==='ppp')) { break; } $pidv6 = find_dhcp6c_process($interface_real); From 0faf3300669dd9d70a78b2636874f87c78f48a47 Mon Sep 17 00:00:00 2001 From: David Wood Date: Wed, 6 Jan 2016 19:17:49 +0000 Subject: [PATCH 8/8] Insert missing close brace --- etc/rc.newwanip | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/rc.newwanip b/etc/rc.newwanip index 6d86f036bb..e65050b5d9 100755 --- a/etc/rc.newwanip +++ b/etc/rc.newwanip @@ -163,6 +163,7 @@ switch($config['interfaces'][$interface]['ipaddrv6']) { // interface_dhcpv6_configure() for these connections after IPv6CP is up if (isset($config['interfaces'][$interface]['dhcp6usev4iface']) && !interface_isppp_type($interface)) { interface_dhcpv6_configure($interface, $config['interfaces'][$interface]); + } break; }