From: Xavi Hernandez Date: Tue, 11 Feb 2025 15:23:08 +0000 (+0100) Subject: libcephfs_proxy: add negotiation structures X-Git-Tag: v20.3.0~362^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f893605c16a2993a7614cd9e2521491c3071ea15;p=ceph.git libcephfs_proxy: add negotiation structures Signed-off-by: Xavi Hernandez --- diff --git a/src/libcephfs_proxy/proxy.h b/src/libcephfs_proxy/proxy.h index cfb69072f199..239cd5d1cb54 100644 --- a/src/libcephfs_proxy/proxy.h +++ b/src/libcephfs_proxy/proxy.h @@ -45,6 +45,9 @@ typedef struct _proxy_manager proxy_manager_t; struct _proxy_link; typedef struct _proxy_link proxy_link_t; +struct _proxy_link_negotiate; +typedef struct _proxy_link_negotiate proxy_link_negotiate_t; + typedef int32_t (*proxy_output_write_t)(proxy_output_t *); typedef int32_t (*proxy_output_full_t)(proxy_output_t *); diff --git a/src/libcephfs_proxy/proxy_link.h b/src/libcephfs_proxy/proxy_link.h index ae24b2ff9312..09fa3be67346 100644 --- a/src/libcephfs_proxy/proxy_link.h +++ b/src/libcephfs_proxy/proxy_link.h @@ -9,6 +9,46 @@ #define PROXY_LINK_DISCONNECTED { NULL, -1 } +/* To define newer versions of the negotiate structure, look for comments + * starting with "NEG_VERSION" and do the appropriate changes in each place. */ + +/* NEG_VERSION: Update this value to the latest implemented version. */ +#define PROXY_LINK_NEGOTIATE_VERSION 1 + +/* Version 0 structure will be used to handle legacy clients that don't support + * negotiation. */ +typedef struct _proxy_link_negotiate_v0 { + /* Size of the entire structure. Don't use sizeof() to compute it, use + * NEG_VERSION_SIZE() to avoid alignement issues. */ + uint16_t size; + + /* Version of the negotiation structure. */ + uint16_t version; + + /* Minimum version that the peer needs to support to proceed. */ + uint16_t min_version; + + /* Reserved. Must be 0. */ + uint16_t flags; +} proxy_link_negotiate_v0_t; + +typedef struct _proxy_link_negotiate_v1 { + uint32_t supported; + uint32_t required; + uint32_t enabled; +} proxy_link_negotiate_v1_t; + +/* NEG_VERSION: Add typedefs for new negotiate extensions above this comment. */ + +struct _proxy_link_negotiate { + proxy_link_negotiate_v0_t v0; + proxy_link_negotiate_v1_t v1; + + /* NEG_VERSION: Add newly defined typedefs above this comment. */ +}; + +typedef int32_t (*proxy_link_negotiate_cbk_t)(proxy_link_negotiate_t *); + struct _proxy_link { proxy_link_stop_t stop; int32_t sd; @@ -27,6 +67,11 @@ typedef struct _proxy_link_ans { uint32_t data_len; } proxy_link_ans_t; +#define NEG_VERSION_SIZE_1(_ver) \ + (offset_of(proxy_link_negotiate_t, v##_ver) + \ + sizeof(proxy_link_negotiate_v##_ver##_t)) +#define NEG_VERSION_SIZE(_ver) NEG_VERSION_SIZE_1(_ver) + static inline bool proxy_link_is_connected(proxy_link_t *link) { return link->sd >= 0;