From 7c1caf1a1132589eda2dce764b78be5bfd9cfec3 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Wed, 8 Jan 2025 11:54:29 +0100 Subject: [PATCH] Interfaces: Devices: Bridge - remove non-functional cruft for https://github.com/opnsense/core/issues/8193 --- src/etc/inc/interfaces.inc | 56 +++----------- src/www/interfaces_bridge_edit.php | 117 +---------------------------- 2 files changed, 13 insertions(+), 160 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 895c10932..9707c0c3c 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -271,8 +271,7 @@ function _interfaces_bridge_configure($bridge) if (isset($bridge['enablestp'])) { mwexecf('/sbin/ifconfig %s proto %s', [$bridge['bridgeif'], $bridge['proto']]); if (!empty($bridge['stp'])) { - $stpifs = explode(',', $bridge['stp']); - foreach ($stpifs as $stpif) { + foreach (explode(',', $bridge['stp']) as $stpif) { mwexecf('/sbin/ifconfig %s stp %s', [$bridge['bridgeif'], get_real_interface($stpif)]); } } @@ -285,46 +284,15 @@ function _interfaces_bridge_configure($bridge) if (!empty($bridge['hellotime'])) { mwexec("/sbin/ifconfig {$bridge['bridgeif']} hellotime " . escapeshellarg($bridge['hellotime'])); } - if (!empty($bridge['priority'])) { - mwexec("/sbin/ifconfig {$bridge['bridgeif']} priority " . escapeshellarg($bridge['priority'])); - } if (!empty($bridge['holdcnt'])) { mwexec("/sbin/ifconfig {$bridge['bridgeif']} holdcnt " . escapeshellarg($bridge['holdcnt'])); } - if (!empty($bridge['ifpriority'])) { - $pconfig = explode(",", $bridge['ifpriority']); - $ifpriority = []; - foreach ($pconfig as $cfg) { - $embcfg = explode_assoc(":", $cfg); - foreach ($embcfg as $key => $value) { - $ifpriority[$key] = $value; - } - } - foreach ($ifpriority as $key => $value) { - $realif = get_real_interface($key); - mwexec("/sbin/ifconfig {$bridgeif} ifpriority {$realif} " . escapeshellarg($value)); - } - } - if (!empty($bridge['ifpathcost'])) { - $pconfig = explode(",", $bridge['ifpathcost']); - $ifpathcost = []; - foreach ($pconfig as $cfg) { - $embcfg = explode_assoc(":", $cfg); - foreach ($embcfg as $key => $value) { - $ifpathcost[$key] = $value; - } - } - foreach ($ifpathcost as $key => $value) { - $realif = get_real_interface($key); - mwexec("/sbin/ifconfig {$bridgeif} ifpathcost {$realif} " . escapeshellarg($value)); - } - } } - if ($bridge['maxaddr'] != '') { + if (!empty($bridge['maxaddr'])) { mwexec("/sbin/ifconfig {$bridge['bridgeif']} maxaddr " . escapeshellarg($bridge['maxaddr'])); } - if ($bridge['timeout'] != '') { + if (!empty($bridge['timeout'])) { mwexec("/sbin/ifconfig {$bridge['bridgeif']} timeout " . escapeshellarg($bridge['timeout'])); } if (!empty($bridge['span'])) { @@ -332,43 +300,37 @@ function _interfaces_bridge_configure($bridge) mwexec("/sbin/ifconfig {$bridge['bridgeif']} span {$realif}"); } if (!empty($bridge['edge'])) { - $edgeifs = explode(',', $bridge['edge']); - foreach ($edgeifs as $edgeif) { + foreach (explode(',', $bridge['edge']) as $edgeif) { $realif = get_real_interface($edgeif); mwexec("/sbin/ifconfig {$bridge['bridgeif']} edge {$realif}"); } } if (!empty($bridge['autoedge'])) { - $edgeifs = explode(',', $bridge['autoedge']); - foreach ($edgeifs as $edgeif) { + foreach (explode(',', $bridge['autoedge']) as $edgeif) { $realif = get_real_interface($edgeif); mwexec("/sbin/ifconfig {$bridge['bridgeif']} -autoedge {$realif}"); } } if (!empty($bridge['ptp'])) { - $ptpifs = explode(',', $bridge['ptp']); - foreach ($ptpifs as $ptpif) { + foreach (explode(',', $bridge['ptp']) as $ptpif) { $realif = get_real_interface($ptpif); mwexec("/sbin/ifconfig {$bridge['bridgeif']} ptp {$realif}"); } } if (!empty($bridge['autoptp'])) { - $ptpifs = explode(',', $bridge['autoptp']); - foreach ($ptpifs as $ptpif) { + foreach (explode(',', $bridge['autoptp']) as $ptpif) { $realif = get_real_interface($ptpif); mwexec("/sbin/ifconfig {$bridge['bridgeif']} -autoptp {$realif}"); } } if (!empty($bridge['static'])) { - $stickyifs = explode(',', $bridge['static']); - foreach ($stickyifs as $stickyif) { + foreach (explode(',', $bridge['static']) as $stickyif) { $realif = get_real_interface($stickyif); mwexec("/sbin/ifconfig {$bridge['bridgeif']} sticky {$realif}"); } } if (!empty($bridge['private'])) { - $privateifs = explode(',', $bridge['private']); - foreach ($privateifs as $privateif) { + foreach (explode(',', $bridge['private']) as $privateif) { $realif = get_real_interface($privateif); mwexec("/sbin/ifconfig {$bridge['bridgeif']} private {$realif}"); } diff --git a/src/www/interfaces_bridge_edit.php b/src/www/interfaces_bridge_edit.php index b48b84178..dc7c74b8c 100644 --- a/src/www/interfaces_bridge_edit.php +++ b/src/www/interfaces_bridge_edit.php @@ -44,11 +44,11 @@ foreach (legacy_config_get_interfaces(['virtual' => false]) as $intf => $intfdat if ($_SERVER['REQUEST_METHOD'] === 'GET') { // read form data - if (!empty($a_bridges[$_GET['id']])) { + if (isset($_GET['id']) && !empty($a_bridges[$_GET['id']])) { $id = $_GET['id']; } // copy fields 1-on-1 - $copy_fields = ['descr', 'bridgeif', 'maxaddr', 'timeout', 'maxage','fwdelay', 'hellotime', 'priority', 'proto', 'holdcnt', 'span']; + $copy_fields = ['descr', 'bridgeif', 'maxaddr', 'timeout', 'maxage','fwdelay', 'proto', 'holdcnt', 'span']; foreach ($copy_fields as $fieldname) { if (isset($a_bridges[$id][$fieldname])) { $pconfig[$fieldname] = $a_bridges[$id][$fieldname]; @@ -70,23 +70,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig[$fieldname] = []; } } - - // array key/value sets - if (!empty($a_bridges[$id]['ifpriority'])) { - foreach (explode(",", $a_bridges[$id]['ifpriority']) as $cfg) { - list ($key, $value) = explode(":", $cfg); - $pconfig['ifpriority_'.$key] = $value; - } - } - if (!empty($a_bridges[$id]['ifpathcost'])) { - foreach (explode(",", $a_bridges[$id]['ifpathcost']) as $cfg) { - list ($key, $value) = explode(":", $cfg); - $pconfig['ifpathcost_'.$key] = $value; - } - } } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { // save / validate formdata - if (!empty($a_bridges[$_POST['id']])) { + if (isset($_POST['id']) && !empty($a_bridges[$_POST['id']])) { $id = $_POST['id']; } @@ -109,23 +95,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { if (!empty($pconfig['fwdelay']) && $not_between_int($pconfig['fwdelay'], 4, 30)) { $input_errors[] = gettext("Forward Delay needs to be an integer between 4 and 30."); } - if (!empty($pconfig['hellotime']) && $not_between_int($pconfig['hellotime'], 1, 2)) { - $input_errors[] = gettext("Hello time for STP needs to be an integer between 1 and 2."); - } - if ($pconfig['priority'] != "" && $not_between_int($pconfig['priority'], 0, 61440)) { - $input_errors[] = gettext("Priority for STP needs to be an integer between 0 and 61440."); - } if (!empty($pconfig['holdcnt']) && $not_between_int($pconfig['holdcnt'], 1, 10)) { $input_errors[] = gettext("Transmit Hold Count for STP needs to be an integer between 1 and 10."); } - foreach ($ifacelist as $ifn => $ifdescr) { - if ($pconfig['ifpriority_'.$ifn] != "" && $not_between_int($pconfig['ifpriority_'.$ifn], 0, 240)) { - $input_errors[] = sprintf(gettext("%s interface priority for STP needs to be an integer between 0 and 240."), $ifdescr); - } - if (!empty($pconfig['ifpathcost_'.$ifn]) && $not_between_int($pconfig['ifpathcost_'.$ifn], 1, 200000000)) { - $input_errors[] = sprintf(gettext("%s interface path cost for STP needs to be an integer between 1 and 200000000."), $ifdescr); - } - } $members = !empty($pconfig['members']) ? $pconfig['members'] : []; if (!empty($members)) { @@ -164,7 +136,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } // 1 on 1 copy - $copy_fields = ['descr', 'maxaddr', 'timeout', 'bridgeif', 'maxage','fwdelay', 'hellotime', 'priority', 'proto', 'holdcnt']; + $copy_fields = ['descr', 'maxaddr', 'timeout', 'bridgeif', 'maxage','fwdelay', 'proto', 'holdcnt']; foreach ($copy_fields as $fieldname) { if (isset($pconfig[$fieldname]) && $pconfig[$fieldname] != '') { $bridge[$fieldname] = $pconfig[$fieldname]; @@ -184,24 +156,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } } - // array key/value sets - $bridge['ifpriority'] = ''; - $bridge['ifpathcost'] = ''; - foreach ($ifacelist as $ifn => $ifdescr) { - if (isset($pconfig['ifpriority_'.$ifn]) && $pconfig['ifpriority_' . $ifn] != '') { - if (!empty($bridge['ifpriority'])) { - $bridge['ifpriority'] .= ','; - } - $bridge['ifpriority'] .= $ifn . ':' . $pconfig['ifpriority_' . $ifn]; - } - if (isset($pconfig['ifpathcost_' . $ifn]) && $pconfig['ifpathcost_' . $ifn] != '') { - if (!empty($bridge['ifpathcost'])) { - $bridge['ifpathcost'] .= ','; - } - $bridge['ifpathcost'] .= $ifn . ':' . $pconfig['ifpathcost_' . $ifn]; - } - } - if (empty($bridge['bridgeif'])) { $bridge['bridgeif'] = legacy_interface_create('bridge'); /* XXX find another strategy */ } @@ -392,26 +346,6 @@ $(document).ready(function() { - - () - - - - - - - - - - - - @@ -423,49 +357,6 @@ $(document).ready(function() { - - - - - $ifdescr):?> - - - - - -
- " /> -
- - - - - - - - $ifdescr):?> - - - - - -
- " /> -
- - -