networkd: network_get - allow udev_device to be NULL

In containers we never have udev devices, so drop the assert.

This fixes an assertion introduced in af3aa30274.
This commit is contained in:
Tom Gundersen 2015-05-12 00:22:29 +02:00
parent e4f66b7773
commit 24c083dfcb
2 changed files with 10 additions and 13 deletions

2
TODO
View File

@ -49,8 +49,6 @@ Before 220:
* introduce argv0array=
* Assertion 'device' failed at src/network/networkd-network.c:280, function network_get(). Aborting.
Features:
* invent a better systemd-run scheme for naming scopes, that works with remoting

View File

@ -273,23 +273,22 @@ int network_get(Manager *manager, struct udev_device *device,
Network **ret) {
Network *network;
struct udev_device *parent;
const char *path, *parent_driver, *driver, *devtype;
const char *path = NULL, *parent_driver = NULL, *driver = NULL, *devtype = NULL;
assert(manager);
assert(ret);
assert(device);
path = udev_device_get_property_value(device, "ID_PATH");
if (device) {
path = udev_device_get_property_value(device, "ID_PATH");
parent = udev_device_get_parent(device);
if (parent)
parent_driver = udev_device_get_driver(parent);
else
parent_driver = NULL;
parent = udev_device_get_parent(device);
if (parent)
parent_driver = udev_device_get_driver(parent);
driver = udev_device_get_property_value(device, "ID_NET_DRIVER");
driver = udev_device_get_property_value(device, "ID_NET_DRIVER");
devtype = udev_device_get_devtype(device);
devtype = udev_device_get_devtype(device);
}
LIST_FOREACH(networks, network, manager->networks) {
if (net_match_config(network->match_mac, network->match_path,
@ -299,7 +298,7 @@ int network_get(Manager *manager, struct udev_device *device,
network->match_arch,
address, path, parent_driver, driver,
devtype, ifname)) {
if (network->match_name) {
if (network->match_name && device) {
const char *attr;
uint8_t name_assign_type = NET_NAME_UNKNOWN;