Add 'optional' interfaces to updown processing.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2010-05-15 17:06:00 -07:00
parent a3589dc6e9
commit 749d6be64e

View File

@ -1242,12 +1242,35 @@ sub compile_updown() {
push_indent; push_indent;
emit( 'local state',
'state=cleared',
'',
'if shorewall_is_up; then',
' state=started',
'elif [ -f ${VARDIR}/state ]; then',
' case "$(cat ${VARDIR}/state)" in',
' Stopped*|Closed*)',
' state=stopped',
' ;;',
' Cleared*)',
' ;;',
' *)',
' state=unknown',
' ;;',
' esac',
'else',
' state=unknown',
'fi',
''
);
emit( 'case $1 in' ); emit( 'case $1 in' );
push_indent; push_indent;
my $ignore = find_interfaces_by_option 'ignore'; my $ignore = find_interfaces_by_option 'ignore';
my $required = find_interfaces_by_option 'required'; my $required = find_interfaces_by_option 'required';
my $optional = find_interfaces_by_option 'optional';
if ( @$ignore ) { if ( @$ignore ) {
my $interfaces = join '|', map $interfaces{$_}->{physical}, @$ignore; my $interfaces = join '|', map $interfaces{$_}->{physical}, @$ignore;
@ -1267,12 +1290,7 @@ sub compile_updown() {
emit( "$interfaces)", emit( "$interfaces)",
' if [ "$COMMAND" = up ]; then', ' if [ "$COMMAND" = up ]; then',
' if shorewall_is_started; then',
' COMMAND=restart',
' else',
' COMMAND=start', ' COMMAND=start',
' fi',
'',
' detect_configuration', ' detect_configuration',
' define_firewall', ' define_firewall',
' else', ' else',
@ -1284,22 +1302,40 @@ sub compile_updown() {
); );
} }
emit( "*)", if ( @$optional ) {
my $interfaces = join '|', map $interfaces{$_}->{physical}, @$optional;
$interfaces =~ s/\+/*/;
emit( "$interfaces)",
' if [ "$COMMAND" = up ]; then', ' if [ "$COMMAND" = up ]; then',
' if shorewall_is_started; then', ' echo 0 > ${VARDIR}/${1}.state',
' COMMAND=restart',
' else', ' else',
' COMMAND=start', ' echo 1 > ${VARDIR}/${1}.state',
' fi', ' fi',
'', '',
' detect_configuration', ' if [ "$state" = started ]; then',
' define_firewall',
' elif shorewall_is_started; then',
' COMMAND=restart', ' COMMAND=restart',
' detect_configuration', ' detect_configuration',
' define_firewall', ' define_firewall',
' fi', ' fi',
' ;;' ' ;;',
);
}
emit( "*)",
' case $state in',
' started)',
' COMMAND=restart',
' detect_configuration',
' define_firewall',
' ;;',
' cleared|unknown)',
' COMMAND=close',
' detect_configuration',
' stop_firewall',
' ;;',
' esac',
); );
pop_indent; pop_indent;