diff options
Diffstat (limited to 'perl-install/network/ethernet.pm')
-rw-r--r-- | perl-install/network/ethernet.pm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm index 845d7b3d8..a6e58df1b 100644 --- a/perl-install/network/ethernet.pm +++ b/perl-install/network/ethernet.pm @@ -39,7 +39,8 @@ sub mapIntfToDevice { my ($interface) = @_; my $hw_addr = c::getHwIDs($interface); my ($bus, $slot, $func) = map { hex($_) } ($hw_addr =~ /([0-9a-f]+):([0-9a-f]+)\.([0-9a-f]+)/); - $hw_addr ? grep { $_->{pci_bus} == $bus && $_->{pci_device} == $slot && $_->{pci_function} == $func } detect_devices::probeall() : {}; + $hw_addr && (every { defined $_ } $bus, $slot, $func) ? + grep { $_->{pci_bus} == $bus && $_->{pci_device} == $slot && $_->{pci_function} == $func } detect_devices::probeall() : {}; } @@ -62,8 +63,19 @@ sub get_eth_cards() { ($description) = (mapIntfToDevice($interface))[0]->{description}; } if (!$description) { + my $drv = readlink("/sys/class/net/$interface/driver"); + if ($drv and $drv =~ s!.*/!!) { + $a = $drv; + my %l; + my %sysfs_fields = (id => "device", subid => "subsystem_device", vendor => "vendor", subvendor => "subsystem_vendor"); + $l{$_} = hex(chomp_(cat_("/sys/class/net/$interface/device/" . $sysfs_fields{$_}))) foreach keys %sysfs_fields; + my @cards = grep { my $dev = $_; every { $dev->{$_} eq $l{$_} } keys %l } detect_devices::probeall(); + $description = $cards[0]{description} if $#cards == 0; + } + } + if (!$description) { my @cards = grep { $_->{driver} eq ($a || $saved_driver) } detect_devices::probeall(); - $description = $cards[0]{descripxtion} if @cards == 1; + $description = $cards[0]->{description} if $#cards == 0; } $a and $saved_driver = $a; # handle multiple cards managed by the same driver [ $interface, $saved_driver, if_($description, $description) ] |