From 053df2a5fb1f6e5c18fd51acf56480c6eff5dec1 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Thu, 25 Sep 2014 09:21:20 -0700 Subject: [PATCH] Go back to original insert_irule() fix. Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Chains.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Chains.pm b/Shorewall/Perl/Shorewall/Chains.pm index 547fe1dd6..ebbfc0857 100644 --- a/Shorewall/Perl/Shorewall/Chains.pm +++ b/Shorewall/Perl/Shorewall/Chains.pm @@ -1662,10 +1662,7 @@ sub insert_irule( $$$$;@ ) { my ( $chainref, $jump, $target, $number, @matches ) = @_; my $rulesref = $chainref->{rules}; - - return add_irule( $chainref, $jump, $target, @matches ) if $number >= @$rulesref; - - my $ruleref = {}; + my $ruleref = {}; $ruleref->{mode} = ( $ruleref->{cmdlevel} = $chainref->{cmdlevel} ) ? CMD_MODE : CAT_MODE; @@ -1684,9 +1681,15 @@ sub insert_irule( $$$$;@ ) { $ruleref->{comment} = shortlineinfo( $chainref->{origin} ) || $ruleref->{comment} || $comment; - splice( @$rulesref, $number, 0, $ruleref ); + if ( $number >= @$rulesref ) { + $number = @$rulesref; + push @$rulesref, $ruleref; + } else { + splice( @$rulesref, $number, 0, $ruleref ); + $number++; + } - trace( $chainref, 'I', ++$number, format_rule( $chainref, $ruleref ) ) if $debug; + trace( $chainref, 'I', $number, format_rule( $chainref, $ruleref ) ) if $debug; $iprangematch = 0;