probe media before applying new settings, exclude vlan's (align to configure_interface_hardware()). for https://github.com/opnsense/core/issues/3198

We could debate that media is hardware setting and thus should move to configure_interface_hardware(), but seems to be the case for more settings in interface_configure().
Maybe it's an idea to move all of these things to a single point later, so legacy_interface_details() only needs to be called once.
This commit is contained in:
Ad Schellevis 2019-02-06 18:58:20 +01:00
parent e4393e0dec
commit 7aab4a99d3
2 changed files with 16 additions and 8 deletions

View File

@ -2406,16 +2406,23 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal
}
}
/* media */
if (!empty($wancfg['media']) || !empty($wancfg['mediaopt'])) {
$cmd = "/sbin/ifconfig " . escapeshellarg($realhwif);
if (!empty($wancfg['media'])) {
$cmd .= " media " . escapeshellarg($wancfg['media']);
}
/* skip vlans for media setup and only apply when changed */
if (!stristr($realhwif, "_vlan") && (!empty($wancfg['media']) || !empty($wancfg['mediaopt']))) {
$intf_details = legacy_interface_details($realhwif);
$media_changed = stripos($intf_details['media_raw'], $wancfg['media']) == false;
if (!empty($wancfg['mediaopt'])) {
$cmd .= " mediaopt " . escapeshellarg($wancfg['mediaopt']);
$media_changed |= stripos($intf_details['media_raw'], $wancfg['mediaopt']) == false;
}
if ($media_changed) {
$cmd = "/sbin/ifconfig " . escapeshellarg($realhwif);
if (!empty($wancfg['media'])) {
$cmd .= " media " . escapeshellarg($wancfg['media']);
}
if (!empty($wancfg['mediaopt'])) {
$cmd .= " mediaopt " . escapeshellarg($wancfg['mediaopt']);
}
mwexec($cmd);
}
mwexec($cmd);
}
// apply interface hardware settings (tso, lro, ..)
configure_interface_hardware($realhwif);

View File

@ -301,6 +301,7 @@ function legacy_interfaces_details($intf = null)
if (preg_match("/media: .*? \((.*?)\)/", $line, $matches)) {
$result[$current_interface]['media'] = $matches[1];
}
$result[$current_interface]['media_raw'] = substr(trim($line), 7);
} elseif (preg_match("/status: (.*)$/", $line, $matches)) {
$result[$current_interface]['status'] = $matches[1];
} elseif (preg_match("/channel (\S*)/", $line, $matches)) {