Commit 20df3371 authored by Ad Schellevis's avatar Ad Schellevis

(vlan's) fix error handling, add description, closes https://github.com/opnsense/core/issues/1247

parent 89c2f17e
...@@ -35,7 +35,7 @@ function vlan_inuse($vlan_intf) { ...@@ -35,7 +35,7 @@ function vlan_inuse($vlan_intf) {
global $config; global $config;
foreach ($config['interfaces'] as $if => $intf) { foreach ($config['interfaces'] as $if => $intf) {
if ($intf['if'] == $vlan_intf) { if ($intf['if'] == $vlan_intf) {
return true; return $if;
} }
} }
return false; return false;
...@@ -53,8 +53,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -53,8 +53,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} }
if (!empty($_POST['action']) && $_POST['action'] == "del" && isset($id)) { if (!empty($_POST['action']) && $_POST['action'] == "del" && isset($id)) {
if (vlan_inuse($a_vlans[$id])) { if (($ifid = vlan_inuse($a_vlans[$id]['vlanif'])) !== false) {
$input_errors[] = gettext("This VLAN cannot be deleted because it is still being used as an interface."); $ifdescr = empty($config['interfaces'][$ifid]['descr']) ? $ifid : $config['interfaces'][$ifid]['descr'];
$input_errors[] = sprintf(
gettext("This VLAN cannot be deleted because it is still being used as an interface (%s).")
, $ifdescr);
} else { } else {
if (does_interface_exist($a_vlans[$id]['vlanif'])) { if (does_interface_exist($a_vlans[$id]['vlanif'])) {
legacy_interface_destroy($a_vlans[$id]['vlanif']); legacy_interface_destroy($a_vlans[$id]['vlanif']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment