]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/neighbor: also remove neighbor on cancelling request
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 2 Jan 2024 19:40:39 +0000 (04:40 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 5 Jan 2024 10:17:59 +0000 (19:17 +0900)
Otherwise, the neighbor may arrive after we call
link_drop_foreign_address() or so on reconfiguring interface.

src/network/networkd-link.c
src/network/networkd-neighbor.c
src/network/networkd-neighbor.h

index 396b2a4d0a97d00279cb168ed4b1d88ab5fe7e30..69f6a0ce726e6e4b027229c17500dd1ed3189c76 100644 (file)
@@ -954,6 +954,13 @@ static int link_drop_requests(Link *link) {
                                         RET_GATHER(ret, address_remove(address, link));
                                 break;
                         }
+                        case REQUEST_TYPE_NEIGHBOR: {
+                                Neighbor *neighbor = ASSERT_PTR(req->userdata);
+
+                                if (neighbor_get(link, neighbor, NULL) < 0)
+                                        RET_GATHER(ret, neighbor_remove(neighbor, link));
+                                break;
+                        }
                         default:
                                 ;
                         }
index e172c564b006d852fe80fefc40918de187cb745f..cdc5dd78a823be2f3fea19710a7fa1e7bbeae0b4 100644 (file)
@@ -152,7 +152,7 @@ static int neighbor_get_request(Link *link, const Neighbor *neighbor, Request **
         return 0;
 }
 
-static int neighbor_get(Link *link, const Neighbor *in, Neighbor **ret) {
+int neighbor_get(Link *link, const Neighbor *in, Neighbor **ret) {
         Neighbor *existing;
 
         assert(link);
@@ -370,18 +370,14 @@ static int neighbor_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link
         return 1;
 }
 
-static int neighbor_remove(Neighbor *neighbor) {
+int neighbor_remove(Neighbor *neighbor, Link *link) {
         _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
-        Request *req;
-        Link *link;
         int r;
 
         assert(neighbor);
-        assert(neighbor->link);
-        assert(neighbor->link->manager);
-        assert(neighbor->link->manager->rtnl);
-
-        link = neighbor->link;
+        assert(link);
+        assert(link->manager);
+        assert(link->manager->rtnl);
 
         log_neighbor_debug(neighbor, "Removing", link);
 
@@ -402,9 +398,6 @@ static int neighbor_remove(Neighbor *neighbor) {
         link_ref(link);
 
         neighbor_enter_removing(neighbor);
-        if (neighbor_get_request(neighbor->link, neighbor, &req) >= 0)
-                neighbor_enter_removing(req->userdata);
-
         return 0;
 }
 
@@ -440,7 +433,7 @@ int link_drop_foreign_neighbors(Link *link) {
                 if (!neighbor_is_marked(neighbor))
                         continue;
 
-                RET_GATHER(r, neighbor_remove(neighbor));
+                RET_GATHER(r, neighbor_remove(neighbor, link));
         }
 
         return r;
@@ -461,7 +454,7 @@ int link_drop_managed_neighbors(Link *link) {
                 if (!neighbor_exists(neighbor))
                         continue;
 
-                RET_GATHER(r, neighbor_remove(neighbor));
+                RET_GATHER(r, neighbor_remove(neighbor, link));
         }
 
         return r;
index 683a310b3f34e09d6cdb32a54d6f2a6c5ff0e9c9..0d1216c21c78869da99d86a666e01bdbd0a364ad 100644 (file)
@@ -28,6 +28,9 @@ typedef struct Neighbor {
 
 Neighbor *neighbor_free(Neighbor *neighbor);
 
+int neighbor_get(Link *link, const Neighbor *in, Neighbor **ret);
+int neighbor_remove(Neighbor *neighbor, Link *link);
+
 int network_drop_invalid_neighbors(Network *network);
 
 int link_drop_managed_neighbors(Link *link);