On 4/25/2015 9:16 AM, Tom Eastep wrote:
> On 4/23/2015 11:55 AM, Ed W wrote:
>> Hi Tom
>>
>> Would you be amenable to optimising detect_configuration for the special 
>> case of calling "enable iface_x"?
>>
> 
> ...
>> My suggestion on practical ways to implement this would be for 
>> 'detect_config()' to take an optional interface parameter. Then each of 
>> the stanzas can be wrapped in a conditional and only run if either the 
>> param is empty or set to detect that specific interface.
>>
>> My simple benchmarks suggest that slowest function for me is 
>> 'interface_is_usable', consuming about 1s. Then 'detect_gateway' which 
>> consumes about 0.7s, the remainder is 
>> 'find_first_interface_address_if_any'. Note these benchmarks and 
>> observations run against shorewall 4.6.6.1.
>>
> 
> I'll take a look at this after I see what I can do about Laurens's bug.
> 

Here is a lightly-tested patch against the current master branch.

-Tom
-- 
Tom
Tom Eastep
http://www.shorewall.net

diff --git a/Shorewall/Perl/Shorewall/Providers.pm 
b/Shorewall/Perl/Shorewall/Providers.pm
index f4be6d9..a2e661b 100644
--- a/Shorewall/Perl/Shorewall/Providers.pm
+++ b/Shorewall/Perl/Shorewall/Providers.pm
@@ -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;
        }
 
diff --git a/Shorewall/Perl/prog.footer b/Shorewall/Perl/prog.footer
index 39292ea..c3689e2 100644
--- a/Shorewall/Perl/prog.footer
+++ b/Shorewall/Perl/prog.footer
@@ -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

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Shorewall-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/shorewall-devel

Reply via email to