[SCM] Samba Shared Repository - branch master updated
Martin Schwenke
martins at samba.org
Tue Oct 10 13:51:02 UTC 2017
The branch, master has been updated
via 046427b ctdb-tests: Add interactive test for tunnels
via 79a44d1 ctdb-tests: Add test for tunnels
via 6fed8a7 ctdb-protocol: Add tunnel id prefix for testing
via ad1a917 ctdb-client: Add client api for using tunnels
via c700464 ctdb-protocol: Add protocol marshalling for CTDB_REQ_TUNNEL
via 24e4197 ctdb-client: Add client code for tunnel controls
via 4467c61 ctdb-protocol: Add protocol marshalling for tunnel controls
via 2cb5fda ctdb-daemon: Add code to process ctdb_req_tunnel packets
via f4f5e7d ctdb-protocol: Add req_tunnel counts to ctdb statistics
via 9c51535 ctdb-daemon: Add implementation of tunnel controls
via a41571a ctdb-protocol: Add controls to register/deregister tunnels
via c202b18 ctdb-protocol: Add REQ_TUNNEL packet type
from 76a1c5a wbinfo: return "NOT MAPPED" instead of "S-0-0" for unmapped id-to-sid
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 046427b0aba58dbecc64d356c32ff019691de363
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Aug 11 15:53:28 2017 +1000
ctdb-tests: Add interactive test for tunnels
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
Autobuild-User(master): Martin Schwenke <martins at samba.org>
Autobuild-Date(master): Tue Oct 10 15:50:04 CEST 2017 on sn-devel-144
commit 79a44d15bb293aca8726ffd3a8112775b8ab1c06
Author: Amitay Isaacs <amitay at gmail.com>
Date: Mon Jun 26 18:06:18 2017 +1000
ctdb-tests: Add test for tunnels
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 6fed8a731a9de7d045871a5da819e9979631c3b6
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Sep 29 12:16:21 2017 +1000
ctdb-protocol: Add tunnel id prefix for testing
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit ad1a9176d1ffa1be29cf090821acbdb23476c252
Author: Amitay Isaacs <amitay at gmail.com>
Date: Thu Apr 6 19:33:47 2017 +1000
ctdb-client: Add client api for using tunnels
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit c700464d2330f3cede96349c0cdcc55bbb88a5a0
Author: Amitay Isaacs <amitay at gmail.com>
Date: Wed Apr 5 16:25:42 2017 +1000
ctdb-protocol: Add protocol marshalling for CTDB_REQ_TUNNEL
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 24e4197195a4a23d1b901ce1d5d9ab5fca22696a
Author: Amitay Isaacs <amitay at gmail.com>
Date: Thu Apr 6 18:58:18 2017 +1000
ctdb-client: Add client code for tunnel controls
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 4467c6112a6954908b97dce994852f882c38ce56
Author: Amitay Isaacs <amitay at gmail.com>
Date: Thu Apr 6 18:58:01 2017 +1000
ctdb-protocol: Add protocol marshalling for tunnel controls
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 2cb5fdac42104c68566c9766cabf7d167091f64d
Author: Amitay Isaacs <amitay at gmail.com>
Date: Thu Apr 6 19:09:58 2017 +1000
ctdb-daemon: Add code to process ctdb_req_tunnel packets
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit f4f5e7d2ad4740cf0af70da3aa3b8bacfe4d3b6e
Author: Amitay Isaacs <amitay at gmail.com>
Date: Thu Apr 6 17:50:38 2017 +1000
ctdb-protocol: Add req_tunnel counts to ctdb statistics
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 9c51535775c9564d0f908ede6cefc2998fe7b2c4
Author: Amitay Isaacs <amitay at gmail.com>
Date: Thu Apr 6 19:03:51 2017 +1000
ctdb-daemon: Add implementation of tunnel controls
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit a41571a7dac87481ef022b50903b6061f1a4f788
Author: Amitay Isaacs <amitay at gmail.com>
Date: Thu Apr 6 18:31:10 2017 +1000
ctdb-protocol: Add controls to register/deregister tunnels
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit c202b188bf6e6b9a4b1eee034acce8981fbb88ff
Author: Amitay Isaacs <amitay at gmail.com>
Date: Wed Apr 5 16:07:10 2017 +1000
ctdb-protocol: Add REQ_TUNNEL packet type
This allows to tunnel new protocols using ctdb transport.
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
-----------------------------------------------------------------------
Summary of changes:
ctdb/client/client.h | 206 ++++++
ctdb/client/client_connect.c | 11 +
ctdb/client/client_control_sync.c | 58 ++
ctdb/client/client_private.h | 13 +
ctdb/client/client_sync.h | 10 +
ctdb/client/client_tunnel.c | 689 +++++++++++++++++++++
ctdb/doc/ctdb-statistics.7.xml | 14 +
ctdb/include/ctdb_private.h | 18 +
ctdb/include/ctdb_protocol.h | 8 +
ctdb/protocol/protocol.h | 17 +
ctdb/protocol/protocol_api.h | 22 +
ctdb/protocol/protocol_client.c | 42 ++
ctdb/protocol/protocol_control.c | 12 +
ctdb/protocol/protocol_debug.c | 53 ++
.../{protocol_keepalive.c => protocol_tunnel.c} | 53 +-
ctdb/protocol/protocol_types.c | 22 +
ctdb/server/ctdb_control.c | 6 +
ctdb/server/ctdb_daemon.c | 76 +++
ctdb/server/ctdb_server.c | 5 +
ctdb/server/ctdb_tunnel.c | 141 +++++
ctdb/tests/cunit/protocol_test_101.sh | 3 +-
.../simple/{52_fetch_ring.sh => 81_tunnel_ring.sh} | 19 +-
ctdb/tests/src/protocol_common_ctdb.c | 41 ++
ctdb/tests/src/protocol_common_ctdb.h | 4 +
ctdb/tests/src/protocol_ctdb_compat_test.c | 87 +++
ctdb/tests/src/protocol_ctdb_test.c | 5 +-
ctdb/tests/src/tunnel_cmd.c | 199 ++++++
ctdb/tests/src/tunnel_test.c | 477 ++++++++++++++
ctdb/tools/ctdb.c | 2 +
ctdb/wscript | 10 +-
30 files changed, 2292 insertions(+), 31 deletions(-)
create mode 100644 ctdb/client/client_tunnel.c
copy ctdb/protocol/{protocol_keepalive.c => protocol_tunnel.c} (57%)
create mode 100644 ctdb/server/ctdb_tunnel.c
copy ctdb/tests/simple/{52_fetch_ring.sh => 81_tunnel_ring.sh} (60%)
create mode 100644 ctdb/tests/src/tunnel_cmd.c
create mode 100644 ctdb/tests/src/tunnel_test.c
Changeset truncated at 500 lines:
diff --git a/ctdb/client/client.h b/ctdb/client/client.h
index 5e3b5c6..5be54b2 100644
--- a/ctdb/client/client.h
+++ b/ctdb/client/client.h
@@ -42,6 +42,11 @@
struct ctdb_client_context;
/**
+ * @brief The abstract context that holds a tunnel endpoint
+ */
+struct ctdb_tunnel_context;
+
+/**
* @brief The abstract context that represents a clustered database
*/
struct ctdb_db_context;
@@ -67,6 +72,17 @@ struct ctdb_transaction_handle;
typedef void (*ctdb_client_callback_func_t)(void *private_data);
/**
+ * @brief Tunnel callback function
+ *
+ * This function is registered when a tunnel endpoint is set up. When the
+ * tunnel endpoint receives a message, this function is invoked.
+ */
+typedef void (*ctdb_tunnel_callback_func_t)(struct ctdb_tunnel_context *tctx,
+ uint32_t srcnode, uint32_t reqid,
+ uint8_t *buf, size_t buflen,
+ void *private_data);
+
+/**
* @brief Initialize and connect to ctdb daemon
*
* This returns a ctdb client context. Freeing this context will free the
@@ -545,6 +561,196 @@ int ctdb_client_control_multi_error(uint32_t *pnn_list, int count,
int *err_list, uint32_t *pnn);
/**
+ * @brief Async computation start to setup a tunnel endpoint
+ *
+ * This computation sets up a tunnel endpoint corresponding to a tunnel_id.
+ * A tunnel is a ctdb transport to deliver new protocol between endpoints.
+ *
+ * For two endpoints to communicate using new protocol,
+ * 1. Set up tunnel endpoints
+ * 2. Send requests
+ * 3. Send replies
+ * 4. Destroy tunnel endpoints
+ *
+ * @param[in] mem_ctx Talloc memory context
+ * @param[in] ev Tevent context
+ * @param[in] client Client connection context
+ * @param[in] tunnel_id Unique tunnel id
+ * @param[in] callback Callback function to call when a message is received
+ * @param[in] private_data Private data for callback
+ * @return a new tevent req on success, NULL on failure
+ */
+struct tevent_req *ctdb_tunnel_setup_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct ctdb_client_context *client,
+ uint64_t tunnel_id,
+ ctdb_tunnel_callback_func_t callback,
+ void *private_data);
+
+/**
+ * @brief Async computation end to setup a tunnel
+ *
+ * @param[in] req Tevent request
+ * @param[in] perr errno in case of failure
+ * @param[out] result A new tunnel context
+ * @return true on success, false on failure
+ *
+ * Tunnel context should never be freed by user.
+ */
+bool ctdb_tunnel_setup_recv(struct tevent_req *req, int *perr,
+ struct ctdb_tunnel_context **result);
+
+/**
+ * @brief Sync wrapper for ctdb_tunnel_setup computation
+ *
+ * @param[in] mem_ctx Talloc memory context
+ * @param[in] ev Tevent context
+ * @param[in] client Client connection context
+ * @param[in] tunnel_id Unique tunnel id
+ * @param[in] callback Callback function to call when a message is received
+ * @param[in] private_data Private data for callback
+ * @param[out] result A new tunnel context
+ * @return 0 on success, errno on failure
+ */
+int ctdb_tunnel_setup(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct ctdb_client_context *client, uint64_t tunnel_id,
+ ctdb_tunnel_callback_func_t callback, void *private_data,
+ struct ctdb_tunnel_context **result);
+
+/**
+ * @brief Async computation start to destroy a tunnel endpoint
+ *
+ * This computation destroys the tunnel endpoint.
+ *
+ * @param[in] mem_ctx Talloc memory context
+ * @param[in] ev Tevent context
+ * @param[in] tctx Tunnel context
+ * @return a new tevent req on success, NULL on failure
+ */
+struct tevent_req *ctdb_tunnel_destroy_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct ctdb_tunnel_context *tctx);
+
+/**
+ * @brief Async computation end to destroy a tunnel endpoint
+ *
+ * @param[in] req Tevent request
+ * @param[out] perr errno in case of failure
+ * @return true on success, false on failure
+ */
+bool ctdb_tunnel_destroy_recv(struct tevent_req *req, int *perr);
+
+/**
+ * @brief Sync wrapper for ctdb_tunnel_destroy computation
+ *
+ * @param[in] ev Tevent context
+ * @param[in] tctx Tunnel context
+ * @return 0 on success, errno on failure
+ */
+int ctdb_tunnel_destroy(struct tevent_context *ev,
+ struct ctdb_tunnel_context *tctx);
+
+/**
+ * @brief Async computation start to send a request via a tunnel
+ *
+ * @param[in] mem_ctx Talloc memory context
+ * @param[in] ev Tevent context
+ * @param[in] tctx Tunnel context
+ * @param[in] destnode PNN of destination
+ * @param[in] timeout How long to wait
+ * @param[in] buf Message to send
+ * @param[in] buflen Size of the message to send
+ * @param[in] wait_for_reply Whether to wait for reply
+ * @return a new tevent req on success, NULL on failure
+ */
+struct tevent_req *ctdb_tunnel_request_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct ctdb_tunnel_context *tctx,
+ int destnode,
+ struct timeval timeout,
+ uint8_t *buf, size_t buflen,
+ bool wait_for_reply);
+
+/**
+ * @brief Async computation end to send a request via a tunnel
+ *
+ * @param[in] req Tevent request
+ * @param[out] perr errno in case of failure
+ * @param[in] mem_ctx Talloc context
+ * @param[out] buf Reply data if expected
+ * @param[out] buflen Size of reply data if expected
+ * @return true on success, false on failure
+ */
+bool ctdb_tunnel_request_recv(struct tevent_req *req, int *perr,
+ TALLOC_CTX *mem_ctx, uint8_t **buf,
+ size_t *buflen);
+
+/**
+ * @brief Sync wrapper for ctdb_tunnel_request computation
+ *
+ * @param[in] mem_ctx Talloc memory context
+ * @param[in] ev Tevent context
+ * @param[in] tctx Tunnel context
+ * @param[in] destnode PNN of destination
+ * @param[in] timeout How long to wait
+ * @param[in] buf Message to send
+ * @param[in] buflen Size of the message to send
+ * @param[in] wait_for_reply Whether to wait for reply
+ * @return 0 on success, errno on failure
+ */
+int ctdb_tunnel_request(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct ctdb_tunnel_context *tctx, int destnode,
+ struct timeval timeout, uint8_t *buf, size_t buflen,
+ bool wait_for_reply);
+
+/**
+ * @brief Async computation start to send a reply via a tunnel
+ *
+ * @param[in] mem_ctx Talloc memory context
+ * @param[in] ev Tevent context
+ * @param[in] tctx Tunnel context
+ * @param[in] destnode PNN of destination
+ * @param[in] reqid Request id
+ * @param[in] timeout How long to wait
+ * @param[in] buf Reply data
+ * @param[in] buflen Size of reply data
+ * @return a new tevent req on success, NULL on failure
+ */
+struct tevent_req *ctdb_tunnel_reply_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct ctdb_tunnel_context *tctx,
+ int destnode, uint32_t reqid,
+ struct timeval timeout,
+ uint8_t *buf, size_t buflen);
+
+/**
+ * @brief Async computation end to send a reply via a tunnel
+ *
+ * @param[in] req Tevent request
+ * @param[out] perr errno in case of failure
+ * @return true on success, false on failure
+ */
+bool ctdb_tunnel_reply_recv(struct tevent_req *req, int *perr);
+
+/**
+ * @brief Sync wrapper for ctdb_tunnel_reply computation
+ *
+ * @param[in] mem_ctx Talloc memory context
+ * @param[in] ev Tevent context
+ * @param[in] tctx Tunnel context
+ * @param[in] destnode PNN of destination
+ * @param[in] reqid Request id
+ * @param[in] timeout How long to wait
+ * @param[in] buf Reply data
+ * @param[in] buflen Size of reply data
+ * @return 0 on success, errno on failure
+ */
+int ctdb_tunnel_reply(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct ctdb_tunnel_context *tctx, int destnode,
+ uint32_t reqid, struct timeval timeout,
+ uint8_t *buf, size_t buflen);
+
+/**
* @brief Async computation start to attach a database
*
* @param[in] mem_ctx Talloc memory context
diff --git a/ctdb/client/client_connect.c b/ctdb/client/client_connect.c
index 6fd2c87..ed4371f 100644
--- a/ctdb/client/client_connect.c
+++ b/ctdb/client/client_connect.c
@@ -72,6 +72,13 @@ int ctdb_client_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
return ret;
}
+ ret = srvid_init(client, &client->tunnels);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, ("srvid_init() failed, ret=%d\n", ret));
+ talloc_free(client);
+ return ret;
+ }
+
client->fd = -1;
client->pnn = CTDB_UNKNOWN_PNN;
@@ -199,6 +206,10 @@ static void client_read_handler(uint8_t *buf, size_t buflen,
ctdb_client_reply_control(client, buf, buflen, hdr.reqid);
break;
+ case CTDB_REQ_TUNNEL:
+ ctdb_client_req_tunnel(client, buf, buflen, hdr.reqid);
+ break;
+
default:
break;
}
diff --git a/ctdb/client/client_control_sync.c b/ctdb/client/client_control_sync.c
index 7ee9f1d..e4e14b7 100644
--- a/ctdb/client/client_control_sync.c
+++ b/ctdb/client/client_control_sync.c
@@ -2660,3 +2660,61 @@ int ctdb_ctrl_check_pid_srvid(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
return 0;
}
+
+int ctdb_ctrl_tunnel_register(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct ctdb_client_context *client,
+ int destnode, struct timeval timeout,
+ uint64_t tunnel_id)
+{
+ struct ctdb_req_control request;
+ struct ctdb_reply_control *reply;
+ int ret;
+
+ ctdb_req_control_tunnel_register(&request, tunnel_id);
+ ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
+ &request, &reply);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,
+ ("Control TUNNEL_REGISTER failed to node %u, ret=%d\n",
+ destnode, ret));
+ return ret;
+ }
+
+ ret = ctdb_reply_control_tunnel_register(reply);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,
+ ("Control TUNNEL_REGISTER failed, ret=%d\n", ret));
+ return ret;
+ }
+
+ return 0;
+}
+
+int ctdb_ctrl_tunnel_deregister(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct ctdb_client_context *client,
+ int destnode, struct timeval timeout,
+ uint64_t tunnel_id)
+{
+ struct ctdb_req_control request;
+ struct ctdb_reply_control *reply;
+ int ret;
+
+ ctdb_req_control_tunnel_deregister(&request, tunnel_id);
+ ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
+ &request, &reply);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,
+ ("Control TUNNEL_DEREGISTER failed to node %u, ret=%d\n",
+ destnode, ret));
+ return ret;
+ }
+
+ ret = ctdb_reply_control_tunnel_deregister(reply);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,
+ ("Control TUNNEL_DEREGISTER failed, ret=%d\n", ret));
+ return ret;
+ }
+
+ return 0;
+}
diff --git a/ctdb/client/client_private.h b/ctdb/client/client_private.h
index 5af019b..bb17055 100644
--- a/ctdb/client/client_private.h
+++ b/ctdb/client/client_private.h
@@ -35,6 +35,7 @@ struct ctdb_db_context {
struct ctdb_client_context {
struct reqid_context *idr;
struct srvid_context *srv;
+ struct srvid_context *tunnels;
struct comm_context *comm;
ctdb_client_callback_func_t callback;
void *private_data;
@@ -64,6 +65,13 @@ struct ctdb_transaction_handle {
bool updated;
};
+struct ctdb_tunnel_context {
+ struct ctdb_client_context *client;
+ uint64_t tunnel_id;
+ ctdb_tunnel_callback_func_t callback;
+ void *private_data;
+};
+
/* From client_call.c */
void ctdb_client_reply_call(struct ctdb_client_context *client,
@@ -79,4 +87,9 @@ void ctdb_client_req_message(struct ctdb_client_context *client,
void ctdb_client_reply_control(struct ctdb_client_context *client,
uint8_t *buf, size_t buflen, uint32_t reqid);
+/* From client_tunnel.c */
+
+void ctdb_client_req_tunnel(struct ctdb_client_context *client,
+ uint8_t *buf, size_t buflen, uint32_t reqid);
+
#endif /* __CTDB_CLIENT_PRIVATE_H__ */
diff --git a/ctdb/client/client_sync.h b/ctdb/client/client_sync.h
index c07edf6..b29e669 100644
--- a/ctdb/client/client_sync.h
+++ b/ctdb/client/client_sync.h
@@ -481,6 +481,16 @@ int ctdb_ctrl_check_pid_srvid(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
int destnode, struct timeval timeout,
struct ctdb_pid_srvid *pid_srvid, int *status);
+int ctdb_ctrl_tunnel_register(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct ctdb_client_context *client,
+ int destnode, struct timeval timeout,
+ uint64_t tunnel_id);
+
+int ctdb_ctrl_tunnel_deregister(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct ctdb_client_context *client,
+ int destnode, struct timeval timeout,
+ uint64_t tunnel_id);
+
/* from client/client_message_sync.c */
int ctdb_message_recd_update_ip(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
diff --git a/ctdb/client/client_tunnel.c b/ctdb/client/client_tunnel.c
new file mode 100644
index 0000000..11715b4
--- /dev/null
+++ b/ctdb/client/client_tunnel.c
@@ -0,0 +1,689 @@
+/*
+ CTDB client code
+
+ Copyright (C) Amitay Isaacs 2016
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "system/network.h"
+
+#include <talloc.h>
+#include <tevent.h>
+#include <tdb.h>
+
+#include "lib/util/tevent_unix.h"
+
+#include "common/reqid.h"
+#include "common/srvid.h"
+#include "common/comm.h"
+
+#include "protocol/protocol.h"
+#include "protocol/protocol_api.h"
+
+#include "client/client_private.h"
+#include "client/client.h"
+
+
+struct ctdb_tunnel_data {
+ struct ctdb_req_header hdr;
+ struct ctdb_req_tunnel *tunnel;
+ uint32_t reqid;
+};
+
+/*
+ * Tunnel setup and destroy
+ */
+
+struct ctdb_tunnel_setup_state {
+ struct ctdb_client_context *client;
+ struct ctdb_tunnel_context *tctx;
+ uint64_t tunnel_id;
+};
+
+static void ctdb_tunnel_setup_register_done(struct tevent_req *subreq);
+static void ctdb_tunnel_handler(uint64_t tunnel_id, TDB_DATA data,
+ void *private_data);
+
+struct tevent_req *ctdb_tunnel_setup_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct ctdb_client_context *client,
+ uint64_t tunnel_id,
+ ctdb_tunnel_callback_func_t callback,
+ void *private_data)
+{
+ struct tevent_req *req, *subreq;
+ struct ctdb_tunnel_setup_state *state;
+ struct ctdb_tunnel_context *tctx;
+ struct ctdb_req_control request;
+ int ret;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct ctdb_tunnel_setup_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ tctx = talloc_zero(client, struct ctdb_tunnel_context);
+ if (tevent_req_nomem(tctx, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ tctx->client = client;
+ tctx->tunnel_id = tunnel_id;
+ tctx->callback = callback;
+ tctx->private_data = private_data;
+
+ state->client = client;
+ state->tunnel_id = tunnel_id;
+ state->tctx = tctx;
+
+ ret = srvid_exists(client->tunnels, tunnel_id, NULL);
+ if (ret == 0) {
+ tevent_req_error(req, EEXIST);
+ return tevent_req_post(req, ev);
+ }
+
+ ctdb_req_control_tunnel_register(&request, tunnel_id);
+ subreq = ctdb_client_control_send(state, ev, client,
+ ctdb_client_pnn(client),
+ tevent_timeval_zero(),
+ &request);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, ctdb_tunnel_setup_register_done, req);
+
+ return req;
+}
+
--
Samba Shared Repository
More information about the samba-cvs
mailing list