summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2014-10-08 21:07:58 +0200
committerDaniil Baturin <daniil@baturin.org>2014-10-08 21:07:58 +0200
commitf14d37e838392d0f0f35900387299c000323ce00 (patch)
treedb188e26ead21fd7b96f0e725274e28dd838bfd1
parent8cc9ab999fab0756b19e0ad9633517d0ad17f1c3 (diff)
downloadvyatta-cfg-f14d37e838392d0f0f35900387299c000323ce00.tar.gz
vyatta-cfg-f14d37e838392d0f0f35900387299c000323ce00.zip
Add QinQ support to the intf name to path function.
-rwxr-xr-xlib/Vyatta/Interface.pm16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm
index 8451d9e..92fdd6a 100755
--- a/lib/Vyatta/Interface.pm
+++ b/lib/Vyatta/Interface.pm
@@ -105,7 +105,7 @@ sub new {
my $name = pop;
my $class = ref($that) || $that;
- my ($vif, $vrid);
+ my ($vif, $vif_c, $vrid);
my $dev = $name;
# remove VRRP id suffix
@@ -114,8 +114,12 @@ sub new {
$vrid = $2;
}
- # remove VLAN suffix
- if ($dev =~ /^(.*)\.(\d+)/) {
+ # QinQ or usual VLAN
+ if ($dev =~ /^([^\.]+)\.(\d+)\.(\d+)/) {
+ $dev = $1;
+ $vif = $2;
+ $vif_c = $3;
+ } elsif ($dev =~ /^(.*)\.(\d+)/) {
$dev = $1;
$vif = $2;
}
@@ -131,6 +135,7 @@ sub new {
type => $type,
dev => $dev,
vif => $vif,
+ vif_c => $vif_c,
vrid => $vrid,
};
bless $self, $class;
@@ -180,7 +185,10 @@ sub path {
# normal device
my $path = "interfaces $self->{type} $self->{dev}";
$path .= " vrrp $self->{vrid}" if $self->{vrid};
- $path .= " vif $self->{vif}" if $self->{vif};
+ $path .= " vif $self->{vif}" if ($self->{vif} && !$self->{vif_c});
+ $path .= " vif-s $self->{vif} vif-c $self->{vif_c}" if
+ ($self->{vif} && $self->{vif_c});
+
return $path;
}