Commit 15fd790f authored by Franco Fichtner's avatar Franco Fichtner

interfaces: slightly restructure the netgraph needed logic

(cherry picked from commit 79b125c2)
parent b2e8049e
...@@ -134,76 +134,68 @@ function does_interface_exist($interface) ...@@ -134,76 +134,68 @@ function does_interface_exist($interface)
} }
} }
function interface_netgraph_needed($interface)
function interface_netgraph_needed($interface = "wan")
{ {
global $config; global $config;
$found = false; if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == 'server') {
if (!empty($config['pptpd']) && if ('wan' == $interface) {
$config['pptpd']['mode'] == "server" return true;
) { }
$found = true;
} }
if (!$found && !empty($config['l2tp']) &&
$config['l2tp']['mode'] == "server" if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == 'server') {
) { if ($config['l2tp']['interface'] == $interface) {
$found = true; return true;
}
} }
if (!$found && isset($config['pppoes']['pppoe']) && is_array($config['pppoes']['pppoe'])) {
if (isset($config['pppoes']['pppoe'])) {
foreach ($config['pppoes']['pppoe'] as $pppoe) { foreach ($config['pppoes']['pppoe'] as $pppoe) {
if ($pppoe['mode'] != "server") { if ($pppoe['mode'] != 'server') {
continue; continue;
} }
if ($pppoe['interface'] == $interface) { if ($pppoe['interface'] == $interface) {
$found = true; return true;
} }
break;
} }
} }
if (!$found) {
if (!empty($config['interfaces'][$interface])) { if (isset($config['interfaces'][$interface]['ipaddr'])) {
switch ($config['interfaces'][$interface]['ipaddr']) { switch ($config['interfaces'][$interface]['ipaddr']) {
case "ppp": case 'ppp':
case "pppoe": case 'pppoe':
case "l2tp": case 'l2tp':
case "pptp": case 'pptp':
$found = true; return true;
break; default:
default: break;
$found = false;
break;
}
} }
} }
if (!$found) {
$realif = get_real_interface($interface); $realif = get_real_interface($interface);
if (isset($config['ppps']['ppp'])) {
foreach ($config['ppps']['ppp'] as $pppid => $ppp) { if (isset($config['ppps']['ppp'])) {
$ports = explode(',', $ppp['ports']); foreach ($config['ppps']['ppp'] as $pppid => $ppp) {
foreach ($ports as $pid => $port) { $ports = explode(',', $ppp['ports']);
$port = get_real_interface($port); foreach ($ports as $pid => $port) {
if ($realif == $port) { $port = get_real_interface($port);
$found = true; if ($realif == $port) {
break; return true;
} }
/* Find the parent interfaces of the vlans in the MLPPP configs /*
* there should be only one element in the array here * Find the parent interfaces of the vlans in the MLPPP
* -- this could be better . . . */ * configs there should be only one element in the array
$parent_if = get_parent_interface($port); */
if ($realif == $parent_if[0]) { $parent_if = get_parent_interface($port);
$found = true; if ($realif == $parent_if[0]) {
break; return true;
}
} }
} }
} }
} }
if (!$found) { return false;
$realif = get_real_interface($interface);
legacy_netgraph_detach($realif);
}
} }
function interfaces_loopback_configure() function interfaces_loopback_configure()
...@@ -3125,7 +3117,9 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven ...@@ -3125,7 +3117,9 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
interfaces_bring_up($wancfg['if']); interfaces_bring_up($wancfg['if']);
} }
interface_netgraph_needed($interface); if (!interface_netgraph_needed($interface)) {
legacy_netgraph_detach($realif);
}
if (!file_exists("/var/run/booting")) { if (!file_exists("/var/run/booting")) {
link_interface_to_vips($interface, "update"); link_interface_to_vips($interface, "update");
......
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