Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions homa_peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ void homa_peer_free_net(struct homa_net *hnet)
WARN(hnet->num_routes != 0, "%s ended up with hnet->num_routes %d",
__func__, hnet->num_routes);
spin_unlock_bh(&peertab->lock);

/* homa_route_free uses hnet, which will be freed as soon as we
* return, so wait for the callbacks queued above.
*/
rcu_barrier();
}

/**
Expand Down
15 changes: 15 additions & 0 deletions test/unit_homa_peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@ TEST_F(homa_peer, homa_peer_free_net__basics)
unit_sock_destroy(&hsk2);
}

TEST_F(homa_peer, homa_peer_free_net__wait_for_rcu_callbacks)
{
/* The homa_net is freed as soon as homa_peer_free_net returns, so
* the homa_route_free callbacks (which use it) must have finished.
*/
struct homa_route *route;

route = homa_route_get(&self->hsk, ip1111);
homa_route_release(route);
EXPECT_EQ(1, unit_count_peers(&self->homa));

homa_peer_free_net(self->hnet);
EXPECT_EQ(0, unit_count_peers(&self->homa));
}

TEST_F(homa_peer, homa_route_delete_fn)
{
struct homa_route *route;
Expand Down