Commit 6044dd2d authored by djGrrr's avatar djGrrr Committed by Franco Fichtner

add VLAN Priority (PCP) setting to VLAN config (#1394)

(cherry picked from commit f07ab5fa)
(cherry picked from commit 189ae898)
(cherry picked from commit f6014c36)
parent bc07959d
......@@ -135,6 +135,22 @@ function interfaces_loopback_configure($verbose = false)
}
}
function interfaces_vlan_priorities()
{
$priorities = array();
$priorities['1'] = gettext('Background (1, lowest)');
$priorities['0'] = gettext('Best Effort (0, default)');
$priorities['2'] = gettext('Excellent Effort (2)');
$priorities['3'] = gettext('Critical Applications (3)');
$priorities['4'] = gettext('Video (4)');
$priorities['5'] = gettext('Voice (5)');
$priorities['6'] = gettext('Internetwork Control (6)');
$priorities['7'] = gettext('Network Control (7, highest)');
return $priorities;
}
function interfaces_vlan_configure($realif = '', $verbose = false)
{
global $config;
......@@ -213,7 +229,8 @@ function interface_vlan_configure(&$vlan)
mwexecf('/usr/sbin/ngctl name %s: %s', array($tmpvlanif, $vlanif));
}
legacy_vlan_tag($vlanif, $if, $vlan['tag']);
$pcp = isset($vlan['pcp']) ? $vlan['pcp'] : 0;
legacy_vlan_tag($vlanif, $if, $vlan['tag'], $pcp);
interfaces_bring_up($vlanif);
interfaces_bring_up($if);
......
......@@ -150,9 +150,9 @@ function legacy_bridge_member($ifs, $member)
}
}
function legacy_vlan_tag($ifs, $member, $tag)
function legacy_vlan_tag($ifs, $member, $tag, $pcp)
{
$cmd = '/sbin/ifconfig ' . escapeshellarg($ifs) . ' vlandev ' . escapeshellarg($member) . ' vlan ' . escapeshellarg($tag);
$cmd = '/sbin/ifconfig ' . escapeshellarg($ifs) . ' vlandev ' . escapeshellarg($member) . ' vlan ' . escapeshellarg($tag) . ' vlanpcp '.escapeshellarg($pcp);
exec($cmd . ' 2>&1', $out, $ret);
if ($ret) {
......
......@@ -122,7 +122,8 @@ $main_buttons = array(
<thead>
<tr>
<th><?=gettext("Interface");?></th>
<th><?=gettext("VLAN tag");?></th>
<th><?=gettext("Tag");?></th>
<th><?=gettext("PCP");?></th>
<th><?=gettext("Description");?></th>
<th>&nbsp;</th>
</tr>
......@@ -134,6 +135,7 @@ $main_buttons = array(
<tr>
<td><?=$vlan['if'];?></td>
<td><?=$vlan['tag'];?></td>
<td><?= isset($vlan['pcp']) ? $vlan['pcp'] : 0 ?></td>
<td><?=$vlan['descr'];?></td>
<td>
<a href="interfaces_vlan_edit.php?id=<?=$i;?>" class="btn btn-xs btn-default" data-toggle="tooltip" title="<?=gettext("edit interface");?>">
......
......@@ -49,6 +49,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['if'] = isset($a_vlans[$id]['if']) ? $a_vlans[$id]['if'] : null;
$pconfig['vlanif'] = isset($a_vlans[$id]['vlanif']) ? $a_vlans[$id]['vlanif'] : null;
$pconfig['tag'] = isset($a_vlans[$id]['tag']) ? $a_vlans[$id]['tag'] : null;
$pconfig['pcp'] = isset($a_vlans[$id]['pcp']) ? $a_vlans[$id]['pcp'] : 0;
$pconfig['descr'] = isset($a_vlans[$id]['descr']) ? $a_vlans[$id]['descr'] : null;
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
// validate / save form data
......@@ -69,6 +70,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$input_errors[] = gettext("The VLAN tag must be an integer between 1 and 4094.");
}
if (isset($pconfig['pcp']) && (!is_numericint($pconfig['pcp']) || $pconfig['pcp'] < 0 || $pconfig['pcp'] > 7)) {
$input_errors[] = gettext("The VLAN priority must be an integer between 0 and 7.");
}
if (!does_interface_exist($pconfig['if'])) {
$input_errors[] = gettext("Interface supplied as parent is invalid");
}
......@@ -99,7 +104,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (count($input_errors) == 0) {
$confif = "";
if (isset($id)) {
if (($a_vlans[$id]['if'] != $pconfig['if']) || ($a_vlans[$id]['tag'] != $pconfig['tag'])) {
if (($a_vlans[$id]['if'] != $pconfig['if']) || ($a_vlans[$id]['tag'] != $pconfig['tag']) || ($a_vlans[$id]['pcp'] != $pconfig['pcp'])) {
if (!empty($a_vlans[$id]['vlanif'])) {
$confif = convert_real_interface_to_friendly_interface_name($a_vlans[$id]['vlanif']);
legacy_interface_destroy($a_vlans[$id]['vlanif']);
......@@ -115,6 +120,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$vlan = array();
$vlan['if'] = $_POST['if'];
$vlan['tag'] = $_POST['tag'];
$vlan['pcp'] = $pconfig['pcp'];
$vlan['descr'] = $_POST['descr'];
$vlan['vlanif'] = "{$_POST['if']}_vlan{$_POST['tag']}";
$vlan['vlanif'] = interface_vlan_configure($vlan);
......@@ -200,6 +206,19 @@ include("head.inc");
</div>
</td>
</tr>
<tr>
<td><a id="help_for_pcp" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("VLAN priority");?></td>
<td>
<select name="pcp">
<? foreach (interfaces_vlan_priorities() as $pcp => $priority): ?>
<option value="<?=$pcp;?>"<?=($pconfig['pcp'] == $pcp ? ' selected="selected"' : '');?>><?=htmlspecialchars($priority);?></option>
<? endforeach ?>
</select>
<div class="hidden" for="help_for_pcp">
<?=gettext('802.1Q VLAN PCP (priority code point)');?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_descr" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description"); ?></td>
<td>
......
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