From d17e9c737d1a89ace17c65af2dcd4a6f62fa8eaa Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Wed, 23 Mar 2022 18:32:02 +0100 Subject: [PATCH] interfaces: zero prefix "vlan" and "qinq" interface names to prevent collisions on vlans.(https://github.com/opnsense/core/issues/5560) Although the prepended 0 might look less intuitive it prevents overlaps when creating new vlans using "ifconfig vlan create" (https://github.com/opnsense/core/blob/2637e6ebca1a7d26daa4ec28f6bfcc7f15a340eb/src/etc/inc/interfaces.lib.inc#L77), to keep qinq and vlan's consistent prepend on both types. ref https://github.com/opnsense/core/commit/2637e6ebca1a7d26daa4ec28f6bfcc7f15a340eb --- .../OPNsense/Interfaces/Api/VlanSettingsController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Interfaces/Api/VlanSettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Interfaces/Api/VlanSettingsController.php index f6bf7918b..4441017e7 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Interfaces/Api/VlanSettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Interfaces/Api/VlanSettingsController.php @@ -53,13 +53,13 @@ class VlanSettingsController extends ApiMutableModelControllerBase return (string)$current->vlanif; } else { // autonumber new - $ifid = -1; + $ifid = 0; foreach ($this->getModel()->vlan->iterateItems() as $node) { if (strpos((string)$node->vlanif, $prefix) === 0) { $ifid = max($ifid, (int)filter_var((string)$node->vlanif, FILTER_SANITIZE_NUMBER_INT)); } } - return $prefix . ($ifid + 1); + return sprintf("%s0%d", $prefix , ($ifid + 1)); } }