Make optimize 8 a multi-pass operation.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2013-01-21 09:12:42 -08:00
parent c820c54f41
commit 5beae475f5

View File

@ -3089,20 +3089,24 @@ sub optimize_level4( $$ ) {
sub optimize_level8( $$$ ) {
my ( $table, $tableref , $passes ) = @_;
my $progress = 1;
my @chains = ( grep $_->{referenced} && ! $_->{builtin}, values %{$tableref} );
my @chains1 = @chains;
my $chains = @chains;
my $chainseq = 0;
my %rename;
my %combined;
$passes++;
progress_message "\n Table $table pass $passes, $chains referenced user chains, level 8...";
%renamed = ();
for my $chainref ( @chains ) {
while ( $progress ) {
my @chains = ( grep $_->{referenced} && ! $_->{builtin}, values %{$tableref} );
my @chains1 = @chains;
my $chains = @chains;
my %rename;
my %combined;
$progress = 0;
progress_message "\n Table $table pass $passes, $chains referenced user chains, level 8...";
$passes++;
for my $chainref ( grep ! $_->{digest}, @chains ) {
my $digest = '';
for ( @{$chainref->{rules}} ) {
@ -3130,6 +3134,7 @@ sub optimize_level8( $$$ ) {
next if $chainref1->{optflags} & DONT_DELETE;
if ( $chainref->{digest} eq $chainref1->{digest} ) {
progress_message " Chain $chainref1->{name} combined with $chainref->{name}";
$progress = 1;
replace_references $chainref1, $chainref->{name}, undef;
unless ( $chainref->{name} =~ /^~/ ) {
@ -3198,13 +3203,16 @@ sub optimize_level8( $$$ ) {
if ( my $newname = $renamed{$_->{target}} ) {
$_->{target} = $newname;
delete $chainref->{digest};
trace( $chainref, 'R', $rulenum, $_ ) if $debug;
}
}
}
}
}
$passes;
}
#