mirror of
https://gitlab.com/shorewall/code.git
synced 2025-06-20 09:47:51 +02:00
Revise and document IPSEC Accounting
- Place accounting rules in accipsecin and accipsecout - Add warning when rule inserted into unreferenced accounting chain - Add warning when an accounting chain has no references Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
33ee9b1481
commit
e70d9c82d8
@ -61,6 +61,10 @@ sub process_accounting_rule( ) {
|
|||||||
|
|
||||||
our $disposition = '';
|
our $disposition = '';
|
||||||
|
|
||||||
|
sub reserved_chain_name($) {
|
||||||
|
$_[0] =~ /^acc(?:ount(?:ing|out)|ipsecin|ipsecout)$/;
|
||||||
|
}
|
||||||
|
|
||||||
sub check_chain( $ ) {
|
sub check_chain( $ ) {
|
||||||
my $chainref = shift;
|
my $chainref = shift;
|
||||||
fatal_error "A non-accounting chain ($chainref->{name}) may not appear in the accounting file" if $chainref->{policy};
|
fatal_error "A non-accounting chain ($chainref->{name}) may not appear in the accounting file" if $chainref->{policy};
|
||||||
@ -72,6 +76,7 @@ sub process_accounting_rule( ) {
|
|||||||
|
|
||||||
sub jump_to_chain( $ ) {
|
sub jump_to_chain( $ ) {
|
||||||
my $jumpchain = $_[0];
|
my $jumpchain = $_[0];
|
||||||
|
fatal_error "Jumps to the $jumpchain chain are not allowed" if reserved_chain_name( $jumpchain );
|
||||||
$jumpchainref = ensure_accounting_chain( $jumpchain );
|
$jumpchainref = ensure_accounting_chain( $jumpchain );
|
||||||
check_chain( $jumpchainref );
|
check_chain( $jumpchainref );
|
||||||
$disposition = $jumpchain;
|
$disposition = $jumpchain;
|
||||||
@ -88,7 +93,7 @@ sub process_accounting_rule( ) {
|
|||||||
my $rule2 = 0;
|
my $rule2 = 0;
|
||||||
|
|
||||||
if ( $ipsec ne '-' ) {
|
if ( $ipsec ne '-' ) {
|
||||||
fatal_error "A rule with non-empty IPSEC column can only appear in the 'accountin' and 'accountout' chains" unless $chain =~ /^account(in|out)$/;
|
fatal_error "A rule with non-empty IPSEC column can only appear in the 'accipsecin' and 'accipsecout' chains" unless $chain =~ /^accipsec(in|out)$/;
|
||||||
$rule .= do_ipsec( $1, $ipsec);
|
$rule .= do_ipsec( $1, $ipsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +149,12 @@ sub process_accounting_rule( ) {
|
|||||||
$dest = ALLIP if $dest eq 'any' || $dest eq 'all';
|
$dest = ALLIP if $dest eq 'any' || $dest eq 'all';
|
||||||
}
|
}
|
||||||
|
|
||||||
my $chainref = ensure_accounting_chain $chain;
|
my $chainref = $filter_table->{$chain};
|
||||||
|
|
||||||
|
if ( ! $chainref ) {
|
||||||
|
warning_message "Adding rule to unreferenced accounting chain $chain" unless reserved_chain_name( $chain );
|
||||||
|
$chainref = ensure_accounting_chain $chain;
|
||||||
|
}
|
||||||
|
|
||||||
expand_rule
|
expand_rule
|
||||||
$chainref ,
|
$chainref ,
|
||||||
@ -185,8 +195,6 @@ sub setup_accounting() {
|
|||||||
|
|
||||||
$nonEmpty |= process_accounting_rule while read_a_line;
|
$nonEmpty |= process_accounting_rule while read_a_line;
|
||||||
|
|
||||||
fatal_error "Accounring rules are isolated" if $nonEmpty && ! $filter_table->{accounting};
|
|
||||||
|
|
||||||
clear_comment;
|
clear_comment;
|
||||||
|
|
||||||
if ( have_bridges ) {
|
if ( have_bridges ) {
|
||||||
@ -199,25 +207,28 @@ sub setup_accounting() {
|
|||||||
if ( $filter_table->{accountout} ) {
|
if ( $filter_table->{accountout} ) {
|
||||||
add_jump( $filter_table->{OUTPUT}, 'accountout', 0, '', 0, 0 );
|
add_jump( $filter_table->{OUTPUT}, 'accountout', 0, '', 0, 0 );
|
||||||
}
|
}
|
||||||
} else {
|
} elsif ( $filter_table->{accounting} ) {
|
||||||
if ( $filter_table->{accountin} ) {
|
for my $chain ( qw/INPUT FORWARD OUTPUT/ ) {
|
||||||
for my $chain ( qw/INPUT FORWARD/ ) {
|
add_jump( $filter_table->{$chain}, 'accounting', 0, '', 0, 0 );
|
||||||
add_jump( $filter_table->{$chain}, 'accountin', 0, '', 0, 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $filter_table->{accountout} ) {
|
|
||||||
for my $chain ( qw/FORWARD OUTPUT/ ) {
|
|
||||||
add_jump( $filter_table->{$chain}, 'accountout', 0, '', 0, 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $filter_table->{accounting} ) {
|
|
||||||
for my $chain ( qw/INPUT FORWARD OUTPUT/ ) {
|
|
||||||
add_jump( $filter_table->{$chain}, 'accounting', 0, '', 0, 0 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $filter_table->{accipsecin} ) {
|
||||||
|
for my $chain ( qw/INPUT FORWARD/ ) {
|
||||||
|
add_jump( $filter_table->{$chain}, 'accipsecin', 0, '', 0, 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $filter_table->{accipsecout} ) {
|
||||||
|
for my $chain ( qw/FORWARD OUTPUT/ ) {
|
||||||
|
add_jump( $filter_table->{$chain}, 'accipsecout', 0, '', 0, 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( accounting_chainrefs ) {
|
||||||
|
warning_message "Accounting chain $_->{name} has no references" unless keys %{$_->{references}};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -109,6 +109,7 @@ our %EXPORT_TAGS = (
|
|||||||
find_chain
|
find_chain
|
||||||
ensure_chain
|
ensure_chain
|
||||||
ensure_accounting_chain
|
ensure_accounting_chain
|
||||||
|
accounting_chainrefs
|
||||||
ensure_mangle_chain
|
ensure_mangle_chain
|
||||||
ensure_nat_chain
|
ensure_nat_chain
|
||||||
ensure_raw_chain
|
ensure_raw_chain
|
||||||
@ -1204,6 +1205,13 @@ sub ensure_accounting_chain( $ )
|
|||||||
$chainref;
|
$chainref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Return a list of references to accounting chains
|
||||||
|
#
|
||||||
|
sub accounting_chainrefs() {
|
||||||
|
grep $_->{accounting} , values %$filter_table;
|
||||||
|
}
|
||||||
|
|
||||||
sub ensure_mangle_chain($) {
|
sub ensure_mangle_chain($) {
|
||||||
my $chain = $_[0];
|
my $chain = $_[0];
|
||||||
|
|
||||||
|
@ -54,6 +54,16 @@ None.
|
|||||||
any+!dmz,loc (All zones except 'dmz' and 'loc' and
|
any+!dmz,loc (All zones except 'dmz' and 'loc' and
|
||||||
include intra-zone rules).
|
include intra-zone rules).
|
||||||
|
|
||||||
|
2) An IPSEC column has been added to the accounting file, allowing you
|
||||||
|
to segregate IPSEC traffic from non-IPSEC traffic. See 'man
|
||||||
|
shorewall-accounting' (man shorewall6-accounting) for details.
|
||||||
|
|
||||||
|
Note that accounting rules that have a non-empty IPSEC column
|
||||||
|
may only appear in the 'accipsecin' and 'accipsecout' chains. The
|
||||||
|
former contains rules that select de-capsulated/decrypted traffic
|
||||||
|
while the latter contains rules that select traffic that will be
|
||||||
|
encapsulated/encrypted.
|
||||||
|
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
I V. R E L E A S E 4 . 4 H I G H L I G H T S
|
I V. R E L E A S E 4 . 4 H I G H L I G H T S
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
|
@ -433,12 +433,12 @@
|
|||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>The CHAIN column must contain either <emphasis
|
<para>The CHAIN column must contain either <emphasis
|
||||||
role="bold">accountin</emphasis> or <emphasis
|
role="bold">accipsecin</emphasis> or <emphasis
|
||||||
role="bold">accountout</emphasis>.</para>
|
role="bold">accipsecout</emphasis>.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
<para> These rules will NOT appear in the <emphasis
|
<para>These rules will NOT appear in the <emphasis
|
||||||
role="bold">accounting</emphasis> chain.</para>
|
role="bold">accounting</emphasis> chain.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user