From 7e677d8555d2eba1f72d2b3581b3042005c78544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20LU=C3=87I?= Date: Thu, 27 Nov 2014 15:06:39 +0100 Subject: Simplify code flow not functional change just aesthetics. --- etc/rc.linkup | 85 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/etc/rc.linkup b/etc/rc.linkup index 923679a..372d7b6 100755 --- a/etc/rc.linkup +++ b/etc/rc.linkup @@ -36,6 +36,9 @@ require_once("filter.inc"); require_once("shaper.inc"); require_once("interfaces.inc"); +if (platform_booting()) + return; + function handle_argument_group($iface, $argument2) { global $config; @@ -95,51 +98,49 @@ function handle_argument_group($iface, $argument2) { } } -if (!platform_booting()) { - if (isset($_GET['interface'])) { - if (!empty($_GET['interface'])) - $realiface = $_GET['interface']; - $action = $_GET['action']; - } else { - if ($argc < 3) { - log_error("HOTPLUG event: The required number of parameters not passed!"); - return; - } - $action = $argv[1]; - $realiface = $argv[2]; +if (isset($_GET['interface'])) { + if (!empty($_GET['interface'])) + $realiface = $_GET['interface']; + $action = $_GET['action']; +} else { + if ($argc < 3) { + log_error("HOTPLUG event: The required number of parameters not passed!"); + return; } - switch($action) { - case "start": - case "stop": - break; - default: - log_error("HOTPLUG event: Action parameter ($action) passed is wrong - only start/stop/up/down are allowed!"); + $action = $argv[1]; + $realiface = $argv[2]; +} +switch($action) { +case "start": +case "stop": + break; +default: + log_error("HOTPLUG event: Action parameter ($action) passed is wrong - only start/stop/up/down are allowed!"); + return; + /* NOTREACHED */ + break; +} +if (!empty($realiface)) { + if (substr($realiface, 0, 4) == 'ovpn') { + log_error("Ignoring link event for ovpn interface"); return; - /* NOTREACHED */ - break; } - if (!empty($realiface)) { - if (substr($realiface, 0, 4) == 'ovpn') { - log_error("Ignoring link event for ovpn interface"); - return; - } - $interface = convert_real_interface_to_friendly_interface_name($realiface); - if (!empty($interface)) - handle_argument_group($interface, $action); - if ($action == 'start') { - /* Check if there is any child on this one as ppp types and trigger them */ - if (is_array($config['ppps']['ppp'])) { - foreach ($config['ppps']['ppp'] as $pppidx => $ppp) { - if ($ppp['type'] == 'ppp') - continue; - $ports = explode(',', $ppp['ports']); - foreach ($ports as $pid => $parent_if) { - /* The loop here is because ppp types can have real and assigned interfaces as members */ - $tmpiface = get_real_interface($parent_if); - $tmpiface = convert_real_interface_to_friendly_interface_name($realiface); - if (!empty($tmpiface)) - interface_configure($tmpiface, true, true); - } + $interface = convert_real_interface_to_friendly_interface_name($realiface); + if (!empty($interface)) + handle_argument_group($interface, $action); + if ($action == 'start') { + /* Check if there is any child on this one as ppp types and trigger them */ + if (is_array($config['ppps']['ppp'])) { + foreach ($config['ppps']['ppp'] as $pppidx => $ppp) { + if ($ppp['type'] == 'ppp') + continue; + $ports = explode(',', $ppp['ports']); + foreach ($ports as $pid => $parent_if) { + /* The loop here is because ppp types can have real and assigned interfaces as members */ + $tmpiface = get_real_interface($parent_if); + $tmpiface = convert_real_interface_to_friendly_interface_name($realiface); + if (!empty($tmpiface)) + interface_configure($tmpiface, true, true); } } } -- cgit v1.1