From: Xavi Hernandez Date: Tue, 11 Feb 2025 17:06:48 +0000 (+0100) Subject: libcephfs_proxy: replace legacy handshake by negotation in server side X-Git-Tag: v20.3.0~362^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2d85a3537d13abcd8704352f123517bec17fd5d4;p=ceph.git libcephfs_proxy: replace legacy handshake by negotation in server side Make server code to actually use the new negotiation functions during connection establishment. Signed-off-by: Xavi Hernandez --- diff --git a/src/libcephfs_proxy/libcephfsd.c b/src/libcephfs_proxy/libcephfsd.c index ee2d99a0aae8..5c1fc4a44b11 100644 --- a/src/libcephfs_proxy/libcephfsd.c +++ b/src/libcephfs_proxy/libcephfsd.c @@ -21,6 +21,7 @@ typedef struct _proxy_server { typedef struct _proxy_client { proxy_worker_t worker; + proxy_link_negotiate_t neg; proxy_link_t *link; proxy_random_t random; void *buffer; @@ -1605,7 +1606,6 @@ static proxy_handler_t libcephfsd_handlers[LIBCEPHFSD_OP_TOTAL_OPS] = { static void serve_binary(proxy_client_t *client) { proxy_req_t req; - CEPH_DATA(hello, ans, 0); struct iovec req_iov[2]; void *buffer; uint32_t size; @@ -1620,14 +1620,6 @@ static void serve_binary(proxy_client_t *client) return; } - ans.major = LIBCEPHFSD_MAJOR; - ans.minor = LIBCEPHFSD_MINOR; - err = proxy_link_send(client->sd, ans_iov, ans_count); - if (err < 0) { - proxy_free(buffer); - return; - } - while (true) { req_iov[0].iov_base = &req; req_iov[0].iov_len = sizeof(req); @@ -1660,22 +1652,27 @@ static void serve_binary(proxy_client_t *client) proxy_free(buffer); } +static int32_t server_negotiation_check(proxy_link_negotiate_t *neg) +{ + proxy_log(LOG_INFO, 0, "Features enabled: %08x", neg->v1.enabled); + + return 0; +} + static void serve_connection(proxy_worker_t *worker) { - CEPH_DATA(hello, req, 0); proxy_client_t *client; int32_t err; client = container_of(worker, proxy_client_t, worker); - err = proxy_link_recv(client->sd, req_iov, req_count); + proxy_link_negotiate_init(&client->neg, 0, PROXY_FEAT_ALL, 0, 0); + + err = proxy_link_handshake_server(client->link, client->sd, + &client->neg, + server_negotiation_check); if (err >= 0) { - if (req.id == LIBCEPHFS_LIB_CLIENT) { - serve_binary(client); - } else { - proxy_log(LOG_ERR, EINVAL, - "Invalid client initial message"); - } + serve_binary(client); } close(client->sd); diff --git a/src/libcephfs_proxy/proxy_requests.h b/src/libcephfs_proxy/proxy_requests.h index 4e3739276bb2..f1f72f5b15a5 100644 --- a/src/libcephfs_proxy/proxy_requests.h +++ b/src/libcephfs_proxy/proxy_requests.h @@ -135,8 +135,6 @@ enum { /* Declaration of types used to transder requests and answers. */ -CEPH_TYPE(hello, FIELDS(uint32_t id;), FIELDS(int16_t major; int16_t minor;)); - CEPH_TYPE(ceph_version, REQ(), ANS(int32_t major; int32_t minor; int32_t patch; int16_t text;));