mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-03 01:17:45 +03:00
udev: re-assign ID_NET_DRIVER=, ID_NET_LINK_FILE=, ID_NET_NAME= properties on non-'add' uevent
Previous commit makes drop ID_NET_DRIVER=, ID_NET_LINK_FILE=, and ID_NET_NAME= properties for network interfaces on 'move' uevent. ID_NET_DRIVER= and ID_NET_LINK_FILE= properties are used by networkctl. ID_NET_NAME= may be used by end-user rules or programs. So, let's re-assign them on 'move' uevent. (Note that strictly speaking, this makes them re-assigned on all but 'remove' uevent.)
This commit is contained in:
parent
51d9aec0ff
commit
e0e789c1e9
@ -4,7 +4,7 @@ SUBSYSTEM!="net", GOTO="net_setup_link_end"
|
|||||||
|
|
||||||
IMPORT{builtin}="path_id"
|
IMPORT{builtin}="path_id"
|
||||||
|
|
||||||
ACTION!="add", GOTO="net_setup_link_end"
|
ACTION=="remove", GOTO="net_setup_link_end"
|
||||||
|
|
||||||
IMPORT{builtin}="net_setup_link"
|
IMPORT{builtin}="net_setup_link"
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "conf-files.h"
|
#include "conf-files.h"
|
||||||
#include "conf-parser.h"
|
#include "conf-parser.h"
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
|
#include "device-private.h"
|
||||||
#include "device-util.h"
|
#include "device-util.h"
|
||||||
#include "ethtool-util.h"
|
#include "ethtool-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
@ -605,6 +606,7 @@ static int link_config_apply_alternative_names(sd_netlink **rtnl, const link_con
|
|||||||
|
|
||||||
int link_config_apply(link_config_ctx *ctx, const link_config *config, sd_device *device, const char **ret_name) {
|
int link_config_apply(link_config_ctx *ctx, const link_config *config, sd_device *device, const char **ret_name) {
|
||||||
const char *new_name;
|
const char *new_name;
|
||||||
|
DeviceAction a;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(ctx);
|
assert(ctx);
|
||||||
@ -612,6 +614,20 @@ int link_config_apply(link_config_ctx *ctx, const link_config *config, sd_device
|
|||||||
assert(device);
|
assert(device);
|
||||||
assert(ret_name);
|
assert(ret_name);
|
||||||
|
|
||||||
|
r = device_get_action(device, &a);
|
||||||
|
if (r < 0)
|
||||||
|
return log_device_error_errno(device, r, "Failed to get ACTION= property: %m");
|
||||||
|
|
||||||
|
if (!IN_SET(a, DEVICE_ACTION_ADD, DEVICE_ACTION_BIND, DEVICE_ACTION_MOVE)) {
|
||||||
|
log_device_debug(device, "Skipping to apply .link settings on '%s' uevent.", device_action_to_string(a));
|
||||||
|
|
||||||
|
r = sd_device_get_sysname(device, ret_name);
|
||||||
|
if (r < 0)
|
||||||
|
return log_device_error_errno(device, r, "Failed to get sysname: %m");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
r = link_config_apply_ethtool_settings(&ctx->ethtool_fd, config, device);
|
r = link_config_apply_ethtool_settings(&ctx->ethtool_fd, config, device);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
@ -620,9 +636,17 @@ int link_config_apply(link_config_ctx *ctx, const link_config *config, sd_device
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = link_config_generate_new_name(ctx, config, device, &new_name);
|
if (a == DEVICE_ACTION_MOVE) {
|
||||||
if (r < 0)
|
log_device_debug(device, "Skipping to apply Name= and NamePolicy= on '%s' uevent.", device_action_to_string(a));
|
||||||
return r;
|
|
||||||
|
r = sd_device_get_sysname(device, &new_name);
|
||||||
|
if (r < 0)
|
||||||
|
return log_device_error_errno(device, r, "Failed to get sysname: %m");
|
||||||
|
} else {
|
||||||
|
r = link_config_generate_new_name(ctx, config, device, &new_name);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
r = link_config_apply_alternative_names(&ctx->rtnl, config, device, new_name);
|
r = link_config_apply_alternative_names(&ctx->rtnl, config, device, new_name);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user