summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2010-04-06 08:36:38 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2010-04-06 08:36:38 -0700
commit3d6755af79c4a694b43efdd3519b6ee10a4656a5 (patch)
tree3a70fcaf209f919e36f28db00d67682d8eda4cb0
parentf17d33fcd1c909eb05943fae41a1628519328c1c (diff)
downloadvyatta-cfg-3d6755af79c4a694b43efdd3519b6ee10a4656a5.tar.gz
vyatta-cfg-3d6755af79c4a694b43efdd3519b6ee10a4656a5.zip
Defer reading ppp config until necessary
Only read ppp peers and config if looking for config path. Other properties don't need it.
-rwxr-xr-xlib/Vyatta/Interface.pm41
1 files changed, 23 insertions, 18 deletions
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 {