summaryrefslogtreecommitdiff
path: root/src/udev/net/link-config.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/link-config.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/link-config.c')
-rw-r--r--src/udev/net/link-config.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index e8389c9be0..40b1d7f7bc 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -90,16 +90,17 @@ int link_config_ctx_new(link_config_ctx **ret) {
static int link_config_ctx_connect(link_config_ctx *ctx) {
int r;
- if (ctx->ethtool_fd >= 0 && ctx->rtnl)
- return 0;
-
- r = ethtool_connect(&ctx->ethtool_fd);
- if (r < 0)
- return r;
+ if (ctx->ethtool_fd == -1) {
+ r = ethtool_connect(&ctx->ethtool_fd);
+ if (r < 0)
+ return r;
+ }
- r = sd_rtnl_open(&ctx->rtnl, 0);
- if (r < 0)
- return r;
+ if (!ctx->rtnl) {
+ r = sd_rtnl_open(&ctx->rtnl, 0);
+ if (r < 0)
+ return r;
+ }
return 0;
}
@@ -442,6 +443,27 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, struct udev_dev
return 0;
}
+int link_get_driver(link_config_ctx *ctx, struct udev_device *device, char **ret) {
+ const char *name;
+ char *driver;
+ int r;
+
+ r = link_config_ctx_connect(ctx);
+ if (r < 0)
+ return r;
+
+ name = udev_device_get_sysname(device);
+ if (!name)
+ return -EINVAL;
+
+ r = ethtool_get_driver(ctx->ethtool_fd, name, &driver);
+ if (r < 0)
+ return r;
+
+ *ret = driver;
+ return 0;
+}
+
static const char* const mac_policy_table[] = {
[MACPOLICY_PERSISTENT] = "persistent",
[MACPOLICY_RANDOM] = "random"