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
20 changes: 10 additions & 10 deletions homa_incoming.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,16 +668,6 @@ void homa_data_pkt(struct sk_buff *skb, struct homa_rpc *rpc)
tt_addr(rpc->peer->addr), ntohl(h->seg.offset),
ntohl(h->message_length));

if (h->ack.client_id) {
const struct in6_addr saddr = skb_canonical_ipv6_saddr(skb);

homa_rpc_unlock(rpc);
homa_rpc_acked(rpc->hsk, &saddr, &h->ack);
homa_rpc_lock(rpc);
if (rpc->state == RPC_DEAD)
goto discard;
}

if (rpc->state != RPC_INCOMING && homa_is_client(rpc->id)) {
if (unlikely(rpc->state != RPC_OUTGOING))
goto discard;
Expand Down Expand Up @@ -728,6 +718,16 @@ void homa_data_pkt(struct sk_buff *skb, struct homa_rpc *rpc)
homa_rpc_handoff(rpc);
}

if (h->ack.client_id) {
const struct in6_addr saddr = skb_canonical_ipv6_saddr(skb);

homa_rpc_unlock(rpc);
homa_rpc_acked(rpc->hsk, &saddr, &h->ack);
homa_rpc_lock(rpc);
if (rpc->state == RPC_DEAD)
return;
}

#ifndef __STRIP__ /* See strip.py */
if (ntohs(h->cutoff_version) != homa->cutoff_version) {
/* The sender has out-of-date cutoffs. Note: we may need
Expand Down
12 changes: 9 additions & 3 deletions test/unit_homa_incoming.c
Original file line number Diff line number Diff line change
Expand Up @@ -1418,10 +1418,16 @@ TEST_F(homa_incoming, homa_data_pkt__handle_ack_rpc_now_dead)
1400, 0), srpc);
homa_rpc_unlock(srpc);
EXPECT_EQ(RPC_DEAD, srpc->state);
/* With the issue #77 fix the piggy-backed ACK is processed *after*
* homa_add_packet has queued the skb, so by the time we observe
* RPC_DEAD the packet has been added (bytes_remaining: 8600 - 1400)
* and the function returns instead of going through `goto discard`
* (kfree_skb on a queued skb would be use-after-free; the msgin
* destructor reaps it on RPC teardown).
*/
EXPECT_SUBSTR("ack 1235; "
"homa_rpc_end invoked; "
"homa_data_pkt discarded packet", unit_log_get());
EXPECT_EQ(8600, srpc->msgin.bytes_remaining);
"homa_rpc_end invoked", unit_log_get());
EXPECT_EQ(7200, srpc->msgin.bytes_remaining);
}
TEST_F(homa_incoming, homa_data_pkt__wrong_client_rpc_state)
{
Expand Down