From c48fab451e7b4dcc44f8c70818000024c73c8e8e Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Wed, 31 Aug 2005 14:32:15 +0000 Subject: add get_current_gateway_interface --- perl-install/network/tools.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'perl-install') 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) || -- cgit v1.2.1