From 757f87429a3ab63a8e75dd2a24d37d37e01b64ab Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 15 Mar 2010 09:27:39 -0700 Subject: 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. --- lib/Vyatta/Interface.pm | 56 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 17 deletions(-) (limited to 'lib') 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"); } -- cgit v1.2.3 From bb368b089e72e89777ef18d0fcb2d61ae390c9a9 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Tue, 16 Mar 2010 12:18:14 -0700 Subject: use template to determine leaf nodes --- lib/Vyatta/ConfigLoad.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/Vyatta/ConfigLoad.pm b/lib/Vyatta/ConfigLoad.pm index 44c1089..627b361 100755 --- a/lib/Vyatta/ConfigLoad.pm +++ b/lib/Vyatta/ConfigLoad.pm @@ -315,7 +315,8 @@ sub findSetNodes { $active_cfg->setLevel(join ' ', @active_path); my @active_nodes = $active_cfg->listOrigNodes(); my %active_hash = map { $_ => 1 } @active_nodes; - if (defined($active_hash{'node.val'})) { + my $nref = $active_cfg->parseTmplAll(join ' ', @active_path); + if (defined($nref->{type}) and !defined($nref->{tag})) { # we are at a leaf node. findSetValues($new_ref, \@active_path); return; -- cgit v1.2.3 From 6a75b597533068974477e30fc439f5c6ee285903 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 17 Mar 2010 13:37:31 -0700 Subject: Fix typo in adsl interface discovery Need to use correct path when searching config path. --- lib/Vyatta/Interface.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm index 230ccab..b7473dc 100755 --- a/lib/Vyatta/Interface.pm +++ b/lib/Vyatta/Interface.pm @@ -115,9 +115,9 @@ sub _ppp_path { return $path if $config->exists($path); } - my $adsl = "interface adsl $intf pvc"; + my $adsl = "interfaces adsl $intf pvc"; foreach my $pvc ($config->listNodes($adsl)) { - my $path = "$adsl pvc $pvc $type $id"; + my $path = "$adsl $pvc $type $id"; return $path if $config->exists($path); } -- cgit v1.2.3 From 327ea4113cea590f4d2c33bb430421158ebf51fa Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 19 Mar 2010 15:33:04 -0700 Subject: Need explicit return to guarantee returning false If perl function falls off the end, it will return the result of the last expression. For these functions, the idea was to return a false value; and it the return was missing. --- lib/Vyatta/Misc.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/Vyatta/Misc.pm b/lib/Vyatta/Misc.pm index 77c6218..f4f9bfc 100755 --- a/lib/Vyatta/Misc.pm +++ b/lib/Vyatta/Misc.pm @@ -62,7 +62,7 @@ sub is_dhcp_enabled { return 1 if ( $addr && $addr eq "dhcp" ); } - # return undef + return; } # check if any non-dhcp addresses configured @@ -77,7 +77,7 @@ sub is_address_enabled { return 1 if ( $addr && $addr ne 'dhcp' ); } - # return undefined (ie false) + return; } # return dhclient related files for interface @@ -186,7 +186,7 @@ sub getNetAddrIP { return $ip; } - # default return of undefined (ie false) + return; } sub is_ip_v4_or_v6 { @@ -207,7 +207,7 @@ sub is_ip_v4_or_v6 { return 6; } - # default return of undefined (ie false) + return; } sub isIpAddress { @@ -269,7 +269,7 @@ sub isIPinInterfaces { return 1 if ( is_ip_in_list( $ip_addr, getIP($name) ) ); } - # false (undef) + return; # false (undef) } sub isClusteringEnabled { -- cgit v1.2.3