more
authorStefan Metzmacher <metze@samba.org>
Fri, 30 Sep 2016 13:53:41 +0000 (15:53 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 1 Jun 2018 12:35:12 +0000 (14:35 +0200)
libcli/smb/smb_direct.c
libcli/smb/smb_direct_daemon.c
libcli/smb/smb_direct_util.c

index 0111e4e9ec1432ed7e6b2d8acd634fcf24abb49f..42dc436572dd9fdb87f1f955f4e337012be1572a 100644 (file)
@@ -34,7 +34,7 @@
 #include <rdma/rdma_cma.h>
 #include <infiniband/verbs.h>
 
-#define SMB_DIRECT_LISTENER_BACKLOG 100
+#define SMB_DIRECT_LISTENER_BACKLOG 5
 
 //#define SMB_DIRECT_IO_MAX_DATA 8192
 #define SMB_DIRECT_IO_MAX_DATA 1364
@@ -48,7 +48,6 @@ struct smb_direct_connection;
 struct smb_direct_io;
 
 struct smb_direct_listener {
-       struct tevent_context *ev;
        struct {
                struct smb_direct_rdma_context context;
                struct rdma_cm_id *cm_id;
@@ -222,6 +221,7 @@ static int smb_direct_io_destructor(struct smb_direct_io *io)
 
 static int smb_direct_connection_destructor(struct smb_direct_connection *c);
 
+#if 0
 #undef DEBUG
 #define DEBUG( _level, body ) do {\
        int level = 5; \
@@ -230,7 +230,7 @@ static int smb_direct_connection_destructor(struct smb_direct_connection *c);
        && (dbghdrclass( level, DBGC_CLASS, __location__, __FUNCTION__ )) \
        && (dbgtext body) ); \
 } while(0)
-
+#endif
 struct smb_direct_connection *smb_direct_connection_create(TALLOC_CTX *mem_ctx)
 {
        struct smb_direct_connection *c;
@@ -281,7 +281,7 @@ DEBUG(0,("%s:%s: here...\n", __location__, __func__));
                return NULL;
        }
        smb_set_close_on_exec(c->rdma.cm_channel->fd);
-       set_blocking(c->rdma.cm_channel->fd, false);
+       //set_blocking(c->rdma.cm_channel->fd, false);
 
        c->rdma.context.c = c;
 
@@ -307,7 +307,7 @@ DEBUG(0,("%s:%s: here...\n", __location__, __func__));
                return NT_STATUS_NO_MEMORY;
        }
        smb_set_close_on_exec(c->ibv.comp_channel->fd);
-       set_blocking(c->ibv.comp_channel->fd, false);
+       //set_blocking(c->ibv.comp_channel->fd, false);
 
 //DEBUG(0,("%s:%s: here...\n", __location__, __func__));
        c->ibv.pd = ibv_alloc_pd(c->rdma.cm_id->verbs);
@@ -2234,7 +2234,7 @@ DEBUG(0,("%s:%s: here...\n", __location__, __func__));
                return NT_STATUS_NO_MEMORY;
        }
        smb_set_close_on_exec(l->rdma.cm_channel->fd);
-       set_blocking(l->rdma.cm_channel->fd, false);
+       //set_blocking(l->rdma.cm_channel->fd, false);
 
        l->rdma.context.l = l;
 #if RDMA_USER_CM_MAX_ABI_VERSION >= 2
@@ -2248,6 +2248,7 @@ DEBUG(0,("%s:%s: here...\n", __location__, __func__));
                             &l->rdma.cm_id,
                             &l->rdma.context);
 #endif
