Commit 34f84c58 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

lib/sock: zero out sock_impl opts



By design the opts for each implementation
can not match spdk_sock_impl_opts.
During get_opts for specific implementation
only used fields are filled.

Yet iterating over all spdk_sock_impl_opts fields
would yeild garbage values for unset fields.

This is the case right now when doing save_config RPC
with uring enabled. A garbe value for enable_zerocopy_send
is returned.

sock.c:829:62: runtime error: load of value 165, which is not a valid value for type '_Bool'

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ie0512a7dffc36c8ff89256d08f8a2f4fefcf9e83
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4699


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent f2852053
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1344,6 +1344,7 @@ posix_sock_impl_get_opts(struct spdk_sock_impl_opts *opts, size_t *len)
		errno = EINVAL;
		return -1;
	}
	memset(opts, 0, *len);

#define FIELD_OK(field) \
	offsetof(struct spdk_sock_impl_opts, field) + sizeof(opts->field) <= *len
+1 −0
Original line number Diff line number Diff line
@@ -1317,6 +1317,7 @@ uring_sock_impl_get_opts(struct spdk_sock_impl_opts *opts, size_t *len)
		errno = EINVAL;
		return -1;
	}
	memset(opts, 0, *len);

#define FIELD_OK(field) \
	offsetof(struct spdk_sock_impl_opts, field) + sizeof(opts->field) <= *len