From 434347bb4ecad81faf002f3e8c40bb6201aca4bc Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 9 Apr 2018 07:26:36 +0200 Subject: [PATCH] interfaces: remove unused $flush argument --- src/etc/inc/gwlb.inc | 4 ++-- src/etc/inc/interfaces.inc | 38 ++++++++++++++++++++++--------------- src/etc/rc.initial.setlanip | 2 +- src/etc/rc.newwanipv6 | 4 ++-- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/etc/inc/gwlb.inc b/src/etc/inc/gwlb.inc index 9980a0343..0d5517a71 100644 --- a/src/etc/inc/gwlb.inc +++ b/src/etc/inc/gwlb.inc @@ -688,9 +688,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); + $gateway['interface'] = get_real_interface($gateway['interface'], 'inet6'); } else { - $gateway['interface'] = get_real_interface($gateway['interface'], "all", false); + $gateway['interface'] = get_real_interface($gateway['interface'], 'all'); } /* entry has a default flag, use it */ diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 0eabc84b8..f2fb02ae4 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -3753,7 +3753,7 @@ function interface_get_wireless_clone($wlif) } } -function get_real_interface($interface = "wan", $family = "all", $flush = true) +function get_real_interface($interface = 'wan', $family = 'all') { global $config; @@ -3770,9 +3770,12 @@ function get_real_interface($interface = "wan", $family = "all", $flush = true) break; default: if (empty($config['interfaces'][$interface])) { - // leftover from legacy code, it's not a very bright idea to use the same function call - // for both virtual as real interface names. does_interface_exist() is quite expensive. - if (does_interface_exist($interface, $flush)) { + /* + * Leftover from legacy code. It's not a very bright idea + * to use the same function call for both virtual as real + * interface names. does_interface_exist() is quite expensive. + */ + if (does_interface_exist($interface)) { $wanif = $interface; } break; @@ -4036,17 +4039,22 @@ function find_interface_ipv6($interface) function find_interface_ipv6_ll($interface) { $interface = trim($interface); - if (does_interface_exist($interface)) { - $ifinfo = legacy_getall_interface_addresses($interface); - foreach ($ifinfo as $line) { - if (strstr($line, ":")) { - $parts = explode("/", $line); - if (is_linklocal($parts[0])) { - return $parts[0]; - } + + if (!does_interface_exist($interface)) { + return null; + } + + $ifinfo = legacy_getall_interface_addresses($interface); + + foreach ($ifinfo as $line) { + if (strstr($line, ':')) { + $parts = explode('/', $line); + if (is_linklocal($parts[0])) { + return $parts[0]; } } } + return null; } @@ -4119,7 +4127,7 @@ function get_interface_ip($interface = "wan") } } -function get_interface_ipv6($interface = "wan", $flush = false) +function get_interface_ipv6($interface = 'wan') { global $config; @@ -4148,14 +4156,14 @@ function get_interface_ipv6($interface = "wan", $flush = false) break; } if (isset($config['interfaces'][$interface]['dhcp6prefixonly'])) { - $curip = find_interface_ipv6_ll($realif, $flush); + $curip = find_interface_ipv6_ll($realif); if ($curip && is_ipaddrv6($curip) && ($curip != "::")) { return $curip; } } } - $curip = find_interface_ipv6($realif, $flush); + $curip = find_interface_ipv6($realif); if ($curip && is_ipaddrv6($curip) && ($curip != "::")) { return $curip; } else { diff --git a/src/etc/rc.initial.setlanip b/src/etc/rc.initial.setlanip index 48c4b5f31..0fba1d1df 100755 --- a/src/etc/rc.initial.setlanip +++ b/src/etc/rc.initial.setlanip @@ -575,7 +575,7 @@ echo "\n"; if ($intip != '' || $intip6 != '') { if (count($ifdescrs) == '1' or $interface == 'lan') { $intip = get_interface_ip($interface); - $intip6 = get_interface_ipv6($interface, true); + $intip6 = get_interface_ipv6($interface); echo "You can now access the web GUI by opening\nthe following URL in your web browser:\n\n"; $webuiport = !empty($config['system']['webgui']['port']) ? ":{$config['system']['webgui']['port']}" : ''; if (is_ipaddr($intip)) { diff --git a/src/etc/rc.newwanipv6 b/src/etc/rc.newwanipv6 index 4468ed32b..602e4c050 100755 --- a/src/etc/rc.newwanipv6 +++ b/src/etc/rc.newwanipv6 @@ -51,11 +51,11 @@ log_error("IP renewal is starting on '{$argument}'"); if (empty($argument)) { $interface = 'wan'; $interface_real = get_real_interface($interface, 'inet6'); - $ip = get_interface_ipv6($interface, true); + $ip = get_interface_ipv6($interface); } else { $interface = convert_real_interface_to_friendly_interface_name($argument); $interface_real = $argument; - $ip = get_interface_ipv6($interface, true); + $ip = get_interface_ipv6($interface); } /* If the interface is configured and not enabled, bail. We do not need to change settings for disabled interfaces. #3313 */