diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-03-15 09:27:39 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-03-15 09:27:39 -0700 |
commit | 757f87429a3ab63a8e75dd2a24d37d37e01b64ab (patch) | |
tree | f3780bb968ce4d05d14d9ffa3439f32118feadc5 /lib/Vyatta | |
parent | 5b944c222a91b63dbd3a5489ddf1cca513322dd8 (diff) | |
download | vyatta-cfg-757f87429a3ab63a8e75dd2a24d37d37e01b64ab.tar.gz vyatta-cfg-757f87429a3ab63a8e75dd2a24d37d37e01b64ab.zip |
Fix PPP serial QoS support
Bug 5005
PPPOE devices live in multiple places in the tree, so code needs to
go searching to find them.
Diffstat (limited to 'lib/Vyatta')
-rwxr-xr-x | lib/Vyatta/Interface.pm | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm index 19dff4a..230ccab 100755 --- a/lib/Vyatta/Interface.pm +++ b/lib/Vyatta/Interface.pm @@ -84,25 +84,44 @@ sub interface_types { return @types; } -# Read pppoe config to fine associated ethernet for ppp device -sub find_pppoe { +# Read ppp config to fine associated interface for ppp device +sub _ppp_intf { my $dev = shift; - my $eth; + my $intf; - open (my $pppoe, '<', "/etc/ppp/peers/$dev") + open (my $ppp, '<', "/etc/ppp/peers/$dev") or return; # no such device - while (<$pppoe>) { + while (<$ppp>) { chomp; # looking for line like: # pty "/usr/sbin/pppoe -m 1412 -I eth1" - next unless /^pty .*(eth\d+)"/; - $eth = $1; + next unless /^pty\s.*-I\s*(\w+)"/; + $intf = $1; last; } - close($pppoe); + close $ppp; - return $eth; + return $intf; +} + +# Go path hunting to find ppp device +sub _ppp_path { + my ($intf, $type, $id) = @_; + my $config = new Vyatta::Config; + + if ($type eq 'pppoe') { + my $path = "interfaces ethernet $intf pppoe $id"; + return $path if $config->exists($path); + } + + my $adsl = "interface adsl $intf pvc"; + foreach my $pvc ($config->listNodes($adsl)) { + my $path = "$adsl pvc $pvc $type $id"; + return $path if $config->exists($path); + } + + return; } # new interface description object @@ -115,17 +134,20 @@ sub new { # need argument to constructor return unless $name; - # Special case for pppoe devices - if ($name =~ /^pppoe(\d+)/) { - my $n = $1; - my $eth = find_pppoe($name); + # Special case for ppp devices + if ($name =~ /^(pppo[ae])(\d+)/) { + my $type = $1; + my $id = $2; + my $intf = _ppp_intf($name); + return unless $intf; - return unless $eth; + my $path = _ppp_path($intf, $type, $id); + return unless $path; my $self = { name => $name, - type => 'pppoe', - path => "interfaces ethernet $eth pppoe $n", + type => $type, + path => $path, dev => $name, }; bless $self, $class; @@ -234,7 +256,7 @@ sub using_dhcp { sub bridge_grp { my $self = shift; my $config = new Vyatta::Config; - + $config->setLevel( $self->{path} ); return $config->returnValue("bridge-group bridge"); } |