summaryrefslogtreecommitdiff
path: root/src/udev/net/ethtool-util.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-02-21 16:54:00 +0100
committerTom Gundersen <teg@jklm.no>2014-02-21 21:00:39 +0100
commit847a8a5fed4d265dfa659917515c6f9bd1b8d5c4 (patch)
treea66310a760d1ea59a366113d4ce5d35cd3f0c014 /src/udev/net/ethtool-util.c
parenta0eb2a751c6f3e9c233772cd9af8e8ee1504d27a (diff)
udev - link-setup - expose ID_NET_DRIVER
This is the same as shown by 'ethtool -i <ifname>', and is sometimes set even though DRIVER is not.
Diffstat (limited to 'src/udev/net/ethtool-util.c')
-rw-r--r--src/udev/net/ethtool-util.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/udev/net/ethtool-util.c b/src/udev/net/ethtool-util.c
index c644f91d02..aaba94c2fb 100644
--- a/src/udev/net/ethtool-util.c
+++ b/src/udev/net/ethtool-util.c
@@ -63,6 +63,29 @@ int ethtool_connect(int *ret) {
return 0;
}
+int ethtool_get_driver(int fd, const char *ifname, char **ret) {
+ struct ifreq ifr;
+ struct ethtool_drvinfo ecmd;
+ int r;
+
+ zero(ecmd);
+ ecmd.cmd = ETHTOOL_GDRVINFO;
+
+ zero(ifr);
+ strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
+ ifr.ifr_data = (void *)&ecmd;
+
+ r = ioctl(fd, SIOCETHTOOL, &ifr);
+ if (r < 0)
+ return -errno;
+
+ *ret = strdup(ecmd.driver);
+ if (!*ret)
+ return -ENOMEM;
+
+ return 0;
+}
+
int ethtool_set_speed(int fd, const char *ifname, unsigned int speed, Duplex duplex)
{
struct ifreq ifr;