summaryrefslogtreecommitdiffstats
path: root/src/udev
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-08-30 01:30:12 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-08-31 14:21:10 +0200
commit751dcd8d81144372f8db369c7cb727d1b6ac8f23 (patch)
treea36fc0370af1a91182674c408d74469437f16a30 /src/udev
parentudev: pass rtnl to builtin commands (diff)
downloadsystemd-751dcd8d81144372f8db369c7cb727d1b6ac8f23.tar.xz
systemd-751dcd8d81144372f8db369c7cb727d1b6ac8f23.zip
udev: use passed rtnl in net_setup_link builtin command
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/net/link-config.c14
-rw-r--r--src/udev/net/link-config.h5
-rw-r--r--src/udev/udev-builtin-net_setup_link.c4
3 files changed, 12 insertions, 11 deletions
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index 4963ba2fae..14ca2e032e 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -37,7 +37,6 @@ struct LinkConfigContext {
LIST_HEAD(LinkConfig, links);
int ethtool_fd;
bool enable_name_policy;
- sd_netlink *rtnl;
usec_t network_dirs_ts_usec;
};
@@ -78,7 +77,6 @@ LinkConfigContext *link_config_ctx_free(LinkConfigContext *ctx) {
return NULL;
safe_close(ctx->ethtool_fd);
- sd_netlink_unref(ctx->rtnl);
link_configs_free(ctx);
return mfree(ctx);
}
@@ -239,7 +237,7 @@ bool link_config_should_reload(LinkConfigContext *ctx) {
return paths_check_timestamp(NETWORK_DIRS, &ctx->network_dirs_ts_usec, false);
}
-int link_config_get(LinkConfigContext *ctx, sd_device *device, LinkConfig **ret) {
+int link_config_get(LinkConfigContext *ctx, sd_netlink **rtnl, sd_device *device, LinkConfig **ret) {
unsigned name_assign_type = NET_NAME_UNKNOWN;
struct ether_addr permanent_mac = {};
unsigned short iftype;
@@ -249,6 +247,7 @@ int link_config_get(LinkConfigContext *ctx, sd_device *device, LinkConfig **ret)
int ifindex, r;
assert(ctx);
+ assert(rtnl);
assert(device);
assert(ret);
@@ -260,7 +259,7 @@ int link_config_get(LinkConfigContext *ctx, sd_device *device, LinkConfig **ret)
if (r < 0)
return r;
- r = rtnl_get_link_info(&ctx->rtnl, ifindex, &iftype, &flags);
+ r = rtnl_get_link_info(rtnl, ifindex, &iftype, &flags);
if (r < 0)
return r;
@@ -606,13 +605,14 @@ static int link_config_apply_alternative_names(sd_netlink **rtnl, const LinkConf
return 0;
}
-int link_config_apply(LinkConfigContext *ctx, const LinkConfig *config, sd_device *device, const char **ret_name) {
+int link_config_apply(LinkConfigContext *ctx, const LinkConfig *config, sd_netlink **rtnl, sd_device *device, const char **ret_name) {
const char *new_name;
sd_device_action_t a;
int r;
assert(ctx);
assert(config);
+ assert(rtnl);
assert(device);
assert(ret_name);
@@ -634,7 +634,7 @@ int link_config_apply(LinkConfigContext *ctx, const LinkConfig *config, sd_devic
if (r < 0)
return r;
- r = link_config_apply_rtnl_settings(&ctx->rtnl, config, device);
+ r = link_config_apply_rtnl_settings(rtnl, config, device);
if (r < 0)
return r;
@@ -650,7 +650,7 @@ int link_config_apply(LinkConfigContext *ctx, const LinkConfig *config, sd_devic
return r;
}
- r = link_config_apply_alternative_names(&ctx->rtnl, config, device, new_name);
+ r = link_config_apply_alternative_names(rtnl, config, device, new_name);
if (r < 0)
return r;
diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h
index 8a29a92822..38a02a75b9 100644
--- a/src/udev/net/link-config.h
+++ b/src/udev/net/link-config.h
@@ -2,6 +2,7 @@
#pragma once
#include "sd-device.h"
+#include "sd-netlink.h"
#include "condition.h"
#include "conf-parser.h"
@@ -77,8 +78,8 @@ int link_load_one(LinkConfigContext *ctx, const char *filename);
int link_config_load(LinkConfigContext *ctx);
bool link_config_should_reload(LinkConfigContext *ctx);
-int link_config_get(LinkConfigContext *ctx, sd_device *device, LinkConfig **ret);
-int link_config_apply(LinkConfigContext *ctx, const LinkConfig *config, sd_device *device, const char **ret_name);
+int link_config_get(LinkConfigContext *ctx, sd_netlink **rtnl, sd_device *device, LinkConfig **ret);
+int link_config_apply(LinkConfigContext *ctx, const LinkConfig *config, sd_netlink **rtnl, sd_device *device, const char **ret_name);
int link_get_driver(LinkConfigContext *ctx, sd_device *device, char **ret);
const char *name_policy_to_string(NamePolicy p) _const_;
diff --git a/src/udev/udev-builtin-net_setup_link.c b/src/udev/udev-builtin-net_setup_link.c
index 49492349b2..4c7a5b23fd 100644
--- a/src/udev/udev-builtin-net_setup_link.c
+++ b/src/udev/udev-builtin-net_setup_link.c
@@ -26,7 +26,7 @@ static int builtin_net_setup_link(sd_device *dev, sd_netlink **rtnl, int argc, c
else
udev_builtin_add_property(dev, test, "ID_NET_DRIVER", driver);
- r = link_config_get(ctx, dev, &link);
+ r = link_config_get(ctx, rtnl, dev, &link);
if (r < 0) {
if (r == -ENODEV)
return log_device_debug_errno(dev, r, "Link vanished while searching for configuration for it.");
@@ -38,7 +38,7 @@ static int builtin_net_setup_link(sd_device *dev, sd_netlink **rtnl, int argc, c
return log_device_error_errno(dev, r, "Failed to get link config: %m");
}
- r = link_config_apply(ctx, link, dev, &name);
+ r = link_config_apply(ctx, link, rtnl, dev, &name);
if (r == -ENODEV)
log_device_debug_errno(dev, r, "Link vanished while applying configuration, ignoring.");
else if (r < 0)