summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2004-08-20 04:58:22 +0000
committerOlivier Blin <oblin@mandriva.org>2004-08-20 04:58:22 +0000
commitb01562e1827926be70ed81cd023df7a405baf997 (patch)
tree5e61c47d21a617755de7fc47a4c840af19ed39a9
parent61741c26ce220cbb435b526ea8fd16ff05588c43 (diff)
downloaddrakx-b01562e1827926be70ed81cd023df7a405baf997.tar
drakx-b01562e1827926be70ed81cd023df7a405baf997.tar.gz
drakx-b01562e1827926be70ed81cd023df7a405baf997.tar.bz2
drakx-b01562e1827926be70ed81cd023df7a405baf997.tar.xz
drakx-b01562e1827926be70ed81cd023df7a405baf997.zip
update mac address in network::ethernet::get_eth_cards to be sure iftab is always up-to-date
-rw-r--r--perl-install/network/ethernet.pm20
-rw-r--r--perl-install/network/network.pm9
2 files changed, 22 insertions, 7 deletions
diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm
index c533d4ade..2659950ef 100644
--- a/perl-install/network/ethernet.pm
+++ b/perl-install/network/ethernet.pm
@@ -82,13 +82,33 @@ sub get_eth_cards_names {
my ($modules_conf, @all_cards) = @_;
foreach my $card (@all_cards) {
+ #- fix modules aliases
$modules_conf->remove_alias($card->[1]);
$modules_conf->set_alias($card->[0], $card->[1]);
+
+ #- update iftab
+ update_eth_card_iftab($card->[0]);
}
{ map { $_->[0] => join(': ', $_->[0], $_->[2]) } @all_cards };
}
+#- returns (link_type, mac_address)
+sub get_eth_card_mac_address {
+ my ($intf) = @_;
+ `LC_ALL= LANG= $::prefix/sbin/ip -o link show $intf 2>/dev/null` =~ m|.*link/(\S+)\s([0-9a-z:]+)\s|;
+}
+
+#- write interface MAC address (if any) in iftab
+sub update_eth_card_iftab {
+ my ($intf) = @_;
+ my ($link_type, $mac_address) = get_eth_card_mac_address($intf) or next;
+ my $descriptor = ${{ ether => 'mac', ieee1394 => 'mac_ieee1394' }}{$link_type} or next;
+ substInFile {
+ s/^$intf\s+.*\n//;
+ $_ .= qq($intf\t$descriptor $mac_address\n) if eof
+ } "$::prefix/etc/iftab";
+}
# automatic net aliases configuration
sub configure_eth_aliases {
diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm
index 26e55beca..4be673b03 100644
--- a/perl-install/network/network.pm
+++ b/perl-install/network/network.pm
@@ -141,15 +141,10 @@ sub write_resolv_conf {
sub write_interface_conf {
my ($file, $intf, $_netc, $_prefix) = @_;
- my ($link_type, $mac_address) = `LC_ALL= LANG= $::prefix/sbin/ip -o link show $intf->{DEVICE} 2>/dev/null` =~ m|.*link/(\S+)\s([0-9a-z:]+)\s|;
+ require network::ethernet;
+ my (undef, $mac_address) = network::ethernet::get_eth_card_mac_address($intf->{DEVICE});
$intf->{HWADDR} &&= $mac_address; #- set HWADDR to MAC address if required
- #- write interface MAC address in iftab (if any)
- my $descriptor = ${{ ether => 'mac', ieee1394 => 'mac_ieee1394' }}{$link_type};
- if ($mac_address && $descriptor) {
- substInFile { s/^$intf->{DEVICE}\s+.*\n//; $_ .= qq($intf->{DEVICE}\t$descriptor $mac_address\n) if eof } "$::prefix/etc/iftab";
- }
-
my @ip = split '\.', $intf->{IPADDR};
my @mask = split '\.', $intf->{NETMASK};