summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd/network-merge-link_drop-and-link_detach_from_manager.patch
blob: 65bdc611df7304f5d67c7427096b7a26fbf21401 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
From 63130eb36dc51e4fd50716c585f98ebe456ca7cf Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Mon, 17 May 2021 15:40:15 +0900
Subject: [PATCH] network: merge link_drop() and link_detach_from_manager()

link_detach_from_manager() is only called by link_drop(). It is not
necessary to split such tiny function.

Upstream-Status: Backport [https://github.com/systemd/systemd-stable/commit/63130eb36dc51e4fd50716c585f98ebe456ca7cf]
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>

---
 src/network/networkd-link.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 9d30e16b0a..67d01ac44d 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -2019,24 +2019,17 @@ static void link_drop_from_master(Link *link, NetDev *netdev) {
         link_unref(set_remove(master->slaves, link));
 }
 
-static void link_detach_from_manager(Link *link) {
-        if (!link || !link->manager)
-                return;
-
-        link_unref(set_remove(link->manager->links_requesting_uuid, link));
-        link_clean(link);
-
-        /* The following must be called at last. */
-        assert_se(hashmap_remove(link->manager->links, INT_TO_PTR(link->ifindex)) == link);
-        link_unref(link);
-}
-
 void link_drop(Link *link) {
-        if (!link || link->state == LINK_STATE_LINGER)
+        if (!link)
                 return;
 
+        assert(link->manager);
+
         link_set_state(link, LINK_STATE_LINGER);
 
+        /* Drop all references from other links and manager. Note that async netlink calls may have
+         * references to the link, and they will be dropped when we receive replies. */
+
         link_free_carrier_maps(link);
 
         if (link->network) {
@@ -2044,10 +2037,14 @@ void link_drop(Link *link) {
                 link_drop_from_master(link, link->network->bond);
         }
 
-        log_link_debug(link, "Link removed");
+        link_unref(set_remove(link->manager->links_requesting_uuid, link));
 
         (void) unlink(link->state_file);
-        link_detach_from_manager(link);
+        link_clean(link);
+
+        /* The following must be called at last. */
+        assert_se(hashmap_remove(link->manager->links, INT_TO_PTR(link->ifindex)) == link);
+        link_unref(link);
 }
 
 static int link_joined(Link *link) {