load= enhancements

- Normalize loads to 0.nnnnnnnn
- Issue warning if the loads don't sum to 1.000000

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2015-05-23 08:05:58 -07:00
parent c851e03313
commit 631ebdecb8

View File

@ -568,8 +568,8 @@ sub process_a_provider( $ ) {
$track = 0 if $config{TRACK_PROVIDERS}; $track = 0 if $config{TRACK_PROVIDERS};
$default_balance = 0 if $config{USE_DEFAULT_RT}; $default_balance = 0 if $config{USE_DEFAULT_RT};
} elsif ( $option =~ /^load=(0?\.\d{1,8})/ ) { } elsif ( $option =~ /^load=(0?\.\d{1,8})/ ) {
$load = $1; $load = sprintf "%1.8f", $1;
require_capability 'STATISTIC_MATCH', "load=$load", 's'; require_capability 'STATISTIC_MATCH', "load=$1", 's';
} elsif ( $option eq 'autosrc' ) { } elsif ( $option eq 'autosrc' ) {
$noautosrc = 0; $noautosrc = 0;
} elsif ( $option eq 'noautosrc' ) { } elsif ( $option eq 'noautosrc' ) {
@ -1620,6 +1620,11 @@ sub setup_providers() {
our $providers; our $providers;
if ( $providers ) { if ( $providers ) {
if ( $maxload ) {
warning_message "The sum of the provider interface loads exceeds 1.000000" if $maxload > 1;
warning_message "The sum of the provider interface loads is less than 1.000000" if $maxload < 1;
}
emit "\nif [ -z \"\$g_noroutes\" ]; then"; emit "\nif [ -z \"\$g_noroutes\" ]; then";
push_indent; push_indent;