From dca3a0bf7c1b807b8a568c436b0225f7c1c2762c Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Fri, 1 Jul 2016 17:33:43 +0200 Subject: 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 --- mdk-stage1/NEWS | 2 ++ mdk-stage1/probing.c | 26 +++++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'mdk-stage1') 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 #include #include +#include +#include #include #include #include @@ -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 -- cgit v1.2.1