From f17d33fcd1c909eb05943fae41a1628519328c1c Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 6 Apr 2010 08:18:55 -0700 Subject: Add support for input interface in Interface module --- lib/Vyatta/Interface.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/Vyatta') diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm index 432fe33..183c6c7 100755 --- a/lib/Vyatta/Interface.pm +++ b/lib/Vyatta/Interface.pm @@ -76,6 +76,7 @@ my %net_prefix = ( '^peth[\d]+$' => { path => 'pseudo-ethernet', vif => 'vif', }, '^wlan[\d]+$' => { path => 'wireless', vif => 'vif' }, + '^in[\d]+$' => { path => 'input' }, ); # get list of interface types (only used in usage function) -- cgit v1.2.3 From 3d6755af79c4a694b43efdd3519b6ee10a4656a5 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 6 Apr 2010 08:36:38 -0700 Subject: Defer reading ppp config until necessary Only read ppp peers and config if looking for config path. Other properties don't need it. --- lib/Vyatta/Interface.pm | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'lib/Vyatta') diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm index 183c6c7..3eb810b 100755 --- a/lib/Vyatta/Interface.pm +++ b/lib/Vyatta/Interface.pm @@ -107,19 +107,26 @@ sub _ppp_intf { } # Go path hunting to find ppp device -sub _ppp_path { - my ($intf, $type, $id) = @_; - my $config = new Vyatta::Config; +sub ppp_path { + my $self = shift; + + return unless ($self->{name} =~ /^(pppo[ae])(\d+)/); + my $type = $1; + my $id = $2; + my $intf = _ppp_intf($self->{name}); + return unless $intf; + + my $config = new Vyatta::Config; if ($type eq 'pppoe') { - my $path = "interfaces ethernet $intf pppoe $id"; - return $path if $config->exists($path); + my $path = "interfaces ethernet $intf pppoe $id"; + return $path if $config->exists($path); } my $adsl = "interfaces adsl $intf pvc"; foreach my $pvc ($config->listNodes($adsl)) { - my $path = "$adsl $pvc $type $id"; - return $path if $config->exists($path); + my $path = "$adsl $pvc $type $id"; + return $path if $config->exists($path); } return; @@ -138,18 +145,11 @@ sub new { # Special case for ppp devices if ($name =~ /^(pppo[ae])(\d+)/) { my $type = $1; - my $id = $2; - my $intf = _ppp_intf($name); - return unless $intf; - - my $path = _ppp_path($intf, $type, $id); - return unless $path; my $self = { - name => $name, - type => $type, - path => $path, - dev => $name, + name => $name, + type => $type, + dev => $name, }; bless $self, $class; return $self; @@ -200,7 +200,12 @@ sub name { sub path { my $self = shift; - return $self->{path}; + my $path = $self->{path}; + + return $path if defined($path); + + # Go path hunting to find ppp device + return ppp_path($self); } sub vif { -- cgit v1.2.3