Set optional provider variables when NOROUTE is true

This commit is contained in:
Tom Eastep 2009-06-15 11:35:46 -07:00
parent 440cc08802
commit c96db9a01c

View File

@ -366,6 +366,7 @@ sub add_a_provider( ) {
interface => $interface ,
optional => $optional ,
gateway => $gateway ,
gatewaycase => $gatewaycase ,
shared => $shared ,
default => $default };
@ -702,6 +703,48 @@ sub finish_providers() {
}
}
sub test_optional_providers() {
my $first = 1;
for my $table ( @providers ) {
my $tableref = $providers{$table};
if ( $tableref->{optional} ) {
my $interface = $tableref->{interface};
my $base = uc chain_base( $interface );
my $variable;
if ( $first ) {
emit 'else';
push_indent;
$first = 0;
} else {
emit '';
}
if ( $tableref->{shared} ) {
$variable = $tableref->{mac};
} elsif ( $tableref->{gatewaycase} eq 'detect' ) {
$variable = $tableref->{gateway};
} else {
$variable = '';
}
if ( $variable ) {
emit qq(if interface_is_usable $interface && [ -n "$variable" ]; then);
} else {
emit qq(if interface_is_usable $interface; then);
}
emit( " ${base}_IS_UP=Yes" ,
'else',
" ${base}_IS_UP=" ,
'fi' );
}
}
pop_indent unless $first;
}
sub setup_providers() {
my $providers = 0;
@ -728,6 +771,7 @@ sub setup_providers() {
setup_null_routing if $config{NULL_ROUTE_RFC1918};
emit "\nrun_ip route flush cache";
pop_indent;
test_optional_providers;
emit "fi\n";
setup_route_marking if @routemarked_interfaces;