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: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ie0512a7dffc36c8ff89256d08f8a2f4fefcf9e83
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4699
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Tomasz Zawadzki 2020-10-15 07:07:41 -04:00
parent f285205333
commit 34f84c5845
2 changed files with 2 additions and 0 deletions

View File

@ -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

View File

@ -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