Skip to content

Commit

Permalink
prov/xnet: Return an error if invalid sequence number received
Browse files Browse the repository at this point in the history
If compiled with --enable-debug, the provider would fail an
assertion if the sequence number received in the header doesn't
match the one expected.

Crashing on an assertion failure is fine for programming errors,
but the assertion failure described above relies on external events:
it may for example trigger because of a buffers corrupted by the
TCP stack or the physical layer.

Instead of an assertion failure, the function returns an error
code, which will cause the EP to be disabled as a consequence.

Signed-off-by: Sylvain Didelot <sdidelot@ddn.com>
  • Loading branch information
sydidelot committed Oct 10, 2023
1 parent 4843d1a commit c7a4edd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion prov/tcp/src/xnet_progress.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,15 @@ static int xnet_progress_hdr(struct xnet_ep *ep)
return -FI_EAGAIN;

ep->hdr_bswap(ep, &ep->cur_rx.hdr.base_hdr);
assert(ep->cur_rx.hdr.base_hdr.id == ep->rx_id++);

#ifndef NDEBUG
if (ep->cur_rx.hdr.base_hdr.id != ep->rx_id++) {
FI_WARN(&xnet_prov, FI_LOG_EP_DATA,
"Received invalid hdr sequence number\n");
return -FI_EIO;
}
#endif

if (ep->cur_rx.hdr.base_hdr.op >= ARRAY_SIZE(xnet_start_op)) {
FI_WARN(&xnet_prov, FI_LOG_EP_DATA,
"Received invalid opcode\n");
Expand Down

0 comments on commit c7a4edd

Please sign in to comment.