[SCM] Samba Shared Repository - branch v4-11-test updated

Karolin Seeger kseeger at samba.org
Wed Aug 28 10:49:02 UTC 2019


The branch, v4-11-test has been updated
       via  aa3ad5c451f WHATSNEW: BIND9_FLATFILE / rndc command deprecated
       via  d61fac0cbe4 docs: Deprecate "rndc command" for Samba 4.11
       via  a9d0e0b7bae ctdb-daemon: Make node inactive in the NODE_STOP control
       via  f454db8d960 ctdb-daemon: Drop unused function ctdb_local_node_got_banned()
       via  a93c591a11a ctdb-daemon: Switch banning code to use ctdb_node_become_inactive()
       via  09397389958 ctdb-daemon: Factor out new function ctdb_node_become_inactive()
       via  240ad91944d ctdb-tcp: Mark node as disconnected if incoming connection goes away
       via  adb19f17cd1 ctdb-tcp: Only mark a node connected if both directions are up
       via  6668733c306 ctdb-tcp: Create outbound queue when the connection becomes writable
       via  1ef2ffbab86 ctdb-tcp: Use TALLOC_FREE()
       via  bf39d0cff16 ctdb-tcp: Move incoming fd and queue into struct ctdb_tcp_node
       via  4cf26ff2ec3 ctdb-tcp: Rename fd -> out_fd
       via  0b4a99c22f5 ctdb-daemon: Add function ctdb_ip_to_node()
       via  53b0fd2216d vfs:glusterfs_fuse: build only if we have setmntent()
       via  d8ba147db50 vfs:glusterfs_fuse: ensure fileids are constant across nodes
      from  c6d784debd8 vfs_glusterfs: Enable profiling for file system operations

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-11-test


- Log -----------------------------------------------------------------
commit aa3ad5c451f38659c1131b20756ad81a903654cb
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 23 21:13:22 2019 +1200

    WHATSNEW: BIND9_FLATFILE / rndc command deprecated
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(v4-11-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-11-test): Wed Aug 28 10:48:10 UTC 2019 on sn-devel-184

commit d61fac0cbe4abe1f90da6aea695690ccdb757765
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Aug 17 06:59:33 2019 +1200

    docs: Deprecate "rndc command" for Samba 4.11
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14092
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 561e0986ac96c842239b4e8c6509e05c836707b7)

commit a9d0e0b7bae9005d56222e5952f9fec66cb8f491
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 19 21:48:04 2019 +1000

    ctdb-daemon: Make node inactive in the NODE_STOP control
    
    Currently some of this is supported by a periodic check in the
    recovery daemon's main_loop(), which notices the flag change, sets
    recovery mode active and freezes databases.  If STOP_NODE returns
    immediately then the associated recovery can complete and the node can
    be continued before databases are actually frozen.
    
    Instead, immediately do all of the things that make a node inactive.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14087
    RN: Stop "ctdb stop" from completing before freezing databases
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Tue Aug 20 08:32:27 UTC 2019 on sn-devel-184
    
    (cherry picked from commit e9f2e205ee89f4f3d6302cc11b4d0eb2efaf0f53)

commit f454db8d960bce78e492cdec344257a2ee094514
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Aug 20 11:29:42 2019 +1000

    ctdb-daemon: Drop unused function ctdb_local_node_got_banned()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14087
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 91ac4c13d8472955d1f04bd775ec4b3ff8bf1b61)

commit a93c591a11a9b19f4f5df87c76e3b2f3f7404339
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 19 21:52:57 2019 +1000

    ctdb-daemon: Switch banning code to use ctdb_node_become_inactive()
    
    There's no reason to avoid immediately setting recovery mode to active
    and initiating freeze of databases.
    
    This effectively reverts the following commits:
    
      d8f3b490bbb691c9916eed0df5b980c1aef23c85
      b4357a79d916b1f8ade8fa78563fbef0ce670aa9
    
    The latter is now implemented using a control, resulting in looser
    coupling.
    
    See also the following commit:
    
      f8141e91a693912ea1107a49320e83702a80757a
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14087
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 0f5f7b7cf4e970f3f36c5e0b3d09e710fe90801a)

