Add Shorewall::Chains::find_chain()

This commit is contained in:
Tom Eastep 2010-08-16 13:12:12 -07:00
parent 633eba6c90
commit 00837ed503

View File

@ -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 );
}
#