Insure uniqueness of chain_base mapping

This commit is contained in:
Tom Eastep 2010-08-28 20:47:39 -07:00
parent 95a09b996f
commit be0231578f

View File

@ -164,6 +164,7 @@ our @bport_zones;
our %ipsets;
our %physical;
our %basemap;
our %mapbase;
our $family;
our $have_ipsec;
our $baseseq;
@ -220,6 +221,7 @@ sub initialize( $ ) {
%ipsets = ();
%physical = ();
%basemap = ();
%mapbase = ();
$baseseq = 0;
if ( $family == F_IPV4 ) {
@ -800,16 +802,20 @@ sub chain_base($) {
#
$chain = join( '' , 'if_', $chain ) if $chain =~ /^[0-9]/;
#
# Save and return mapped name
# Create a new unique name
#
$name = join ( '_', $chain, ++$baseseq );
1 while $mapbase{$name = join ( '_', $chain, ++$baseseq )};
} else {
#
# We'll store the identity mapping
# We'll store the identity mapping if it is unique
#
$name = $chain;
$chain = join( '_', $key , ++$baseseq ) while $mapbase{$name = $chain};
}
#
# Store the reverse mapping
#
$mapbase{$name} = $key;
#
# Store the mapping
#
$basemap{$key} = $name;