1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

Merge pull request #11729 from yuwata/fix-11721

sd-device: also store properties read from udev database to sd_device::properties_db
This commit is contained in:
Lennart Poettering 2019-02-18 16:02:26 +01:00 committed by GitHub
commit 9c5675af76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 16 deletions

View File

@ -107,7 +107,6 @@ bool net_match_config(Set *match_mac,
Condition *match_arch,
const struct ether_addr *dev_mac,
const char *dev_path,
const char *dev_parent_driver,
const char *dev_driver,
const char *dev_type,
const char *dev_name) {

View File

@ -25,7 +25,6 @@ bool net_match_config(Set *match_mac,
Condition *match_arch,
const struct ether_addr *dev_mac,
const char *dev_path,
const char *dev_parent_driver,
const char *dev_driver,
const char *dev_type,
const char *dev_name);

View File

@ -1110,6 +1110,7 @@ int device_add_devlink(sd_device *device, const char *devlink) {
static int device_add_property_internal_from_string(sd_device *device, const char *str) {
_cleanup_free_ char *key = NULL;
char *value;
int r;
assert(device);
assert(str);
@ -1127,7 +1128,13 @@ static int device_add_property_internal_from_string(sd_device *device, const cha
if (isempty(++value))
value = NULL;
return device_add_property_internal(device, key, value);
/* Add the property to both sd_device::properties and sd_device::properties_db,
* as this is called by only handle_db_line(). */
r = device_add_property_aux(device, key, value, false);
if (r < 0)
return r;
return device_add_property_aux(device, key, value, true);
}
int device_set_usec_initialized(sd_device *device, usec_t when) {

View File

@ -673,7 +673,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
netdev_raw->match_host, netdev_raw->match_virt,
netdev_raw->match_kernel_cmdline, netdev_raw->match_kernel_version,
netdev_raw->match_arch,
NULL, NULL, NULL, NULL, NULL, NULL) <= 0)
NULL, NULL, NULL, NULL, NULL) <= 0)
return 0;
if (netdev_raw->kind == _NETDEV_KIND_INVALID) {

View File

@ -427,8 +427,7 @@ int network_get_by_name(Manager *manager, const char *name, Network **ret) {
int network_get(Manager *manager, sd_device *device,
const char *ifname, const struct ether_addr *address,
Network **ret) {
const char *path = NULL, *parent_driver = NULL, *driver = NULL, *devtype = NULL;
sd_device *parent;
const char *path = NULL, *driver = NULL, *devtype = NULL;
Network *network;
assert(manager);
@ -437,9 +436,6 @@ int network_get(Manager *manager, sd_device *device,
if (device) {
(void) sd_device_get_property_value(device, "ID_PATH", &path);
if (sd_device_get_parent(device, &parent) >= 0)
(void) sd_device_get_driver(parent, &parent_driver);
(void) sd_device_get_property_value(device, "ID_NET_DRIVER", &driver);
(void) sd_device_get_devtype(device, &devtype);
@ -451,8 +447,7 @@ int network_get(Manager *manager, sd_device *device,
network->match_name, network->match_host,
network->match_virt, network->match_kernel_cmdline,
network->match_kernel_version, network->match_arch,
address, path, parent_driver, driver,
devtype, ifname)) {
address, path, driver, devtype, ifname)) {
if (network->match_name && device) {
const char *attr;
uint8_t name_assign_type = NET_NAME_UNKNOWN;

View File

@ -243,13 +243,10 @@ int link_config_get(link_config_ctx *ctx, sd_device *device, link_config **ret)
assert(ret);
LIST_FOREACH(links, link, ctx->links) {
const char *address = NULL, *id_path = NULL, *parent_driver = NULL, *id_net_driver = NULL, *devtype = NULL, *sysname = NULL;
sd_device *parent;
const char *address = NULL, *id_path = NULL, *id_net_driver = NULL, *devtype = NULL, *sysname = NULL;
(void) sd_device_get_sysattr_value(device, "address", &address);
(void) sd_device_get_property_value(device, "ID_PATH", &id_path);
if (sd_device_get_parent(device, &parent) >= 0)
(void) sd_device_get_driver(parent, &parent_driver);
(void) sd_device_get_property_value(device, "ID_NET_DRIVER", &id_net_driver);
(void) sd_device_get_devtype(device, &devtype);
(void) sd_device_get_sysname(device, &sysname);
@ -260,7 +257,6 @@ int link_config_get(link_config_ctx *ctx, sd_device *device, link_config **ret)
link->match_kernel_version, link->match_arch,
address ? ether_aton(address) : NULL,
id_path,
parent_driver,
id_net_driver,
devtype,
sysname)) {

View File

@ -286,6 +286,11 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
self.assertNotRegex(output, '1 lo ')
self.assertRegex(output, 'dropin-test')
output = subprocess.check_output(['networkctl', 'status', 'dropin-*']).rstrip().decode('utf-8')
self.assertNotRegex(output, '1 lo ')
self.assertRegex(output, 'dropin-test')
self.assertRegex(output, 'Driver: dummy')
def test_bridge(self):
self.copy_unit_to_networkd_unit_path('25-bridge.netdev')
self.start_networkd()