sock/posix: Fix sendmsg_idx rollover for zcopy

If the idx gets to UINT32_MAX we need to ensure it doesn't wrap around
before we check if we're done iterating.

Fixes #2892

Change-Id: I2c57ed2a6f6eda16e2d1faa63e587dca0b380a17
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17687
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
Ben Walker 2023-04-20 14:34:25 -07:00 committed by David Ko
parent 90656238b4
commit fe1ea7cebf

View File

@ -1178,7 +1178,8 @@ _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.is_zcopy) {
@ -1197,6 +1198,16 @@ _sock_check_zcopy(struct spdk_sock *sock)
break;
}
}
if (idx == serr->ee_data) {
break;
}
if (idx == UINT32_MAX) {
idx = 0;
} else {
idx++;
}
}
}