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(-) 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 1c9fdd378e53ff62a4e2853407a0a1978be0bf45 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 15 Mar 2010 10:54:28 -0700 Subject: 0.16.21 --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 1760bd1..c1fd19c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +vyatta-cfg (0.16.21) unstable; urgency=low + + * Fix PPP serial QoS support + + -- Stephen Hemminger Mon, 15 Mar 2010 10:54:28 -0700 + vyatta-cfg (0.16.20) unstable; urgency=low * Print node name before the warning message. -- cgit v1.2.3 From 493f0ffdeae0e3916bf813951c9e921d9c554ce7 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Mon, 15 Mar 2010 14:02:19 -0700 Subject: add hook for boot-time config loading environment --- etc/init.d/vyatta-router | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/etc/init.d/vyatta-router b/etc/init.d/vyatta-router index 3f64b9c..c41c48a 100755 --- a/etc/init.d/vyatta-router +++ b/etc/init.d/vyatta-router @@ -117,7 +117,13 @@ load_bootfile () { if [ -x $vyatta_sbindir/vyatta-config-loader.pl ]; then log_progress_msg configure - sg ${GROUP} -c "$vyatta_sbindir/vyatta-config-loader.pl $BOOTFILE" + ( + if [ -f /etc/default/vyatta-load-boot ]; then + # build-specific environment for boot-time config loading + source /etc/default/vyatta-load-boot + fi + sg ${GROUP} -c "$vyatta_sbindir/vyatta-config-loader.pl $BOOTFILE" + ) fi } -- cgit v1.2.3 From 05f0ba8e5ba9282973bb5bc207f9f854c1ffa4a5 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Mon, 15 Mar 2010 14:03:07 -0700 Subject: 0.16.22 --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index c1fd19c..2e1d448 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +vyatta-cfg (0.16.22) unstable; urgency=low + + * add hook for boot-time config loading environment + + -- An-Cheng Huang Mon, 15 Mar 2010 14:03:07 -0700 + vyatta-cfg (0.16.21) unstable; urgency=low * Fix PPP serial QoS support -- 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(-) 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(-) 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 c4e924bb3de01f348816d2854c3e1d9b28ec49d0 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 17 Mar 2010 14:11:57 -0700 Subject: 0.16.23 --- debian/changelog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/debian/changelog b/debian/changelog index 2e1d448..dc62f66 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +vyatta-cfg (0.16.23) unstable; urgency=low + + [ An-Cheng Huang ] + * use template to determine leaf nodes + + [ Stephen Hemminger ] + * Fix typo in adsl interface discovery + + -- Stephen Hemminger Wed, 17 Mar 2010 14:11:57 -0700 + vyatta-cfg (0.16.22) unstable; urgency=low * add hook for boot-time config loading environment -- 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(-) 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