diff --git a/src/etc/inc/gwlb.inc b/src/etc/inc/gwlb.inc index bbad31e09..0a50d3711 100644 --- a/src/etc/inc/gwlb.inc +++ b/src/etc/inc/gwlb.inc @@ -680,9 +680,9 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive /* special treatment for tunnel interfaces */ if ($gateway['ipprotocol'] == "inet6") { - $gateway['interface'] = get_real_interface($gateway['interface'], "inet6", false, false); + $gateway['interface'] = get_real_interface($gateway['interface'], "inet6", false); } else { - $gateway['interface'] = get_real_interface($gateway['interface'], "all", false, false); + $gateway['interface'] = get_real_interface($gateway['interface'], "all", false); } /* entry has a default flag, use it */ diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 277e5b31f..c1e71e6eb 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -1116,19 +1116,29 @@ function interface_bring_down($interface = "wan", $ifacecfg = false) return; } - /* - * NOTE: The $realifv6 is needed when WANv4 is type PPP and v6 is DHCP and the option v6 from v4 is used. - * In this case the real $realif of v4 is different from that of v6 for operation. - * Keep this in mind while doing changes here! - */ + $realif = get_real_interface($interface); + $realifv6 = get_real_interface($interface, "inet6"); + if (!in_array($interface, array('openvpn', 'ppp', 'ipsec', 'enc0'))) { + /** + * NOTE: The $realifv6 is needed when WANv4 is type PPP and v6 is DHCP and the option v6 from v4 is used. + * XXX: we kept this in place due to dropping the $realv6iface parameter from get_real_interface(), + */ + $cfg = &config_read_array('interfaces', $interface); + $ipaddrv6 = empty($cfg['ipaddrv6']) ? null : $cfg['ipaddrv6']; + if (!in_array($ipaddrv6, array('6rd', '6to4', 'pppoe', 'ppp', 'l2tp', 'pptp'))) { + $ipaddr = empty($cfg['ipaddr']) ? null : $cfg['ipaddr']; + if (in_array($ipaddr, array('pppoe', 'ppp', 'l2tp', 'pptp'))) { + $parents = get_parent_interface($interface); + $realifv6 = !empty($parents[0]) ? $parents[0] : $cfg['if']; + } + } + } if ($ifacecfg === false) { $ifcfg = $config['interfaces'][$interface]; $ppps = array(); if (isset($config['ppps']['ppp'])) { $ppps = $config['ppps']['ppp']; } - $realif = get_real_interface($interface); - $realifv6 = get_real_interface($interface, "inet6", true); } elseif (!is_array($ifacecfg)) { log_error('Wrong parameters used during interface_bring_down()'); $ifcfg = $config['interfaces'][$interface]; @@ -1136,8 +1146,6 @@ function interface_bring_down($interface = "wan", $ifacecfg = false) if (isset($config['ppps']['ppp'])) { $ppps = $config['ppps']['ppp']; } - $realif = get_real_interface($interface); - $realifv6 = get_real_interface($interface, "inet6", true); } else { $ifcfg = $ifacecfg['ifcfg']; $ppps = $ifacecfg['ppps']; @@ -1145,9 +1153,6 @@ function interface_bring_down($interface = "wan", $ifacecfg = false) $realif = $ifacecfg['ifcfg']['realif']; /* XXX: Any better way? */ $realifv6 = $realif; - } else { - $realif = get_real_interface($interface); - $realifv6 = get_real_interface($interface, "inet6", true); } } @@ -3872,7 +3877,7 @@ function interface_get_wireless_clone($wlif) } } -function get_real_interface($interface = "wan", $family = "all", $realv6iface = false, $flush = true) +function get_real_interface($interface = "wan", $family = "all", $flush = true) { global $config; @@ -3926,7 +3931,7 @@ function get_real_interface($interface = "wan", $family = "all", $realv6iface = case 'ppp': case 'l2tp': case 'pptp': - if (isset($cfg['dhcp6usev4iface']) && $realv6iface === false) { + if (isset($cfg['dhcp6usev4iface'])) { $wanif = $cfg['if']; } else { $parents = get_parent_interface($interface); diff --git a/src/www/interfaces.php b/src/www/interfaces.php index ff0f7da1f..ed90c106c 100644 --- a/src/www/interfaces.php +++ b/src/www/interfaces.php @@ -363,6 +363,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig['dhcp6sendsolicit'] = isset($a_interfaces[$if]['dhcp6sendsolicit']); $pconfig['dhcp6prefixonly'] = isset($a_interfaces[$if]['dhcp6prefixonly']); $pconfig['dhcp6usev4iface'] = isset($a_interfaces[$if]['dhcp6usev4iface']); + // Due to the settings being split per interface type, we need to copy the settings that use the same + // config directive. + $pconfig['staticv6usev4iface'] = $pconfig['dhcp6usev4iface']; $pconfig['adv_dhcp6_debug'] = isset($a_interfaces[$if]['adv_dhcp6_debug']); $pconfig['track6-prefix-id--hex'] = sprintf("%x", empty($pconfig['track6-prefix-id']) ? 0 :$pconfig['track6-prefix-id']); @@ -1049,6 +1052,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { // switch ipv6 config by type switch($pconfig['type6']) { case "staticv6": + if (!empty($pconfig['staticv6usev4iface'])) { + $new_config['dhcp6usev4iface'] = true; + } $new_config['ipaddrv6'] = $pconfig['ipaddrv6']; $new_config['subnetv6'] = $pconfig['subnetv6']; if ($pconfig['gatewayv6'] != "none") { @@ -2358,6 +2364,17 @@ include("head.inc"); + + + + /> + + +