commit 093973899580c2fd1a95d067ff695388b7bdc4f8
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 19 21:47:03 2019 +1000

    ctdb-daemon: Factor out new function ctdb_node_become_inactive()
    
    This is a superset of ctdb_local_node_got_banned() so will replace
    that function, and will also be used in the NODE_STOP control.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14087
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit a42bcaabb63722411bee52b80cbfc795593defbc)

commit 240ad91944d617d33b85aaeeed2a57ecf1ce9c67
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Aug 13 17:08:43 2019 +1000

    ctdb-tcp: Mark node as disconnected if incoming connection goes away
    
    To make it easy to pass the node data to the upcall, the private data
    for ctdb_tcp_read_cb() needs to be changed from tnode to node.
    
    RN: Avoid marking a node as connected before it can receive packets
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Fri Aug 16 22:50:35 UTC 2019 on sn-devel-184
    
    (cherry picked from commit 73c850eda4209b688a169aeeb20c453b738cbb35)

commit adb19f17cd1a778a6ee58d7f4658b9f27ea087de
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Aug 9 15:33:05 2019 +1000

    ctdb-tcp: Only mark a node connected if both directions are up
    
    Nodes are currently marked as up if the outgoing connection is
    established.  However, if the incoming connection is not yet
    established then this node could send a request where the replying
    node can not queue its reply.  Wait until both directions are up
    before marking a node as connected.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 8c98c10f242bc722beffc711e85c0e4f2e74cd57)

commit 6668733c306896a779c707acdd9912efcf52c0da
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 15 15:57:31 2019 +1000

    ctdb-tcp: Create outbound queue when the connection becomes writable
    
    Since commit ddd97553f0a8bfaada178ec4a7460d76fa21f079
    ctdb_queue_send() doesn't queue a packet if the connection isn't yet
    established (i.e. when fd == -1).  So, don't bother creating the
    outbound queue during initialisation but create it when the connection
    becomes writable.
    
    Now the presence of the queue indicates that the outbound connection
    is up.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 7f4854d9643a096a6d8a354fcd27b7c6ed24a75e)

commit 1ef2ffbab865b80c90a69b5899285c0b7409c26d
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 15 15:45:16 2019 +1000

    ctdb-tcp: Use TALLOC_FREE()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit d80d9edb4dc107b15a35a39e5c966a3eaed6453a)

commit bf39d0cff16cd240ceddb3cb88183ad61e667ac2
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Aug 9 15:29:36 2019 +1000

    ctdb-tcp: Move incoming fd and queue into struct ctdb_tcp_node
    
    This makes it easy to track both incoming and outgoing connectivity
    states.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit c68b6f96f26664459187ab2fbd56767fb31767e0)

commit 4cf26ff2ec350db6b3ad5fa08dea602b3b842baf
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Aug 9 15:06:34 2019 +1000

    ctdb-tcp: Rename fd -> out_fd
    
    in_fd is coming soon.
    
    Fix coding style violations in the affected and adjacent lines.
    Modernise some debug macros and make them more consistent (e.g. drop
    logging of errno when strerror(errno) is already logged.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit c06620169fc178ea6db2631f03edf008285d8cf2)

commit 0b4a99c22f5e72d2bc6e2770b070e964866db148
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 8 16:20:44 2019 +1000

    ctdb-daemon: Add function ctdb_ip_to_node()
    
    This is the core logic from ctdb_ip_to_pnn(), so re-implement that
    that function using ctdb_ip_to_node().
    
    Something similar (ctdb_ip_to_nodeid()) was recently removed in commit
    010c1d77cd7e192b1fff39b7b91fccbdbbf4a786 because it wasn't required.
    Now there is a use case.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 3acb8e9d1c854b577d6be282257269df83055d31)

commit 53b0fd2216dfd93ae0379f48e712294137e9b5b6
Author: Michael Adam <obnox at samba.org>
Date:   Thu Aug 1 00:47:29 2019 +0200

    vfs:glusterfs_fuse: build only if we have setmntent()
    
    FreeBSD and other platforms that don't have setmntent() and friends can
    not compile this module. This patch lets changes the build to only
    compile this module if the setmntent() function is found.
    
    This is the a follow-up fix to the actual fix for bug #13972.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13972
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Thu Aug  1 09:49:04 UTC 2019 on sn-devel-184
    
    (cherry picked from commit f258cfaa1d07af6ac6e996006f6e59955cfe34ce)

