summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2018-04-17 16:23:13 +0700
committerGitHub <noreply@github.com>2018-04-17 16:23:13 +0700
commit379cdf6aee9b1f034344e2f7befcde13291d8bef (patch)
treef5715aed7a3bef8fff3886fb62e461fa1f496ed5
parentc22fd4e612bdc9e95474baa0bc7d0cf3d2144ebc (diff)
parentf6e4c60702f810cc06449782f64c7e5a7e20abb2 (diff)
downloadvyatta-cfg-firewall-379cdf6aee9b1f034344e2f7befcde13291d8bef.tar.gz
vyatta-cfg-firewall-379cdf6aee9b1f034344e2f7befcde13291d8bef.zip
Merge pull request #10 from mtudosoiu/current
Task T35 - fixing prune_deleted_sets for inet6 family
-rwxr-xr-xlib/Vyatta/IpTables/IpSet.pm19
-rwxr-xr-xscripts/firewall/vyatta-ipset.pl2
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/Vyatta/IpTables/IpSet.pm b/lib/Vyatta/IpTables/IpSet.pm
index ba5e68d..276b845 100755
--- a/lib/Vyatta/IpTables/IpSet.pm
+++ b/lib/Vyatta/IpTables/IpSet.pm
@@ -137,6 +137,25 @@ sub get_type {
return $self->{_type};
}
+sub get_family {
+ my ($self) = @_;
+ return $self->{_family} if defined $self->{_family};
+ return if !$self->exists();
+ my @lines = `ipset -L $self->{_name}`;
+ my $family;
+ foreach my $line (@lines) {
+ if ($line =~ /^Header: family (\w+) hashsize/) {
+ $family = $1;
+ $self->{_family} = $family;
+ last;
+ } elsif ($line =~ /^Type: bitmap:port$/){
+ $self->{_family} = "inet";
+ last;
+ }
+ }
+ return $self->{_family};
+}
+
sub alphanum_split {
my ($str) = @_;
my @list = split m/(?=(?<=\D)\d|(?<=\d)\D)/, $str;
diff --git a/scripts/firewall/vyatta-ipset.pl b/scripts/firewall/vyatta-ipset.pl
index 0f7f731..e5b2fd1 100755
--- a/scripts/firewall/vyatta-ipset.pl
+++ b/scripts/firewall/vyatta-ipset.pl
@@ -350,6 +350,8 @@ sub prune_deleted_sets {
# only try groups with no references
if ($group->exists() && ($group->references() == 0)) {
my $type = $group->get_type();
+ my $family = $group->get_family();
+ ($family eq 'inet') ? $cfg->setLevel("firewall group $type-group") : $cfg->setLevel("firewall group ipv6-$type-group");
$cfg->setLevel("firewall group $type-group");
next if ($cfg->isEffective($set)); # don't prune if still in config
my $rc;