summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-01-02 20:40:39 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-01-05 11:17:59 +0100
commitc902fa08c312f9dad539dd7ead5f7e0616ff2d43 (patch)
treed276862db907fc6a03cc0fd7c8ee46f728f68c65 /src
parentnetwork/address: also remove address on cancelling request (diff)
downloadsystemd-c902fa08c312f9dad539dd7ead5f7e0616ff2d43.tar.xz
systemd-c902fa08c312f9dad539dd7ead5f7e0616ff2d43.zip
network/neighbor: also remove neighbor on cancelling request
Otherwise, the neighbor may arrive after we call link_drop_foreign_address() or so on reconfiguring interface.
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-link.c7
-rw-r--r--src/network/networkd-neighbor.c21
-rw-r--r--src/network/networkd-neighbor.h3
3 files changed, 17 insertions, 14 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 396b2a4d0a..69f6a0ce72 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -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:
;
}
diff --git a/src/network/networkd-neighbor.c b/src/network/networkd-neighbor.c
index e172c564b0..cdc5dd78a8 100644
--- a/src/network/networkd-neighbor.c
+++ b/src/network/networkd-neighbor.c
@@ -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;
diff --git a/src/network/networkd-neighbor.h b/src/network/networkd-neighbor.h
index 683a310b3f..0d1216c21c 100644
--- a/src/network/networkd-neighbor.h
+++ b/src/network/networkd-neighbor.h
@@ -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);