mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-12 21:57:27 +03:00
udev: use passed rtnl in net_setup_link builtin command
This commit is contained in:
parent
92232230af
commit
751dcd8d81
@ -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;
|
||||
|
||||
|
@ -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_;
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user