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