Commit e351b190 authored by Ben Walker's avatar Ben Walker Committed by Konrad Sztyber
Browse files

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: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17687


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 1922700e
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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++;
			}
		}
	}