Skip to content

Commit

Permalink
sock/posix: Fix sendmsg_idx rollover for zcopy
Browse files Browse the repository at this point in the history
If the idx gets to UINT32_MAX we need to ensure it doesn't wrap around
before we check if we're done iterating.

This is a backport from 23.05.
Original commit e351b19.

Signed-off-by: Dmitry Savitskiy <[email protected]>
  • Loading branch information
dsavitskiy committed Nov 2, 2023
1 parent 11c1aa0 commit 18cb979
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions module/sock/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,21 +686,30 @@ _sock_check_zcopy(struct spdk_sock *sock)
* we encounter one match we can stop looping as soon as a
* non-match is found.
*/
for (idx = serr->ee_info; idx <= serr->ee_data; idx++) {
idx = serr->ee_info;
while (true) {
found = false;
TAILQ_FOREACH_SAFE(req, &sock->pending_reqs, internal.link, treq) {
if (req->internal.offset == idx) {
found = true;

rc = spdk_sock_request_put(sock, req, 0);
if (rc < 0) {
return rc;
}

} else if (found) {
break;
}
}

if (idx == serr->ee_data) {
break;
}

if (idx == UINT32_MAX) {
idx = 0;
} else {
idx++;
}
}
}

Expand Down

0 comments on commit 18cb979

Please sign in to comment.