From d8f209420d889ceee816200c4bab96d56c4dd5fa Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Fri, 20 Jan 2023 18:57:18 +0100 Subject: [PATCH] Interfaces/Other Types/VLAN - outer vlan should be marked "ad", inner is always "q". closes https://github.com/opnsense/core/issues/5893 --- src/etc/inc/interfaces.inc | 7 +++++-- src/opnsense/scripts/interfaces/reconfigure_vlans.php | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index aba506fbe..8ca160bed 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -154,11 +154,14 @@ function interfaces_vlan_configure($verbose = false) $all_parents = []; foreach ($config['vlans']['vlan'] as $vlan) { if (!in_array($vlan['vlanif'], $all_parents)) { - $all_parents[] = $vlan['vlanif']; + if (!isset($all_parents[$vlan['if']])) { + $all_parents[$vlan['if']] = 0; + } + $all_parents[$vlan['if']]++ ; } } foreach ($config['vlans']['vlan'] as $vlan) { - $vlan['proto'] = !in_array($vlan['if'], $all_parents) ? '802.1q' : '802.1ad'; + $vlan['proto'] = empty($all_parents[$vlan['vlanif']]) ? '802.1q' : '802.1ad'; _interfaces_vlan_configure($vlan); } diff --git a/src/opnsense/scripts/interfaces/reconfigure_vlans.php b/src/opnsense/scripts/interfaces/reconfigure_vlans.php index 13e45d108..143561918 100755 --- a/src/opnsense/scripts/interfaces/reconfigure_vlans.php +++ b/src/opnsense/scripts/interfaces/reconfigure_vlans.php @@ -54,9 +54,10 @@ if (file_exists($vfilename) && filesize($vfilename) > 0) { if (!empty($config['vlans']['vlan'])) { foreach ($config['vlans']['vlan'] as $vlan) { $all_vlans[$vlan['vlanif']] = $vlan; - if (!in_array($vlan['vlanif'], $all_parents)) { - $all_parents[] = $vlan['vlanif']; + if (!isset($all_parents[$vlan['if']])) { + $all_parents[$vlan['if']] = 0; } + $all_parents[$vlan['if']]++ ; } } @@ -67,7 +68,7 @@ foreach (legacy_interfaces_details() as $ifname => $ifdetails) { } if (isset($all_vlans[$ifname])) { $vlan = $all_vlans[$ifname]; - $vlan['proto'] = !in_array($vlan['if'], $all_parents) ? '802.1q' : '802.1ad'; + $vlan['proto'] = empty($all_parents[$vlan['vlanif']]) ? '802.1q' : '802.1ad'; $cvlan = $ifdetails['vlan']; if (empty($vlan)) { // option 1: removed vlan