From 77eda8d57ed38cf8510d494a4294e7f0d4fe7e52 Mon Sep 17 00:00:00 2001 From: Luiz Souza Date: Wed, 25 Oct 2017 12:20:17 -0500 Subject: [PATCH] Fix the interface_is_vlan() function. It now works when only QinQ VLANs exist in the system. --- src/etc/inc/interfaces.inc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 4908d40fe8..aef1e10872 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -288,7 +288,7 @@ function vlan_inuse($vlan) { function interface_is_vlan($if = NULL) { global $config; - if ($if == NULL || empty($if) || !is_array($config['vlans']['vlan'])) { + if ($if == NULL || empty($if)) { return (NULL); } @@ -299,20 +299,20 @@ function interface_is_vlan($if = NULL) { } /* Find the VLAN interface. */ - foreach ($config['vlans']['vlan'] as $vlanidx => $vlan) { - if ($if == $vlan['vlanif']) { - return ($vlan); + if (isset($config['vlans']['vlan']) && is_array($config['vlans']['vlan'])) { + foreach ($config['vlans']['vlan'] as $vlanidx => $vlan) { + if ($if == $vlan['vlanif']) { + return ($vlan); + } } } /* Check for the first level tag in QinQ interfaces. */ - if (!isset($config['qinqs']['qinqentry']) || - !is_array($config['qinqs']['qinqentry'])) { - return (NULL); - } - foreach ($config['qinqs']['qinqentry'] as $qinqidx => $qinq) { - if ($if == $qinq['vlanif']) { - return ($qinq); + if (isset($config['qinqs']['qinqentry']) && is_array($config['qinqs']['qinqentry'])) { + foreach ($config['qinqs']['qinqentry'] as $qinqidx => $qinq) { + if ($if == $qinq['vlanif']) { + return ($qinq); + } } }