mirror of
https://gitlab.com/shorewall/code.git
synced 2025-06-20 17:58:07 +02:00
Avoid embedded Perl in the Broadcast action when ADDRTYPE is available
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
901c6d34f6
commit
bd2295c4c3
@ -30,44 +30,32 @@
|
|||||||
|
|
||||||
DEFAULTS DROP,-
|
DEFAULTS DROP,-
|
||||||
|
|
||||||
|
?if __ADDRTYPE
|
||||||
|
@1 - - - ;; -m addrtype --dst-type BROADCAST
|
||||||
|
@1 - - - ;; -m addrtype --dst-type MULTICAST
|
||||||
|
@1 - - - ;; -m addrtype --dst-type ANYCAST
|
||||||
|
?else
|
||||||
?begin perl;
|
?begin perl;
|
||||||
|
|
||||||
use Shorewall::IPAddrs;
|
use Shorewall::IPAddrs;
|
||||||
use Shorewall::Config;
|
use Shorewall::Config;
|
||||||
use Shorewall::Chains;
|
use Shorewall::Chains;
|
||||||
|
|
||||||
my ( $action, $audit ) = get_action_params( 2 );
|
my ( $action ) = get_action_params( 1 );
|
||||||
|
|
||||||
fatal_error "Invalid parameter ($audit) to action Broadcast" if supplied $audit && $audit ne 'audit';
|
|
||||||
fatal_error "Invalid parameter ($action) to action Broadcast" unless $action =~ /^(?:ACCEPT|DROP|REJECT)$/;
|
|
||||||
|
|
||||||
my $chainref = get_action_chain;
|
my $chainref = get_action_chain;
|
||||||
|
|
||||||
my ( $level, $tag ) = get_action_logging;
|
my ( $level, $tag ) = get_action_logging;
|
||||||
my $target = require_audit ( $action , $audit );
|
|
||||||
|
|
||||||
if ( have_capability( 'ADDRTYPE' ) ) {
|
add_commands $chainref, 'for address in $ALL_BCASTS; do';
|
||||||
if ( $level ne '' ) {
|
incr_cmd_level $chainref;
|
||||||
log_rule_limit $level, $chainref, 'dropBcast' , $action, '', $tag, 'add', ' -m addrtype --dst-type BROADCAST ';
|
log_rule_limit $level, $chainref, 'Broadcast' , $action, '', $tag, 'add', ' -d $address ' if $level ne '';
|
||||||
log_rule_limit $level, $chainref, 'dropBcast' , $action, '', $tag, 'add', ' -m addrtype --dst-type MULTICAST ';
|
add_jump $chainref, $action, 0, "-d \$address ";
|
||||||
log_rule_limit $level, $chainref, 'dropBcast' , $action, '', $tag, 'add', ' -m addrtype --dst-type ANYCAST ';
|
decr_cmd_level $chainref;
|
||||||
}
|
add_commands $chainref, 'done';
|
||||||
|
|
||||||
add_jump $chainref, $target, 0, '-m addrtype --dst-type BROADCAST ';
|
log_rule_limit $level, $chainref, 'Broadcast' , $action, '', $tag, 'add', ' -d 224.0.0.0/4 ' if $level ne '';
|
||||||
add_jump $chainref, $target, 0, '-m addrtype --dst-type MULTICAST ';
|
add_jump $chainref, $action, 0, '-d 224.0.0.0/4 ';
|
||||||
add_jump $chainref, $target, 0, '-m addrtype --dst-type ANYCAST ';
|
|
||||||
} else {
|
|
||||||
add_commands $chainref, 'for address in $ALL_BCASTS; do';
|
|
||||||
incr_cmd_level $chainref;
|
|
||||||
log_rule_limit $level, $chainref, 'Broadcast' , $action, '', $tag, 'add', ' -d $address ' if $level ne '';
|
|
||||||
add_jump $chainref, $target, 0, "-d \$address ";
|
|
||||||
decr_cmd_level $chainref;
|
|
||||||
add_commands $chainref, 'done';
|
|
||||||
|
|
||||||
log_rule_limit $level, $chainref, 'Broadcast' , $action, '', $tag, 'add', ' -d 224.0.0.0/4 ' if $level ne '';
|
|
||||||
add_jump $chainref, $target, 0, '-d 224.0.0.0/4 ';
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
?end perl;
|
?end perl;
|
||||||
|
?endif
|
||||||
|
@ -27,7 +27,7 @@ A_Reject # Audited Default action for REJECT policy
|
|||||||
allowInvalid inline # Accepts packets in the INVALID conntrack state
|
allowInvalid inline # Accepts packets in the INVALID conntrack state
|
||||||
AutoBL noinline # Auto-blacklist IPs that exceed thesholds
|
AutoBL noinline # Auto-blacklist IPs that exceed thesholds
|
||||||
AutoBLL noinline # Helper for AutoBL
|
AutoBLL noinline # Helper for AutoBL
|
||||||
Broadcast noinline # Handles Broadcast/Multicast/Anycast
|
Broadcast noinline,audit # Handles Broadcast/Multicast/Anycast
|
||||||
DNSAmp # Matches one-question recursive DNS queries
|
DNSAmp # Matches one-question recursive DNS queries
|
||||||
Drop # Default Action for DROP policy
|
Drop # Default Action for DROP policy
|
||||||
dropInvalid inline # Drops packets in the INVALID conntrack state
|
dropInvalid inline # Drops packets in the INVALID conntrack state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user