]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs_proxy: replace legacy handshake by negotation in server side
authorXavi Hernandez <xhernandez@gmail.com>
Tue, 11 Feb 2025 17:06:48 +0000 (18:06 +0100)
committerXavi Hernandez <xhernandez@gmail.com>
Fri, 14 Feb 2025 15:15:00 +0000 (16:15 +0100)
Make server code to actually use the new negotiation functions during
connection establishment.

Signed-off-by: Xavi Hernandez <xhernandez@gmail.com>
src/libcephfs_proxy/libcephfsd.c
src/libcephfs_proxy/proxy_requests.h

index ee2d99a0aae865eac85aa9274e24aacfc06cfb02..5c1fc4a44b1112433bbd66f532be6d52b337ba8e 100644 (file)
@@ -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);
index 4e3739276bb27db47696c3a90a1445b95336cb8f..f1f72f5b15a51fb5b67e075fed33fce0d572145e 100644 (file)
@@ -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;));