Optimize detect_configuration() for enable/disable

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2015-04-25 15:46:19 -07:00
parent bebb41674a
commit 75d18139f7
2 changed files with 21 additions and 4 deletions

View File

@ -1729,12 +1729,12 @@ sub compile_updown() {
q( if [ "$COMMAND" = up ]; then) ,
q( progress_message3 "Attempting enable on interface $1") ,
q( COMMAND=enable) ,
q( detect_configuration),
q( detect_configuration $1),
q( enable_provider $1),
q( elif [ "$PHASE" != post-down ]; then # pre-down or not Debian) ,
q( progress_message3 "Attempting disable on interface $1") ,
q( COMMAND=disable) ,
q( detect_configuration),
q( detect_configuration $1),
q( disable_provider $1) ,
q( fi) ,
q(elif [ "$COMMAND" = up ]; then) ,
@ -1941,6 +1941,19 @@ sub handle_optional_interfaces( $ ) {
emit( "$physical)" ), push_indent if $wildcards;
if ( $provider eq $physical ) {
#
# Just an optional interface, or provider and interface are the same
#
emit qq(if [ -z "\$1" -o "\$1" = "$physical" ]; then);
} else {
#
# Provider
#
emit qq(if [ -z "\$1" -o "\$1" = "$physical" -o "\$1" = "$provider" ]; then);
}
push_indent;
if ( $providerref->{gatewaycase} eq 'detect' ) {
emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then);
} else {
@ -1952,6 +1965,10 @@ sub handle_optional_interfaces( $ ) {
emit( " SW_${base}_IS_USABLE=Yes" ,
'fi' );
pop_indent;
emit( 'fi' );
emit( ';;' ), pop_indent if $wildcards;
}

View File

@ -375,7 +375,7 @@ case "$COMMAND" in
[ $# -ne 1 ] && usage 2
mutex_on
if product_is_started; then
detect_configuration
detect_configuration $1
enable_provider $1
fi
mutex_off
@ -387,7 +387,7 @@ case "$COMMAND" in
[ $# -ne 1 ] && usage 2
mutex_on
if product_is_started; then
detect_configuration
detect_configuration $1
disable_provider $1
fi
mutex_off