Commit c62143c0 authored by Kirk Webb's avatar Kirk Webb

Merge branch 'aristatrunk' from weibin

parents 0950ac4f dbcf6cf0
......@@ -665,7 +665,24 @@ sub createVlan($$$) {
#
# Put the given ports in the given VLAN. The VLAN is given as an 802.1Q
# tag number.
#
############################################################
# Semantics:
#
# Case mode(port):
# 'free' or 'in default untagged':
# add port to vlan_number untagged.
# 'in use(not in default) untagged':
# add port to vlan_number untagged.
# 'in use(not in default) all tagged':
# add port to vlan_number tagged.
# 'in use(may in default) native tagged':
# add port to vlan_number tagged;
# if native_vlan == default:
# remove native_vlan
#
# Arista 'free': switchportMode='access' AND accessVlan=1
#
############################################################
# usage: setPortVlan($self, $vlan_number, @ports)
# returns 0 on sucess.
# returns the number of failed ports on failure.
......@@ -688,7 +705,9 @@ sub setPortVlan($$@) {
my @swports = $self->convertPortFormat($PORT_FORMAT_SYSDB, @ports);
$self->lock();
my $resp = $self->callRPC($id, 'setPortVlan', $vlan_number, \@swports);
$self->unlock();
if (defined($resp)) {
$errors = $resp;
......@@ -732,7 +751,9 @@ sub delPortVlan($$@) {
my @swports = $self->convertPortFormat($PORT_FORMAT_SYSDB, @ports);
my $resp = $self->callRPC($id, 'removePortsFromVlan', $vlan_number, \@swports);
my $resp = $self->callRPC($id,
'removePortsFromVlan',
$vlan_number, \@swports);
if (defined($resp)) {
$errors = $resp;
......@@ -765,7 +786,9 @@ sub removePortsFromVlan($@) {
$errors++;
}
my $resp = $self->callRPC($id, 'removePortsFromVlan', $vlan_number, []);
my $resp = $self->callRPC($id,
'removePortsFromVlan',
$vlan_number, []);
if (defined($resp)) {
$errors += $resp;
......@@ -781,6 +804,18 @@ sub removePortsFromVlan($@) {
# Removes and disables some ports in a given VLAN.
# The VLAN is given as a VLAN 802.1Q tag value.
#
# Semantics:
# Case:
# untagged:
# move to default VLAN, put port down
# alltagged:
# untag port
# nativetagged:
# remove native vlan:
# clear native
# nonative vlan:
# untag
#
# usage: removeSomePortsFromVlan(self,vlan,@ports)
# returns 0 on sucess.
# returns the number of failed ports on failure.
......@@ -1062,13 +1097,29 @@ sub setVlansOnTrunk($$$$) {
my ($self, $modport, $value, @vlan_numbers) = @_;
my $id = $self->{NAME} . "::setVlansOnTrunk";
#
# Some error checking (from HP)
#
if (($value != 1) && ($value != 0)) {
warn "Invalid value $value passed to setVlansOnTrunk\n";
return 0;
}
if (grep(/^1$/,@vlan_numbers)) {
warn "VLAN 1 passed to setVlansOnTrunk\n";
return 0;
}
my ($swport) = $self->convertPortFormat($PORT_FORMAT_SYSDB, $modport);
my $resp = $self->callRPC($id, 'setAllowedVlansOnTrunkedPort', $swport,
($value?1:0), \@vlan_numbers);
if ($resp) {
return 1;
} else {
if (int($resp) == -1) {
warn "$id: port $modport is normal port, " .
"refusing to add vlan(s) @vlan_numbers\n";
}
return 0;
} else {
return 1;
}
}
......@@ -1088,6 +1139,17 @@ sub enablePortTrunking2($$$$) {
my $id = $self->{NAME} .
"::enablePortTrunking($port,$native_vlan,$equaltrunking)";
$self->debug($id."\n");
if ((!$equaltrunking) &&
(!defined($native_vlan) || ($native_vlan <= 1))) {
warn "$id: inappropriate or missing PVID for trunk\n";
return 0;
}
if (!defined($native_vlan)) {
$native_vlan = -1;
}
my ($swport) = $self->convertPortFormat($PORT_FORMAT_SYSDB, $port);
my $resp = $self->callRPC($id, 'enablePortTrunking',
$swport, $native_vlan, ($equaltrunking?1:0));
......@@ -1108,6 +1170,8 @@ sub disablePortTrunking($$) {
my ($self, $port) = @_;
my $id = $self->{NAME} . "::disablePortTrunking($port)";
$self->debug($id."\n");
my ($swport) = $self->convertPortFormat($PORT_FORMAT_SYSDB, $port);
my $resp = $self->callRPC($id, 'disablePortTrunking',
$swport);
......
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