+       //ret = rdma_create_ep(l->rdma.cm_channel, &l->rdma.cm_id, &l->rdma.context)
        if (ret != 0) {
                NTSTATUS status;
                status = map_nt_error_from_unix_common(errno);
@@ -2425,7 +2426,7 @@ static void smb_direct_listener_accept_rdma_handler(struct tevent_context *ev,
                RSIVAL(ird_ord_hdr, 0, 0);
                RSIVAL(ird_ord_hdr, 4, 16);
 
-               DBG_DEBUG("RDMA_CM_EVENT_CONNECT_REQUEST\n");
+               DBG_ERR("RDMA_CM_EVENT_CONNECT_REQUEST\n");
 
                conn_param = l->rdma.cm_event->param.conn;
 //             ZERO_STRUCT(conn_param);
@@ -2446,7 +2447,18 @@ static void smb_direct_listener_accept_rdma_handler(struct tevent_context *ev,
 
                c->rdma.cm_id = l->rdma.cm_event->id;
                c->rdma.cm_id->context = &c->rdma.context;
-               c->rdma.cm_id->channel = c->rdma.cm_channel;
+               //c->rdma.cm_id->channel = c->rdma.cm_channel;
+               ret = rdma_migrate_id(c->rdma.cm_id, c->rdma.cm_channel);
+               if (ret != 0) {
+                       DBG_ERR("rdma_migrate_id failed [%s] result [%d]\n", strerror(errno), ret);
+                       c->rdma.cm_id->context = NULL;
+                       c->rdma.cm_id = NULL;
+                       TALLOC_FREE(c);
+
+                       rdma_reject(l->rdma.cm_event->id, NULL, 0);
+                       /* wait for more */
+                       break;
+               }
 
                status = smb_direct_connection_complete_alloc(c);
                if (!NT_STATUS_IS_OK(status)) {
@@ -2478,8 +2490,9 @@ static void smb_direct_listener_accept_rdma_handler(struct tevent_context *ev,
 
                c->l = l;
                DLIST_ADD_END(l->ready, c);
+DEBUG(0,("%s:%s: here...\n", __location__, __func__));
 
-               tevent_req_defer_callback(req, l->ev);
+               tevent_req_defer_callback(req, state->ev);
                tevent_req_done(req);
                }
                break;
@@ -2517,6 +2530,7 @@ NTSTATUS smb_direct_listener_accept_recv(struct tevent_req *req,
        struct smb_direct_connection *c = NULL;
        NTSTATUS status;
 
+DEBUG(0,("%s:%s: here...\n", __location__, __func__));
        *_c = NULL;
        *fd = -1;
        if (laddr != NULL) {
@@ -2528,6 +2542,7 @@ NTSTATUS smb_direct_listener_accept_recv(struct tevent_req *req,
 
        if (tevent_req_is_nterror(req, &status)) {
                tevent_req_received(req);
+DEBUG(0,("%s:%s: here...\n", __location__, __func__));
                return status;
        }
 
@@ -2537,6 +2552,7 @@ NTSTATUS smb_direct_listener_accept_recv(struct tevent_req *req,
         * in order to consume more connections
         */
        if (l->ready == NULL) {
+DEBUG(0,("%s:%s: here...\n", __location__, __func__));
                return NT_STATUS_NO_MORE_ENTRIES;
        }
 
@@ -2552,6 +2568,7 @@ NTSTATUS smb_direct_listener_accept_recv(struct tevent_req *req,
        if (raddr != NULL) {
                ZERO_STRUCTP(raddr);
        }
+DEBUG(0,("%s:%s: here...\n", __location__, __func__));
        *_c = talloc_move(mem_ctx, &c);
        return NT_STATUS_OK;
 
index 5f6b9827951ea46cc738153fcf5f01a060fb05fe..f123e9108225b6a727ef3435b17ef10e07b31a15 100644 (file)
@@ -560,7 +560,7 @@ static NTSTATUS smbd_direct_daemon_listen(
        // process. If the other end closes we need to free the
        // listener.
 
-       subreq = smb_direct_listener_accept_send(l, daemon_state->ev, l);
+       subreq = smb_direct_listener_accept_send(conn, daemon_state->ev, l);
        if (subreq == NULL) {
                TALLOC_FREE(l);
                status = NT_STATUS_NO_MEMORY;
index 3fda2dcdb929d54f55a34ae6b5e3a77c2bac7a96..3db7be88a1e38dabd96f15132dbfaa8b52ff2d1b 100644 (file)
@@ -43,7 +43,7 @@ static char *smb_direct_common_path(TALLOC_CTX *mem_ctx, const char *name)
                return NULL;
        }
 
-       ok = directory_create_or_exist_strict(smb_direct_ctl_path, 0, 0755);
+       ok = directory_create_or_exist_strict(smb_direct_ctl_path, geteuid(), 0755);
        if (!ok) {
                DBG_ERR("Could not create smb_direct_ctl directory: "
                        "path [%s] error [%s]\n",