summaryrefslogtreecommitdiff
path: root/lib/Vyatta/IpTables
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@io.vyatta.com>2009-02-13 15:22:10 -0800
committerStig Thormodsrud <stig@io.vyatta.com>2009-02-13 15:22:10 -0800
commit4d030e8c3c0f289de8471b91bc6b789592254b46 (patch)
treefea2a3e48f1121b351f2e5152088ab66c3f73903 /lib/Vyatta/IpTables
parentde14ea1af63db350e7174f75c9ace4fb13ded6bd (diff)
downloadvyatta-cfg-firewall-4d030e8c3c0f289de8471b91bc6b789592254b46.tar.gz
vyatta-cfg-firewall-4d030e8c3c0f289de8471b91bc6b789592254b46.zip
Cache exists() to reduce calls to external /usr/sbin/ipset.
Diffstat (limited to 'lib/Vyatta/IpTables')
-rwxr-xr-xlib/Vyatta/IpTables/IpSet.pm9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Vyatta/IpTables/IpSet.pm b/lib/Vyatta/IpTables/IpSet.pm
index e38e731..1f8e25b 100755
--- a/lib/Vyatta/IpTables/IpSet.pm
+++ b/lib/Vyatta/IpTables/IpSet.pm
@@ -34,9 +34,10 @@ use strict;
use warnings;
my %fields = (
- _name => undef,
- _type => undef, # vyatta group type, not ipset type
- _debug => undef,
+ _name => undef,
+ _type => undef, # vyatta group type, not ipset type
+ _exists => undef,
+ _debug => undef,
);
my %grouptype_hash = (
@@ -71,11 +72,13 @@ sub debug {
sub exists {
my ($self) = @_;
+ return 1 if defined $self->{_exists};
return 0 if ! defined $self->{_name};
my $func = (caller(0))[3];
my $cmd = "ipset -L $self->{_name}";
my $rc = system("$cmd > /dev/null &>2");
system("$logger [$func] [$cmd] = [$rc]") if defined $self->{_debug};
+ $self->{_exists} = 1 if $rc eq 0;
return $rc ? 0 : 1;
}