summaryrefslogtreecommitdiffstats
path: root/src/network/netdev
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-10-27 15:02:50 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-10-29 19:07:32 +0100
commit3252a1f2740904f2a2544994514d34a94c30cbfc (patch)
tree06754d685db9930d8123e6336481d5f68e6c0c7a /src/network/netdev
parentMerge pull request #34245 from bluca/logind_drop_weak_delay_inhibitor (diff)
downloadsystemd-3252a1f2740904f2a2544994514d34a94c30cbfc.tar.xz
systemd-3252a1f2740904f2a2544994514d34a94c30cbfc.zip
network/netdev: split out netdev_attach_name_full()
No functional change, preparation for later commits.
Diffstat (limited to 'src/network/netdev')
-rw-r--r--src/network/netdev/netdev.c14
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;