diff options
author | Olivier Blin <oblin@mandriva.org> | 2005-08-31 14:32:15 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2005-08-31 14:32:15 +0000 |
commit | c48fab451e7b4dcc44f8c70818000024c73c8e8e (patch) | |
tree | e58ea4f451c864874148415bae3672af171a0a15 /perl-install/network/tools.pm | |
parent | 1b2177ab11b91e017bdbfcbd2fd99f025da4341c (diff) | |
download | drakx-c48fab451e7b4dcc44f8c70818000024c73c8e8e.tar drakx-c48fab451e7b4dcc44f8c70818000024c73c8e8e.tar.gz drakx-c48fab451e7b4dcc44f8c70818000024c73c8e8e.tar.bz2 drakx-c48fab451e7b4dcc44f8c70818000024c73c8e8e.tar.xz drakx-c48fab451e7b4dcc44f8c70818000024c73c8e8e.zip |
add get_current_gateway_interface
Diffstat (limited to 'perl-install/network/tools.pm')
-rw-r--r-- | perl-install/network/tools.pm | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm index bd3d99fce..a80397400 100644 --- a/perl-install/network/tools.pm +++ b/perl-install/network/tools.pm @@ -174,12 +174,17 @@ sub find_matching_interface { } sort keys %{$net->{ifcfg}}; } +#- returns the current gateway, with lowest metric +sub get_current_gateway_interface() { + my $routes = get_routes(); + first(sort { $routes->{$a}{metric} <=> $routes->{$b}{metric} } grep { exists $routes->{$_}{gateway} } keys %$routes); +} + #- returns gateway interface if found sub get_default_gateway_interface { my ($net) = @_; my @intfs = sort keys %{$net->{ifcfg}}; - my $routes = get_routes(); - (find { $routes->{$_}{gateway} } sort keys %$routes) || + get_current_gateway_interface() || $net->{network}{GATEWAYDEV} || $net->{network}{GATEWAY} && find_matching_interface($net, $net->{network}{GATEWAY}) || (find { get_interface_type($net->{ifcfg}{$_}) eq 'adsl' } @intfs) || |