diff options
author | Mohit Mehta <mohit@vyatta.com> | 2010-10-01 11:31:54 -0700 |
---|---|---|
committer | Mohit Mehta <mohit@vyatta.com> | 2010-10-01 11:31:54 -0700 |
commit | 0b0e584e03e1d63f0a375a98d0722341ff457a17 (patch) | |
tree | 9da1e19b86894a77f5cc00d0e67d7184393c2b43 /lib/Vyatta | |
parent | 86d7d24905956da49aef347c811480d9dcb125b3 (diff) | |
download | vyatta-cfg-firewall-0b0e584e03e1d63f0a375a98d0722341ff457a17.tar.gz vyatta-cfg-firewall-0b0e584e03e1d63f0a375a98d0722341ff457a17.zip |
move chain_referenced function to Mgr.pm module
Diffstat (limited to 'lib/Vyatta')
-rwxr-xr-x | lib/Vyatta/IpTables/Mgr.pm | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Vyatta/IpTables/Mgr.pm b/lib/Vyatta/IpTables/Mgr.pm index ff468cb..678fb39 100755 --- a/lib/Vyatta/IpTables/Mgr.pm +++ b/lib/Vyatta/IpTables/Mgr.pm @@ -29,7 +29,8 @@ use warnings; use base 'Exporter'; our @EXPORT = qw(ipt_find_chain_rule ipt_enable_conntrack - ipt_disable_conntrack count_iptables_rules); + ipt_disable_conntrack count_iptables_rules + chain_referenced); sub ipt_find_chain_rule { @@ -114,4 +115,19 @@ sub count_iptables_rules { return $cnt; } +sub chain_referenced { + my ( $table, $chain, $iptables_cmd ) = @_; + + my $cmd = "$iptables_cmd -t $table -n -L $chain"; + my $line = `$cmd 2>/dev/null |head -n1`; + chomp $line; + my $found = 0; + if ( $line =~ m/^Chain $chain \((\d+) references\)$/ ) { + if ( $1 > 0 ) { + $found = 1; + } + } + return $found; +} + 1; |