From d98b5f89c8aa822e598dedddf6007bbb16aed4c6 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 29 Sep 2016 21:11:55 -0700 Subject: [PATCH] FIXUP smb_direct.c --- libcli/smb/smb_direct.c | 62 +++++++++++++++++++++++++++++++++++++++-- libcli/smb/smb_direct.h | 4 +++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/libcli/smb/smb_direct.c b/libcli/smb/smb_direct.c index 7adce4ece629..9c2f6ed995e3 100644 --- a/libcli/smb/smb_direct.c +++ b/libcli/smb/smb_direct.c @@ -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 */ diff --git a/libcli/smb/smb_direct.h b/libcli/smb/smb_direct.h index 6c290b6e2471..06b52aa23754 100644 --- a/libcli/smb/smb_direct.h +++ b/libcli/smb/smb_direct.h @@ -22,11 +22,15 @@ #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, -- 2.34.1