summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdk-stage1/NEWS2
-rw-r--r--mdk-stage1/probing.c26
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