summaryrefslogtreecommitdiffstats
path: root/perl-install/network/tools.pm
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2005-08-31 14:32:15 +0000
committerOlivier Blin <oblin@mandriva.org>2005-08-31 14:32:15 +0000
commitc48fab451e7b4dcc44f8c70818000024c73c8e8e (patch)
treee58ea4f451c864874148415bae3672af171a0a15 /perl-install/network/tools.pm
parent1b2177ab11b91e017bdbfcbd2fd99f025da4341c (diff)
downloaddrakx-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.pm9
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) ||