commit d8ba147db50feeeedbeb738a2be24c28e3790a45
Author: Michael Adam <obnox at samba.org>
Date:   Sat May 18 11:28:54 2019 +0200

    vfs:glusterfs_fuse: ensure fileids are constant across nodes
    
    Instead of adding a new gluster-specific mode to the fileid module,
    this patches provides a fileid algorithm as part of the glusterfs_fuse
    vfs module. This can not be configured further, simply adding the
    glusterfs_fuse vfs module to the vfs objects configuration will enable
    the new fileid mode.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13972
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Guenther Deschner <gd at samba.org>
    
    Autobuild-User(master): Günther Deschner <gd at samba.org>
    Autobuild-Date(master): Sat Jul 13 22:54:56 UTC 2019 on sn-devel-184
    
    (cherry picked from commit 5522aa1a4c34ee1a1e81db73cf41594bb10bd989)

-----------------------------------------------------------------------

Summary of changes:
 WHATSNEW.txt                               |  15 +++
 ctdb/include/ctdb_private.h                |   5 +-
 ctdb/server/ctdb_banning.c                 |  26 +---
 ctdb/server/ctdb_recover.c                 |  45 +++++++
 ctdb/server/ctdb_server.c                  |  24 +++-
 ctdb/tcp/ctdb_tcp.h                        |  16 +--
 ctdb/tcp/tcp_connect.c                     | 208 +++++++++++++++++++----------
 ctdb/tcp/tcp_init.c                        |  21 +--
 ctdb/tcp/tcp_io.c                          |  17 ++-
 docs-xml/manpages/vfs_glusterfs_fuse.8.xml |   8 ++
 docs-xml/smbdotconf/domain/rndccommand.xml |   7 +
 source3/modules/vfs_glusterfs_fuse.c       | 193 +++++++++++++++++++++++++-
 source3/wscript                            |   4 +-
 13 files changed, 464 insertions(+), 125 deletions(-)


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 6a0cc9d72fd..c273117c72f 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -68,6 +68,20 @@ in the following years. If you have a strong requirement for SMB1
 (except for supporting old Linux Kernels), please file a bug
 at https://bugzilla.samba.org and let us know about the details.
 
+BIND9_FLATFILE deprecated
+-------------------------
+
+The BIND9_FLATFILE DNS backend is deprecated in this release and will
+be removed in the future.  This was only practically useful on a single
+domain controller or under expert care and supervision.
+
+This release therefore deprecates the "rndc command" smb.conf
+parameter, which is used to support this configuration.  After writing
+out a list of DCs permitted to make changes to the DNS Zone "rndc
+command" is called with reload to tell the 'named' server if a DC was
+added/removed to to the domain.
+
+
 NEW FEATURES/CHANGES
 ====================
 
@@ -342,6 +356,7 @@ smb.conf changes
   web port                           Removed
   fruit:zero_file_id                 Changed default            False
   debug encryption                   New: dump encryption keys  False
+  rndc command                       Deprecated
 
 
 KNOWN ISSUES
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 2bcc7c94156..1f168dae2b8 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -481,7 +481,6 @@ int ctdb_ibw_init(struct ctdb_context *ctdb);
 
 /* from ctdb_banning.c */
 
-void ctdb_local_node_got_banned(struct ctdb_context *ctdb);
 int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata);
 int32_t ctdb_control_get_ban_state(struct ctdb_context *ctdb, TDB_DATA *outdata);
 void ctdb_ban_self(struct ctdb_context *ctdb);
@@ -819,6 +818,8 @@ int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb);
 int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb,
 				   uint32_t opcode, TDB_DATA indata);
 
+void ctdb_node_become_inactive(struct ctdb_context *ctdb);
+
 int32_t ctdb_control_stop_node(struct ctdb_context *ctdb);
 int32_t ctdb_control_continue_node(struct ctdb_context *ctdb);
 
@@ -831,6 +832,8 @@ void ctdb_stop_recoverd(struct ctdb_context *ctdb);
 
 int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
 
+struct ctdb_node *ctdb_ip_to_node(struct ctdb_context *ctdb,
+				  const ctdb_sock_addr *nodeip);
 uint32_t ctdb_ip_to_pnn(struct ctdb_context *ctdb,
 			const ctdb_sock_addr *nodeip);
 
