mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 16:44:39 +00:00
add VLAN Priority (PCP) setting to VLAN config (#1394)
* add VLAN Priority (PCP) setting to VLAN config * use array() instead of [] here * add a default value for $pcp to legacy_vlan_tag()
This commit is contained in:
parent
46fb701528
commit
f07ab5fa7a
@ -213,7 +213,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 = 0)
|
||||
{
|
||||
$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) {
|
||||
|
||||
@ -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'] : null;
|
||||
$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,31 @@ include("head.inc");
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?
|
||||
$priorities = array(
|
||||
1 => gettext('1 - Background'),
|
||||
0 => gettext('0 - Best Effort (default)'),
|
||||
2 => gettext('2 - Excellent Effort'),
|
||||
3 => gettext('3 - Critical Applications'),
|
||||
4 => gettext('4 - Video'),
|
||||
5 => gettext('5 - Voice'),
|
||||
6 => gettext('6 - Internetwork Control'),
|
||||
7 => gettext('7 - Network Control'),
|
||||
);
|
||||
?>
|
||||
<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 ($priorities as $pcp => $priority) { ?>
|
||||
<option value="<?=$pcp;?>"<?=($pconfig['pcp'] == $pcp ? ' selected="selected"' : '');?>><?=htmlspecialchars($priority);?></option>
|
||||
<? } ?>
|
||||
</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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user