diff options
-rw-r--r-- | src/network/netdev/netdev.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c index 8e58a1ae12..965b218a06 100644 --- a/src/network/netdev/netdev.c +++ b/src/network/netdev/netdev.c @@ -273,18 +273,17 @@ void netdev_drop(NetDev *netdev) { netdev_detach(netdev); } -int netdev_attach_name(NetDev *netdev, const char *name) { +static int netdev_attach_name_full(NetDev *netdev, const char *name, Hashmap **netdevs) { int r; assert(netdev); - assert(netdev->manager); assert(name); - r = hashmap_ensure_put(&netdev->manager->netdevs, &string_hash_ops, name, netdev); + r = hashmap_ensure_put(netdevs, &string_hash_ops, name, netdev); if (r == -ENOMEM) return log_oom(); if (r == -EEXIST) { - NetDev *n = hashmap_get(netdev->manager->netdevs, name); + NetDev *n = hashmap_get(*netdevs, name); assert(n); if (!streq(netdev->filename, n->filename)) @@ -299,6 +298,13 @@ int netdev_attach_name(NetDev *netdev, const char *name) { return 0; } +int netdev_attach_name(NetDev *netdev, const char *name) { + assert(netdev); + assert(netdev->manager); + + return netdev_attach_name_full(netdev, name, &netdev->manager->netdevs); +} + static int netdev_attach(NetDev *netdev) { int r; |