diff --git a/ctdb/server/ctdb_banning.c b/ctdb/server/ctdb_banning.c
index 9cd163645a1..3c711575e8c 100644
--- a/ctdb/server/ctdb_banning.c
+++ b/ctdb/server/ctdb_banning.c
@@ -57,30 +57,6 @@ static void ctdb_ban_node_event(struct tevent_context *ev,
 	}
 }
 
-void ctdb_local_node_got_banned(struct ctdb_context *ctdb)
-{
-	struct ctdb_db_context *ctdb_db;
-
-	DEBUG(DEBUG_NOTICE, ("This node has been banned - releasing all public "
-			     "IPs and setting the generation to INVALID.\n"));
-
-	/* Reset the generation id to 1 to make us ignore any
-	   REQ/REPLY CALL/DMASTER someone sends to us.
-	   We are now banned so we shouldnt service database calls
-	   anymore.
-	*/
-	ctdb->vnn_map->generation = INVALID_GENERATION;
-	for (ctdb_db = ctdb->db_list; ctdb_db != NULL; ctdb_db = ctdb_db->next) {
-		ctdb_db->generation = INVALID_GENERATION;
-	}
-
-	/* Recovery daemon will set the recovery mode ACTIVE and freeze
-	 * databases.
-	 */
-
-	ctdb_release_all_ips(ctdb);
-}
-
 int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata)
 {
 	struct ctdb_ban_state *bantime = (struct ctdb_ban_state *)indata.dptr;
@@ -129,7 +105,7 @@ int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata)
 			 ctdb_ban_node_event, ctdb);
 
 	if (!already_banned) {
-		ctdb_local_node_got_banned(ctdb);
+		ctdb_node_become_inactive(ctdb);
 	}
 	return 0;
 }
diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c
index 343728839c1..1654c6d3978 100644
--- a/ctdb/server/ctdb_recover.c
+++ b/ctdb/server/ctdb_recover.c
@@ -1420,12 +1420,57 @@ int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb, uint32_t opcode, T
 	return 0;
 }
 
+void ctdb_node_become_inactive(struct ctdb_context *ctdb)
+{
+	struct ctdb_db_context *ctdb_db;
+
+	D_WARNING("Making node INACTIVE\n");
+
+	/*
+	 * Do not service database calls - reset generation to invalid
+	 * so this node ignores any REQ/REPLY CALL/DMASTER
+	 */
+	ctdb->vnn_map->generation = INVALID_GENERATION;
+	for (ctdb_db = ctdb->db_list; ctdb_db != NULL; ctdb_db = ctdb_db->next) {
+		ctdb_db->generation = INVALID_GENERATION;
+	}
+
+	/*
+	 * Although this bypasses the control, the only thing missing
+	 * is the deferred drop of all public IPs, which isn't
+	 * necessary because they are dropped below
+	 */
+	if (ctdb->recovery_mode != CTDB_RECOVERY_ACTIVE) {
+		D_NOTICE("Recovery mode set to ACTIVE\n");
+		ctdb->recovery_mode = CTDB_RECOVERY_ACTIVE;
+	}
+
+	/*
+	 * Initiate database freeze - this will be scheduled for
+	 * immediate execution and will be in progress long before the
+	 * calling control returns
+	 */
+	ctdb_daemon_send_control(ctdb,
+				 ctdb->pnn,
+				 0,
+				 CTDB_CONTROL_FREEZE,
+				 0,
+				 CTDB_CTRL_FLAG_NOREPLY,
+				 tdb_null,
+				 NULL,
+				 NULL);
+
+	D_NOTICE("Dropping all public IP addresses\n");
+	ctdb_release_all_ips(ctdb);
+}
 
 int32_t ctdb_control_stop_node(struct ctdb_context *ctdb)
 {
 	DEBUG(DEBUG_ERR, ("Stopping node\n"));
 	ctdb->nodes[ctdb->pnn]->flags |= NODE_FLAGS_STOPPED;
 
+	ctdb_node_become_inactive(ctdb);
+
 	return 0;
 }
 
diff --git a/ctdb/server/ctdb_server.c b/ctdb/server/ctdb_server.c
index dcd761a2961..9724d1fe0a8 100644
--- a/ctdb/server/ctdb_server.c
+++ b/ctdb/server/ctdb_server.c
@@ -45,9 +45,9 @@ int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport)
 	return 0;
 }
 
