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" (2637e6ebca/src/etc/inc/interfaces.lib.inc (L77)), to keep qinq and vlan's consistent prepend on both types.

ref 2637e6ebca
This commit is contained in:
Ad Schellevis 2022-03-23 18:32:02 +01:00
parent aa3c27df0b
commit d17e9c737d

View File

@ -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));
}
}