From 2508d170c899e80b2c0bf84c13bbc93785e9158d Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Wed, 17 Aug 2022 22:29:53 +0000 Subject: [PATCH] sock: make opts structures packed This ensures that when fields are added, that the size of the structure will change, ensuring different versions of the structure can be detected using sizeof. Signed-off-by: Jim Harris Change-Id: Ia30d57b25b559a89997963a3f68797ff3b9d6409 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14093 Reviewed-by: Ben Walker Reviewed-by: Tomasz Zawadzki Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot --- include/spdk/sock.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/spdk/sock.h b/include/spdk/sock.h index c0827496a..783bfba2d 100644 --- a/include/spdk/sock.h +++ b/include/spdk/sock.h @@ -175,11 +175,17 @@ struct spdk_sock_opts { */ bool zcopy; + /* Hole at bytes 13-15. */ + uint8_t reserved13[3]; + /** * Time in msec to wait ack until connection is closed forcefully. */ uint32_t ack_timeout; + /* Hole at bytes 20-23. */ + uint8_t reserved[4]; + /** * Socket implementation options. If non-NULL, these will override those set by * spdk_sock_impl_set_opts(). The library copies this structure internally, so the user can @@ -191,7 +197,7 @@ struct spdk_sock_opts { * Size of the impl_opts structure. */ size_t impl_opts_size; -}; +} __attribute__((packed)); SPDK_STATIC_ASSERT(sizeof(struct spdk_sock_opts) == 40, "Incorrect size"); /**