Improve interface number assignment

This commit is contained in:
Tom Eastep 2009-05-06 07:07:38 -07:00
parent 83bef182b1
commit 56016ca1bb

View File

@ -168,10 +168,7 @@ use constant { SIMPLE_IF_OPTION => 1,
our %validinterfaceoptions; our %validinterfaceoptions;
our %validhostoptions; our %validhostoptions;
our $num;
# #
# Initialize globals -- we take this novel approach to globals initialization to allow # Initialize globals -- we take this novel approach to globals initialization to allow
@ -188,7 +185,6 @@ sub initialize( $ ) {
@zones = (); @zones = ();
%zones = (); %zones = ();
$firewall_zone = ''; $firewall_zone = '';
$num = 0;
@interfaces = (); @interfaces = ();
%interfaces = (); %interfaces = ();
@ -683,7 +679,8 @@ sub firewall_zone() {
# #
# Process a record in the interfaces file # Process a record in the interfaces file
# #
sub process_interface() { sub process_interface( $ ) {
my $nextinum = $_[0];
my $nets; my $nets;
my ($zone, $originalinterface, $networks, $options ) = split_line 2, 4, 'interfaces file'; my ($zone, $originalinterface, $networks, $options ) = split_line 2, 4, 'interfaces file';
my $zoneref; my $zoneref;
@ -860,7 +857,7 @@ sub process_interface() {
$interfaces{$interface} = { name => $interface , $interfaces{$interface} = { name => $interface ,
bridge => $bridge , bridge => $bridge ,
nets => 0 , nets => 0 ,
number => ++$num , number => $nextinum ,
root => $root , root => $root ,
broadcasts => $broadcasts , broadcasts => $broadcasts ,
options => \%options }; options => \%options };
@ -886,9 +883,11 @@ sub validate_interfaces_file( $ ) {
my @ifaces; my @ifaces;
my $nextinum = 1;
first_entry "$doing $fn..."; first_entry "$doing $fn...";
push @ifaces, process_interface while read_a_line; push @ifaces, process_interface( $nextinum++) while read_a_line;
# #
# We now assemble the @interfaces array such that bridge ports immediately precede their associated bridge # We now assemble the @interfaces array such that bridge ports immediately precede their associated bridge