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 %ipsets;
our %physical; our %physical;
our %basemap; our %basemap;
our %mapbase;
our $family; our $family;
our $have_ipsec; our $have_ipsec;
our $baseseq; our $baseseq;
@ -220,6 +221,7 @@ sub initialize( $ ) {
%ipsets = (); %ipsets = ();
%physical = (); %physical = ();
%basemap = (); %basemap = ();
%mapbase = ();
$baseseq = 0; $baseseq = 0;
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
@ -800,16 +802,20 @@ sub chain_base($) {
# #
$chain = join( '' , 'if_', $chain ) if $chain =~ /^[0-9]/; $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 { } 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 # Store the mapping
# #
$basemap{$key} = $name; $basemap{$key} = $name;