summaryrefslogtreecommitdiff
path: root/scripts/firewall/vyatta-ipset.pl
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@vyatta.com>2010-03-18 19:44:41 -0700
committerStig Thormodsrud <stig@vyatta.com>2010-03-18 19:44:41 -0700
commitce3389b3cafa928fd2468705c049ef958f5f4266 (patch)
treead90ec0f77c6d7c22416591ece600fbdf3f7794a /scripts/firewall/vyatta-ipset.pl
parenta3997491b17f5451f44ea77359e4a2f7c2fc3555 (diff)
downloadvyatta-cfg-firewall-ce3389b3cafa928fd2468705c049ef958f5f4266.tar.gz
vyatta-cfg-firewall-ce3389b3cafa928fd2468705c049ef958f5f4266.zip
Fix firewall group parent delete while still referenced.
Diffstat (limited to 'scripts/firewall/vyatta-ipset.pl')
-rwxr-xr-xscripts/firewall/vyatta-ipset.pl34
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/firewall/vyatta-ipset.pl b/scripts/firewall/vyatta-ipset.pl
index 399c629..8614581 100755
--- a/scripts/firewall/vyatta-ipset.pl
+++ b/scripts/firewall/vyatta-ipset.pl
@@ -170,6 +170,35 @@ sub ipset_copy_set {
}
}
+sub ipset_is_group_deleted {
+ my ($set_name, $set_type) = @_;
+
+ die "Error: undefined set_name\n" if ! defined $set_name;
+ die "Error: undefined set_type\n" if ! defined $set_type;
+
+ my $config = new Vyatta::Config;
+ $config->setLevel("firewall group $set_type-group");
+ my %nodes = $config->listNodeStatus();
+
+ if ($nodes{$set_name} eq 'deleted') {
+ exit 0;
+ } else {
+ exit 1;
+ }
+}
+
+sub ipset_is_group_used {
+ my ($set_name, $set_type) = @_;
+
+ die "Error: undefined set_name\n" if ! defined $set_name;
+ die "Error: undefined set_type\n" if ! defined $set_type;
+
+ my $group = new Vyatta::IpTables::IpSet($set_name);
+ my $refs = $group->references();
+ exit 0 if $refs > 0;
+ exit 1;
+}
+
#
# main
@@ -208,6 +237,11 @@ $rc = ipset_is_set_empty($set_name) if $action eq 'is-set-empty';
$rc = ipset_copy_set($set_name, $set_type, $set_copy) if $action eq 'copy-set';
+$rc = ipset_is_group_deleted($set_name, $set_type)
+ if $action eq 'is-group-deleted';
+
+$rc = ipset_is_group_used($set_name, $set_type) if $action eq 'is-group-used';
+
if (defined $rc) {
print $rc;
exit 1;