diff options
author | Thierry Vignaud <thierry.vignaud@gmail.com> | 2016-07-01 17:33:43 +0200 |
---|---|---|
committer | Thierry Vignaud <thierry.vignaud@gmail.com> | 2016-07-01 17:41:15 +0200 |
commit | dca3a0bf7c1b807b8a568c436b0225f7c1c2762c (patch) | |
tree | cdc9a5fb952922b5d2f2dcdc8a8f7e0450bde2c5 /mdk-stage1 | |
parent | bac52c60e891ed3e927b508729d04be720fd34d6 (diff) | |
download | drakx-dca3a0bf7c1b807b8a568c436b0225f7c1c2762c.tar drakx-dca3a0bf7c1b807b8a568c436b0225f7c1c2762c.tar.gz drakx-dca3a0bf7c1b807b8a568c436b0225f7c1c2762c.tar.bz2 drakx-dca3a0bf7c1b807b8a568c436b0225f7c1c2762c.tar.xz drakx-dca3a0bf7c1b807b8a568c436b0225f7c1c2762c.zip |
fix description of network interfaces (mga#15638)
It got broken when switching stage1 to udev: previously we were manually
loading the driver and thus we knew which driver corresponded to the
newly created intf.
Since mga4, the driver has already been loaded by udev and thus we fail
to associate the intf with the right driver and thus we failed to get
the driver description.
=> let's use the ethtool IOCTL like the stage2 does
Diffstat (limited to 'mdk-stage1')
-rw-r--r-- | mdk-stage1/NEWS | 2 | ||||
-rw-r--r-- | mdk-stage1/probing.c | 26 |
2 files changed, 23 insertions, 5 deletions
diff --git a/mdk-stage1/NEWS b/mdk-stage1/NEWS index e24d81e07..0b4b73aab 100644 --- a/mdk-stage1/NEWS +++ b/mdk-stage1/NEWS @@ -1,3 +1,5 @@ +- fix description of network interfaces (mga#15638) + 2.19 - recognize some missing wireless drivers (mga#16768) diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c index 956038da2..b9420deb7 100644 --- a/mdk-stage1/probing.c +++ b/mdk-stage1/probing.c @@ -40,6 +40,8 @@ #include <fnmatch.h> #include <sys/socket.h> #include <net/if.h> +#include <linux/sockios.h> +#include <linux/ethtool.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <pci/pci.h> @@ -125,11 +127,25 @@ void net_discovered_interface(char * intf_name) char * get_net_intf_description(char * intf_name) { - int i; - for (i = 0; i < net_descr_number ; i++) - if (!strcmp(net_descriptions[i].intf_name, intf_name)) - return net_descriptions[i].intf_description; - return strdup("unknown"); + struct ifreq ifr; + struct ethtool_drvinfo drvinfo; + int s = socket(AF_INET, SOCK_DGRAM, 0); + char *res; + + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, intf_name, IFNAMSIZ); + + drvinfo.cmd = ETHTOOL_GDRVINFO; + ifr.ifr_data = (caddr_t) &drvinfo; + + if (ioctl(s, SIOCETHTOOL, &ifr) != -1) { + res = drvinfo.driver; + } else { + perror("SIOCETHTOOL"); + res = "unknown"; + } + close(s); + return strdup(res); } #endif |