FIXUP smb_direct.c
authorRalph Boehme <slow@samba.org>
Fri, 30 Sep 2016 04:11:55 +0000 (21:11 -0700)
committerStefan Metzmacher <metze@samba.org>
Fri, 1 Jun 2018 12:35:08 +0000 (14:35 +0200)
libcli/smb/smb_direct.c
libcli/smb/smb_direct.h

index 7adce4ece62989731264d42315d395a3c00106eb..9c2f6ed995e3851410ff87167c03b6ab663de071 100644 (file)
@@ -276,7 +276,7 @@ DEBUG(0,("%s:%s: here...\n", __location__, __func__));
        return c;
 }
 
-static struct smb_direct_connection *smb_direct_connection_complete_alloc(struct smb_direct_connection *c)
+struct smb_direct_connection *smb_direct_connection_complete_alloc(struct smb_direct_connection *c)
 {
        int ret;
        uint16_t i;
@@ -710,7 +710,7 @@ static struct tevent_req *smb_direct_connection_rdma_connect_send(TALLOC_CTX *me
        }
        state->c = c;
 
-DEBUG(0,("%s:%s: here...\n", __location__, __func__));
+       DEBUG(0,("%s:%s: here...\n", __location__, __func__));
        talloc_set_destructor(state, smb_direct_connection_rdma_connect_state_destructor);
 
        c->rdma.fde_channel = tevent_add_fd(ev, c,
@@ -2238,4 +2238,62 @@ DEBUG(0,("%s:%s: here...\n", __location__, __func__));
        return NT_STATUS_OK;
 }
 
+struct smb_direct_connection *smb_direct_connection_listener(
+       TALLOC_CTX *mem_ctx,
+       struct rdma_cm_id *cm_id)
+{
+       struct smb_direct_connection *c;
+       int sfd[2];
+       int ret;
+       //uint16_t i;
+
+       c = talloc_zero(mem_ctx, struct smb_direct_connection);
+       if (c == NULL) {
+               return NULL;
+       }
+       c->sock.fd = -1;
+       c->sock.tmp_fd = -1;
+//DEBUG(0,("%s:%s: here...\n", __location__, __func__));
+       talloc_set_destructor(c, smb_direct_connection_destructor);
+
+       c->state.max_send_size       = 1364;
+       c->state.max_receive_size    = SMB_DIRECT_IO_MAX_DATA;
+       c->state.max_fragmented_size = 1048576;
+       c->state.max_read_write_size = 0;
+       c->state.receive_credit_max  = 10;//255;
+       c->state.send_credit_target  = 255;
+       c->state.keep_alive_internal = 5;
+
+       ret = socketpair(AF_UNIX, SOCK_STREAM, 0, sfd);
+       if (ret == -1) {
+               int saved_errno = errno;
+               TALLOC_FREE(c);
+DEBUG(0,("%s:%s: here...\n", __location__, __func__));
+               errno = saved_errno;
+               return NULL;
+       }
+       c->sock.tmp_fd = sfd[0];
+       c->sock.fd = sfd[1];
+
+DEBUG(0,("%s:%s: sock.fd[%d] sock.tmp_fd[%d]\n",
+       __location__, __func__, c->sock.fd, c->sock.tmp_fd));
+
+       smb_set_close_on_exec(c->sock.tmp_fd);
+       smb_set_close_on_exec(c->sock.fd);
+       set_blocking(c->sock.fd, false);
+
+       c->rdma.cm_channel = rdma_create_event_channel();
+       if (c->rdma.cm_channel == NULL) {
+               TALLOC_FREE(c);
+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);
+
+       c->rdma.cm_id = cm_id;
+
+       return c;
+}
+
 #endif /* SMB_TRANSPORT_ENABLE_RDMA */
index 6c290b6e24714a738278f4bcf29f47f4955e7ad8..06b52aa237541b55f4cb3b66e564734c7eb1c22c 100644 (file)
 #define _LIBCLI_SMB_SMB_DIRECT_H_
 
 struct smb_direct_connection;
+struct rdma_cm_id;
 
 //Hack...
 extern struct smb_direct_connection *smb_direct_conn;
 
 struct smb_direct_connection *smb_direct_connection_create(TALLOC_CTX *mem_ctx);
+struct smb_direct_connection *smb_direct_connection_listener(TALLOC_CTX *mem_ctx,
+                                                            struct rdma_cm_id *cm_id);
+struct smb_direct_connection *smb_direct_connection_complete_alloc(struct smb_direct_connection *c);
 
 struct tevent_req *smb_direct_connection_connect_send(TALLOC_CTX *mem_ctx,
                                                      struct tevent_context *ev,