forked from extern/shorewall_code
Unify chain deletion.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
7a831107c7
commit
2ff1df53da
@ -78,7 +78,7 @@ our %EXPORT_TAGS = (
|
||||
add_commands
|
||||
move_rules
|
||||
insert_rule1
|
||||
purge_jump
|
||||
purge_jumps
|
||||
add_tunnel_rule
|
||||
process_comment
|
||||
no_comment
|
||||
@ -597,13 +597,13 @@ sub add_reference ( $$ ) {
|
||||
# Purge jumps previously added via add_jump. If the target chain is empty, reset its
|
||||
# referenced flag
|
||||
#
|
||||
sub purge_jump ( $$ ) {
|
||||
sub purge_jumps ( $$ ) {
|
||||
my ( $fromref, $toref ) = @_;
|
||||
my $to = $toref->{name};
|
||||
my $last = 0;
|
||||
my $rule;
|
||||
|
||||
for ( $rule = 0; $rule < $#{$fromref->{rules}}; $rule++ ) {
|
||||
for ( $rule = 0; $rule <= $#{$fromref->{rules}}; $rule++ ) {
|
||||
if ( $fromref->{rules}[$rule] =~ / -[gj] ${to}\b/ ) {
|
||||
trace( $fromref, 'D', $rule + 1, $_ ) if $debug;
|
||||
splice( @{$fromref->{rules}}, $rule, 1 );
|
||||
@ -1412,7 +1412,6 @@ sub optimize_chain( $ ) {
|
||||
#
|
||||
# Delete the references to the passed chain
|
||||
#
|
||||
|
||||
sub delete_references( $ ) {
|
||||
my $chainref = shift;
|
||||
my $table = $chainref->{table};
|
||||
@ -1420,16 +1419,7 @@ sub delete_references( $ ) {
|
||||
my $rule;
|
||||
|
||||
for my $fromref ( map $chain_table{$table}{$_} , keys %{$chainref->{references}} ) {
|
||||
for ( $rule = 0; $rule <= $#{$fromref->{rules}}; $rule++ ) {
|
||||
if ( $fromref->{rules}[$rule] =~ / -[jg] $chainref->{name}$/ ) {
|
||||
trace( $fromref, 'D', $rule + 1, $_ ) if $debug;
|
||||
splice( @{$fromref->{rules}}, $rule, 1 );
|
||||
$count++;
|
||||
$rule--;
|
||||
}
|
||||
}
|
||||
|
||||
delete $chainref->{references}{$fromref->{name}};
|
||||
purge_jumps ($fromref, $chainref );
|
||||
}
|
||||
|
||||
if ( $count ) {
|
||||
@ -1438,9 +1428,12 @@ sub delete_references( $ ) {
|
||||
progress_message " Empty chain $chainref->{name} deleted";
|
||||
}
|
||||
|
||||
if ( $chainref->{referenced} ) {
|
||||
$chainref->{referenced} = 0;
|
||||
$chainref->{rules} = [];
|
||||
trace ( $chainref, 'X', undef, '' ) if $debug;
|
||||
}
|
||||
|
||||
$count;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ use strict;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw( setup_providers @routemarked_interfaces handle_stickiness handle_optional_interfaces );
|
||||
our @EXPORT_OK = qw( initialize lookup_provider );
|
||||
our $VERSION = '4.4_8';
|
||||
our $VERSION = '4.4_9';
|
||||
|
||||
use constant { LOCAL_TABLE => 255,
|
||||
MAIN_TABLE => 254,
|
||||
@ -960,8 +960,8 @@ sub handle_stickiness( $ ) {
|
||||
}
|
||||
|
||||
if ( @routemarked_providers ) {
|
||||
purge_jump $mangle_table->{PREROUTING}, $setstickyref unless @{$setstickyref->{rules}};
|
||||
purge_jump $mangle_table->{OUTPUT}, $setstickoref unless @{$setstickoref->{rules}};
|
||||
purge_jumps $mangle_table->{PREROUTING}, $setstickyref unless @{$setstickyref->{rules}};
|
||||
purge_jumps $mangle_table->{OUTPUT}, $setstickoref unless @{$setstickoref->{rules}};
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user