From 00837ed5037e8d8725bedf253af0e364690539fd Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Mon, 16 Aug 2010 13:12:12 -0700 Subject: [PATCH] Add Shorewall::Chains::find_chain() --- Shorewall/Perl/Shorewall/Chains.pm | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Chains.pm b/Shorewall/Perl/Shorewall/Chains.pm index 91f6cf047..35941f845 100644 --- a/Shorewall/Perl/Shorewall/Chains.pm +++ b/Shorewall/Perl/Shorewall/Chains.pm @@ -106,6 +106,7 @@ our %EXPORT_TAGS = ( ecn_chain notrack_chain first_chains + find_chain ensure_chain ensure_accounting_chain ensure_mangle_chain @@ -176,7 +177,7 @@ our %EXPORT_TAGS = ( Exporter::export_ok_tags('internal'); -our $VERSION = '4.4_12'; +our $VERSION = '4.4_13'; # # Chain Table @@ -1070,6 +1071,17 @@ sub new_chain($$) $chain_table{$table}{$chain} = $chainref; } +# +# Find a chain +# +sub find_chain($$) { + my ($table, $chain) = @_; + + assert( $table && $chain && $chain_table{$table} ); + + $chain_table{$table}{$chain}; +} + # # Create a chain if it doesn't exist already # @@ -1077,11 +1089,7 @@ sub ensure_chain($$) { my ($table, $chain) = @_; - assert( $table && $chain && $chain_table{$table} ); - - my $ref = $chain_table{$table}{$chain}; - - $ref || new_chain( $table, $chain ); + find_chain( $table, $chain ) || new_chain( $table, $chain ); } #