Commit 4ff07cad authored by Ad Schellevis's avatar Ad Schellevis

lagg interfaces, restructure interface_lagg_configure() and add mtu option,...

lagg interfaces, restructure interface_lagg_configure() and add mtu option, for https://github.com/opnsense/core/issues/1709
parent e5e914c9
......@@ -704,35 +704,48 @@ function interface_lagg_configure(&$lagg)
if (!count($members)) {
return -1;
}
$interface_stats = legacy_interfaces_details();
if (file_exists("/var/run/booting") || !(empty($lagg['laggif']))) {
legacy_interface_destroy($lagg['laggif']);
legacy_interface_create($lagg['laggif']);
if (!empty($lagg['laggif'])) {
$laggif = $lagg['laggif'];
if (empty($interface_stats[$laggif])) {
legacy_interface_create($lagg['laggif']);
} else {
// Already configured, detach child interfaces before attempting to configure.
// Prevents vlans to loose parent.
if (!empty($interface_stats[$laggif]['laggport'])) {
foreach ($interface_stats[$laggif]['laggport'] as $laggport) {
mwexec("/sbin/ifconfig {$laggif} -laggport {$laggport}");
}
}
}
} else {
$laggif = legacy_interface_create('lagg');
}
/* Calculate smaller mtu and enforce it */
// determine mtu value to use, either the provided one for the lagg or smallest of it's children
$mtu = null;
if (!empty($lagg['mtu'])) {
// mtu provided for lagg
$mtu = $lagg['mtu'];
} else {
// min() mtu of children
foreach ($members as $member) {
$opts = legacy_interface_stats($member);
if (!empty($opts['mtu']) && ($mtu == null || $opts['mtu'] < $mtu)) {
$mtu = $opts['mtu'];
if (!empty($interface_stats[$member]['mtu']) && ($mtu == null || $interface_stats[$member]['mtu'] < $mtu)) {
$mtu = $interface_stats[$member]['mtu'];
}
}
$checklist = get_interface_list();
foreach ($members as $member) {
if (!array_key_exists($member, $checklist)) {
continue;
}
foreach ($members as $member) {
if (!empty($interface_stats[$member])) {
legacy_interface_mtu($member, $mtu);
configure_interface_hardware($member);
interfaces_bring_up($member);
mwexec("/sbin/ifconfig {$laggif} laggport {$member}");
}
}
mwexec("/sbin/ifconfig {$laggif} laggproto " . escapeshellarg($lagg['proto']));
if (!empty($lagg['lacp_fast_timeout'])) {
......
......@@ -93,6 +93,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['proto'] = isset($a_laggs[$id]['proto']) ? $a_laggs[$id]['proto'] : null;
$pconfig['descr'] = isset($a_laggs[$id]['descr']) ? $a_laggs[$id]['descr'] : null;
$pconfig['lacp_fast_timeout'] = !empty($a_laggs[$id]['lacp_fast_timeout']);
$pconfig['mtu'] = isset($a_laggs[$id]['mtu']) ? $a_laggs[$id]['mtu'] : null;
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
// validate and save form data
if (!empty($a_laggs[$_POST['id']])) {
......@@ -118,6 +119,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!in_array($pconfig['proto'], $laggprotos)) {
$input_errors[] = gettext("Protocol supplied is invalid");
}
if (!empty($pconfig['mtu']) && ($pconfig['mtu'] < 576 || $pconfig['mtu'] > 9000)) {
$input_errors[] = gettext("The MTU must be greater than 576 bytes and less than 9000.");
}
if (count($input_errors) == 0) {
$lagg = array();
......@@ -125,6 +129,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$lagg['descr'] = $pconfig['descr'];
$lagg['laggif'] = $pconfig['laggif'];
$lagg['proto'] = $pconfig['proto'];
$lagg['mtu'] = $pconfig['mtu'];
$lagg['lacp_fast_timeout'] = !empty($pconfig['lacp_fast_timeout']);
if (isset($id)) {
$lagg['laggif'] = $a_laggs[$id]['laggif'];
......@@ -282,6 +287,15 @@ legacy_html_escape_form_data($pconfig);
</div>
</td>
</tr>
<tr>
<td><a id="help_for_mtu" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("MTU"); ?></td>
<td>
<input name="mtu" id="mtu" type="text" value="<?=$pconfig['mtu'];?>" />
<div class="hidden" for="help_for_mtu">
<?= gettext("If you leave this field blank, the smallest mtu of this laggs children will be used.");?>
</div>
</td>
</tr>
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
......
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