Commit 9374b8ad authored by Franco Fichtner's avatar Franco Fichtner

interfaces: fix edge case parsing of flags, mtu and laggport

parent 37f92da4
......@@ -160,7 +160,7 @@ function legacy_vlan_tag($ifs, $member, $tag, $pcp)
}
}
function legacy_interface_stats($ifs=null)
function legacy_interface_stats($ifs = null)
{
if ($ifs != null) {
// only request data for selected interface
......@@ -218,7 +218,7 @@ function legacy_interfaces_details($intf = null)
$current_interface = null;
foreach ($ifconfig_data as $line) {
$line_parts = explode(' ', $line);
if (strpos(trim($line), 'flags=') !== false) {
if (strpos(trim($line), 'flags=') !== false && $line[0] != "\t") {
$current_interface = explode(':', $line)[0];
$result[$current_interface] = array();
$result[$current_interface]["capabilities"] = array();
......@@ -226,6 +226,9 @@ function legacy_interfaces_details($intf = null)
$result[$current_interface]["macaddr"] = "00:00:00:00:00:00";
$result[$current_interface]["ipv4"] = array();
$result[$current_interface]["ipv6"] = array();
if (preg_match("/ mtu ([0-9]*).*$/", $line, $matches)) {
$result[$current_interface]["mtu"] = $matches[1];
}
} elseif (empty($current_interface)) {
// skip parsing, no interface found (yet)
continue;
......@@ -291,7 +294,7 @@ function legacy_interfaces_details($intf = null)
if (empty($result[$current_interface]['laggport'])) {
$result[$current_interface]['laggport'] = array();
}
$result[$current_interface]['laggport'][] = $matches[1];
$result[$current_interface]['laggport'][] = explode(' ', trim($matches[1]))[0];
}
}
......
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