forked from extern/shorewall_code
Don't generate multihop routes unnecessarily
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
e027f5078f
commit
83e0be6d0b
@ -64,6 +64,8 @@ our @load_interfaces;
|
|||||||
|
|
||||||
our $balancing;
|
our $balancing;
|
||||||
our $fallback;
|
our $fallback;
|
||||||
|
our $balanced_providers;
|
||||||
|
our $fallback_providers;
|
||||||
our $metrics;
|
our $metrics;
|
||||||
our $first_default_route;
|
our $first_default_route;
|
||||||
our $first_fallback_route;
|
our $first_fallback_route;
|
||||||
@ -99,6 +101,8 @@ sub initialize( $ ) {
|
|||||||
%provider_interfaces = ();
|
%provider_interfaces = ();
|
||||||
@load_interfaces = ();
|
@load_interfaces = ();
|
||||||
$balancing = 0;
|
$balancing = 0;
|
||||||
|
$balanced_providers = 0;
|
||||||
|
$fallback_providers = 0;
|
||||||
$fallback = 0;
|
$fallback = 0;
|
||||||
$metrics = 0;
|
$metrics = 0;
|
||||||
$first_default_route = 1;
|
$first_default_route = 1;
|
||||||
@ -323,7 +327,13 @@ sub balance_default_route( $$$$ ) {
|
|||||||
emit '';
|
emit '';
|
||||||
|
|
||||||
if ( $first_default_route ) {
|
if ( $first_default_route ) {
|
||||||
|
if ( $balanced_providers == 1 ) {
|
||||||
if ( $gateway ) {
|
if ( $gateway ) {
|
||||||
|
emit "DEFAULT_ROUTE=\"via $gateway dev $interface $realm\"";
|
||||||
|
} else {
|
||||||
|
emit "DEFAULT_ROUTE=\"dev $interface $realm\"";
|
||||||
|
}
|
||||||
|
} elsif ( $gateway ) {
|
||||||
emit "DEFAULT_ROUTE=\"nexthop via $gateway dev $interface weight $weight $realm\"";
|
emit "DEFAULT_ROUTE=\"nexthop via $gateway dev $interface weight $weight $realm\"";
|
||||||
} else {
|
} else {
|
||||||
emit "DEFAULT_ROUTE=\"nexthop dev $interface weight $weight $realm\"";
|
emit "DEFAULT_ROUTE=\"nexthop dev $interface weight $weight $realm\"";
|
||||||
@ -347,7 +357,13 @@ sub balance_fallback_route( $$$$ ) {
|
|||||||
emit '';
|
emit '';
|
||||||
|
|
||||||
if ( $first_fallback_route ) {
|
if ( $first_fallback_route ) {
|
||||||
|
if ( $balanced_providers == 1 ) {
|
||||||
if ( $gateway ) {
|
if ( $gateway ) {
|
||||||
|
emit "FALLBACK_ROUTE=\"via $gateway dev $interface $realm\"";
|
||||||
|
} else {
|
||||||
|
emit "FALLBACK_ROUTE=\"dev $interface $realm\"";
|
||||||
|
}
|
||||||
|
} elsif ( $gateway ) {
|
||||||
emit "FALLBACK_ROUTE=\"nexthop via $gateway dev $interface weight $weight $realm\"";
|
emit "FALLBACK_ROUTE=\"nexthop via $gateway dev $interface weight $weight $realm\"";
|
||||||
} else {
|
} else {
|
||||||
emit "FALLBACK_ROUTE=\"nexthop dev $interface weight $weight $realm\"";
|
emit "FALLBACK_ROUTE=\"nexthop dev $interface weight $weight $realm\"";
|
||||||
@ -593,7 +609,12 @@ sub process_a_provider( $ ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fatal_error q(The 'balance' and 'fallback' options are mutually exclusive) if $balance && $default;
|
if ( $balance ) {
|
||||||
|
fatal_error q(The 'balance' and 'fallback' options are mutually exclusive) if $default;
|
||||||
|
$balanced_providers++;
|
||||||
|
} elsif ( $default ) {
|
||||||
|
$fallback_providers++;
|
||||||
|
}
|
||||||
|
|
||||||
if ( $load ) {
|
if ( $load ) {
|
||||||
fatal_error q(The 'balance=<weight>' and 'load=<load-factor>' options are mutually exclusive) if $balance > 1;
|
fatal_error q(The 'balance=<weight>' and 'load=<load-factor>' options are mutually exclusive) if $balance > 1;
|
||||||
@ -1534,9 +1555,9 @@ sub finish_providers() {
|
|||||||
} else {
|
} else {
|
||||||
emit ( " if echo \$DEFAULT_ROUTE | grep -q 'nexthop.+nexthop'; then",
|
emit ( " if echo \$DEFAULT_ROUTE | grep -q 'nexthop.+nexthop'; then",
|
||||||
" qt \$IP -6 route delete default scope global table $table \$DEFAULT_ROUTE",
|
" qt \$IP -6 route delete default scope global table $table \$DEFAULT_ROUTE",
|
||||||
" run_ip -6 route add default scope global table $table \$DEFAULT_ROUTE",
|
" run_ip route add default scope global table $table \$DEFAULT_ROUTE",
|
||||||
' else',
|
' else',
|
||||||
" run_ip -6 route replace default scope global table $table \$DEFAULT_ROUTE",
|
" run_ip route replace default scope global table $table \$DEFAULT_ROUTE",
|
||||||
' fi',
|
' fi',
|
||||||
'' );
|
'' );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user