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.
This commit is contained in:
Yu Watanabe
2024-01-05 19:17:59 +09:00
parent 4303e9806b
commit c902fa08c3
3 changed files with 17 additions and 14 deletions
+7
View 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:
;
}
+7 -14
View 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;
+3
View 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);