summaryrefslogtreecommitdiff
path: root/src/network/networkd-network.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-05-12 00:22:29 +0200
committerTom Gundersen <teg@jklm.no>2015-05-12 00:43:45 +0200
commit24c083dfcbff3d1dd86a22cba7555a9ae6d8a53d (patch)
treef4e30951822d9ae9d9c6e00a02ed152ebb98ed90 /src/network/networkd-network.c
parente4f66b7773ae21278bf6b9c02a3282eec5996266 (diff)
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 af3aa302741b6edb0729925febb5f8bc26721fe3.
Diffstat (limited to 'src/network/networkd-network.c')
-rw-r--r--src/network/networkd-network.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 4d4972e5d6..8aa4eb2ed1 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -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;