-/* Return the PNN for nodeip, CTDB_UNKNOWN_PNN if nodeip is invalid */
-uint32_t ctdb_ip_to_pnn(struct ctdb_context *ctdb,
-			const ctdb_sock_addr *nodeip)
+/* Return the node structure for nodeip, NULL if nodeip is invalid */
+struct ctdb_node *ctdb_ip_to_node(struct ctdb_context *ctdb,
+				  const ctdb_sock_addr *nodeip)
 {
 	unsigned int nodeid;
 
@@ -56,11 +56,25 @@ uint32_t ctdb_ip_to_pnn(struct ctdb_context *ctdb,
 			continue;
 		}
 		if (ctdb_same_ip(&ctdb->nodes[nodeid]->address, nodeip)) {
-			return ctdb->nodes[nodeid]->pnn;
+			return ctdb->nodes[nodeid];
 		}
 	}
 
-	return CTDB_UNKNOWN_PNN;
+	return NULL;
+}
+
+/* Return the PNN for nodeip, CTDB_UNKNOWN_PNN if nodeip is invalid */
+uint32_t ctdb_ip_to_pnn(struct ctdb_context *ctdb,
+			const ctdb_sock_addr *nodeip)
+{
+	struct ctdb_node *node;
+
+	node = ctdb_ip_to_node(ctdb, nodeip);
+	if (node == NULL) {
+		return CTDB_UNKNOWN_PNN;
+	}
+
+	return node->pnn;
 }
 
 /* Load a nodes list file into a nodes array */
diff --git a/ctdb/tcp/ctdb_tcp.h b/ctdb/tcp/ctdb_tcp.h
index 0a998c94da4..9a615fc6393 100644
--- a/ctdb/tcp/ctdb_tcp.h
+++ b/ctdb/tcp/ctdb_tcp.h
@@ -26,23 +26,19 @@ struct ctdb_tcp {
 	int listen_fd;
 };
 
-/*
-  state associated with an incoming connection
-*/
-struct ctdb_incoming {
-	struct ctdb_context *ctdb;
-	int fd;
-	struct ctdb_queue *queue;
-};
-
 /*
   state associated with one tcp node
 */
 struct ctdb_tcp_node {
-	int fd;
+	int out_fd;
 	struct ctdb_queue *out_queue;
+
 	struct tevent_fd *connect_fde;
 	struct tevent_timer *connect_te;
+
+	struct ctdb_context *ctdb;
+	int in_fd;
+	struct ctdb_queue *in_queue;
 };
 
 
diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c
index d757abdf26c..6123380ca9f 100644
--- a/ctdb/tcp/tcp_connect.c
+++ b/ctdb/tcp/tcp_connect.c
@@ -44,15 +44,13 @@ void ctdb_tcp_stop_connection(struct ctdb_node *node)
 {
 	struct ctdb_tcp_node *tnode = talloc_get_type(
 		node->private_data, struct ctdb_tcp_node);
-	
-	ctdb_queue_set_fd(tnode->out_queue, -1);
-	talloc_free(tnode->connect_te);
-	talloc_free(tnode->connect_fde);
-	tnode->connect_fde = NULL;
-	tnode->connect_te = NULL;
-	if (tnode->fd != -1) {
-		close(tnode->fd);
-		tnode->fd = -1;
+
+	TALLOC_FREE(tnode->out_queue);
+	TALLOC_FREE(tnode->connect_te);
+	TALLOC_FREE(tnode->connect_fde);
+	if (tnode->out_fd != -1) {
+		close(tnode->out_fd);
+		tnode->out_fd = -1;
 	}
 }
 
@@ -93,12 +91,13 @@ static void ctdb_node_connect_write(struct tevent_context *ev,
 	int error = 0;
 	socklen_t len = sizeof(error);
 	int one = 1;
+	int ret;
 
 	talloc_free(tnode->connect_te);
 	tnode->connect_te = NULL;
 
-	if (getsockopt(tnode->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0 ||
-	    error != 0) {
+	ret = getsockopt(tnode->out_fd, SOL_SOCKET, SO_ERROR, &error, &len);
+	if (ret != 0 || error != 0) {
 		ctdb_tcp_stop_connection(node);
 		tnode->connect_te = tevent_add_timer(ctdb->ev, tnode,
 						    timeval_current_ofs(1, 0),
@@ -109,22 +108,54 @@ static void ctdb_node_connect_write(struct tevent_context *ev,
 	talloc_free(tnode->connect_fde);
 	tnode->connect_fde = NULL;
 
-        if (setsockopt(tnode->fd,IPPROTO_TCP,TCP_NODELAY,(char *)&one,sizeof(one)) == -1) {
-		DEBUG(DEBUG_WARNING, ("Failed to set TCP_NODELAY on fd - %s\n",
-				      strerror(errno)));
+	ret = setsockopt(tnode->out_fd,
+			 IPPROTO_TCP,
+			 TCP_NODELAY,
+			 (char *)&one,
+			 sizeof(one));
+	if (ret == -1) {
+		DBG_WARNING("Failed to set TCP_NODELAY on fd - %s\n",
+			  strerror(errno));
 	}
-        if (setsockopt(tnode->fd,SOL_SOCKET,SO_KEEPALIVE,(char *)&one,sizeof(one)) == -1) {
-		DEBUG(DEBUG_WARNING, ("Failed to set KEEPALIVE on fd - %s\n",
-				      strerror(errno)));
+	ret = setsockopt(tnode->out_fd,
+			 SOL_SOCKET,
+			 SO_KEEPALIVE,(char *)&one,
+			 sizeof(one));
+	if (ret == -1) {
+		DBG_WARNING("Failed to set KEEPALIVE on fd - %s\n",
+			    strerror(errno));
 	}
 
-	ctdb_queue_set_fd(tnode->out_queue, tnode->fd);
+	tnode->out_queue = ctdb_queue_setup(node->ctdb,
+					    tnode,
+					    tnode->out_fd,
+					    CTDB_TCP_ALIGNMENT,
+					    ctdb_tcp_tnode_cb,
+					    node,
+					    "to-node-%s",
+					    node->name);
+	if (tnode->out_queue == NULL) {
+		DBG_ERR("Failed to set up outgoing queue\n");
+		ctdb_tcp_stop_connection(node);
+		tnode->connect_te = tevent_add_timer(ctdb->ev,
+						     tnode,
+						     timeval_current_ofs(1, 0),
+						     ctdb_tcp_node_connect,
+						     node);
+		return;
+	}
 
 	/* the queue subsystem now owns this fd */
-	tnode->fd = -1;
+	tnode->out_fd = -1;
 
-	/* tell the ctdb layer we are connected */
-	node->ctdb->upcalls->node_connected(node);
+	/*
+	 * Mark the node to which this connection has been established
+	 * as connected, but only if the corresponding listening
+	 * socket is also connected
+	 */
+	if (tnode->in_fd != -1) {
+		node->ctdb->upcalls->node_connected(node);
+	}
 }
 
 
@@ -149,26 +180,24 @@ void ctdb_tcp_node_connect(struct tevent_context *ev, struct tevent_timer *te,
 
 	sock_out = node->address;
 
-	tnode->fd = socket(sock_out.sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
-	if (tnode->fd == -1) {
-		DEBUG(DEBUG_ERR, (__location__ " Failed to create socket\n"));
+	tnode->out_fd = socket(sock_out.sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
+	if (tnode->out_fd == -1) {
+		DBG_ERR("Failed to create socket\n");
 		return;
 	}
 
-	ret = set_blocking(tnode->fd, false);
+	ret = set_blocking(tnode->out_fd, false);
 	if (ret != 0) {
-		DEBUG(DEBUG_ERR,
-		      (__location__
-		       " failed to set socket non-blocking (%s)\n",
-		       strerror(errno)));
-		close(tnode->fd);
-		tnode->fd = -1;
+		DBG_ERR("Failed to set socket non-blocking (%s)\n",
+			strerror(errno));
+		close(tnode->out_fd);
+		tnode->out_fd = -1;
 		return;
 	}
 
-	set_close_on_exec(tnode->fd);
+	set_close_on_exec(tnode->out_fd);
 
-	DEBUG(DEBUG_DEBUG, (__location__ " Created TCP SOCKET FD:%d\n", tnode->fd));
+	DBG_DEBUG("Created TCP SOCKET FD:%d\n", tnode->out_fd);
 
 	/* Bind our side of the socketpair to the same address we use to listen
 	 * on incoming CTDB traffic.
@@ -197,39 +226,48 @@ void ctdb_tcp_node_connect(struct tevent_context *ev, struct tevent_timer *te,
 	default:
 		DEBUG(DEBUG_ERR, (__location__ " unknown family %u\n",
 			sock_in.sa.sa_family));
-		close(tnode->fd);
-		tnode->fd = -1;
+		close(tnode->out_fd);
+		tnode->out_fd = -1;
 		return;
 	}
 
-	if (bind(tnode->fd, (struct sockaddr *)&sock_in, sockin_size) == -1) {
-		DEBUG(DEBUG_ERR, (__location__ " Failed to bind socket %s(%d)\n",
-				  strerror(errno), errno));
-		close(tnode->fd);
-		tnode->fd = -1;
+	ret = bind(tnode->out_fd, (struct sockaddr *)&sock_in, sockin_size);
+	if (ret == -1) {
+		DBG_ERR("Failed to bind socket (%s)\n", strerror(errno));
+		close(tnode->out_fd);
+		tnode->out_fd = -1;
 		return;
 	}
 
-	if (connect(tnode->fd, (struct sockaddr *)&sock_out, sockout_size) != 0 &&
-	    errno != EINPROGRESS) {
+	ret = connect(tnode->out_fd,
+		      (struct sockaddr *)&sock_out,
+		      sockout_size);
+	if (ret != 0 && errno != EINPROGRESS) {
 		ctdb_tcp_stop_connection(node);
-		tnode->connect_te = tevent_add_timer(ctdb->ev, tnode,
+		tnode->connect_te = tevent_add_timer(ctdb->ev,
+						     tnode,
 						     timeval_current_ofs(1, 0),
-						     ctdb_tcp_node_connect, node);
+						     ctdb_tcp_node_connect,
+						     node);
 		return;
 	}
 
 	/* non-blocking connect - wait for write event */
-	tnode->connect_fde = tevent_add_fd(node->ctdb->ev, tnode, tnode->fd,
+	tnode->connect_fde = tevent_add_fd(node->ctdb->ev,
+					   tnode,
+					   tnode->out_fd,
 					   TEVENT_FD_WRITE|TEVENT_FD_READ,
-					   ctdb_node_connect_write, node);
+					   ctdb_node_connect_write,
+					   node);
 
 	/* don't give it long to connect - retry in one second. This ensures
 	   that we find a node is up quickly (tcp normally backs off a syn reply
 	   delay by quite a lot) */
-	tnode->connect_te = tevent_add_timer(ctdb->ev, tnode,
+	tnode->connect_te = tevent_add_timer(ctdb->ev,
+					     tnode,
 					     timeval_current_ofs(1, 0),
-					     ctdb_tcp_node_connect, node);
+					     ctdb_tcp_node_connect,
+					     node);
 }
 
 /*
@@ -245,8 +283,8 @@ static void ctdb_listen_event(struct tevent_context *ev, struct tevent_fd *fde,
 	ctdb_sock_addr addr;
 	socklen_t len;
 	int fd;
-	uint32_t pnn;
-	struct ctdb_incoming *in;
+	struct ctdb_node *node;
+	struct ctdb_tcp_node *tnode;
 	int one = 1;
 	int ret;
 
@@ -256,42 +294,70 @@ static void ctdb_listen_event(struct tevent_context *ev, struct tevent_fd *fde,
 	if (fd == -1) return;
 	smb_set_close_on_exec(fd);
 
-	pnn = ctdb_ip_to_pnn(ctdb, &addr);
-
-	if (pnn == CTDB_UNKNOWN_PNN) {
+	node = ctdb_ip_to_node(ctdb, &addr);
+	if (node == NULL) {
 		D_ERR("Refused connection from unknown node %s\n",
 		      ctdb_addr_to_str(&addr));
 		close(fd);
 		return;
 	}
 
-	in = talloc_zero(ctcp, struct ctdb_incoming);
-	in->fd = fd;
-	in->ctdb = ctdb;
+	tnode = talloc_get_type_abort(node->private_data,
+				      struct ctdb_tcp_node);
+	if (tnode == NULL) {
+		/* This can't happen - see ctdb_tcp_initialise() */
+		DBG_ERR("INTERNAL ERROR setting up connection from node %s\n",
+			ctdb_addr_to_str(&addr));
+		close(fd);
+		return;
+	}
 
-	ret = set_blocking(in->fd, false);
+	ret = set_blocking(fd, false);
 	if (ret != 0) {
-		DEBUG(DEBUG_ERR,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list