[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Thu Sep 8 08:46:04 UTC 2016


The branch, master has been updated
       via  c730f0b ctdb-scripts: Optimise tickle_tcp_connections()
       via  30c56a0 ctdb-scripts: Optimise update_tickles()
       via  a75a2c2 ctdb-tests: Allow "addtickle" and "deltickle" stubs to read from stdin
       via  bacdb2e ctdb-tests: CID 1125635 Dereference null return value (NULL_RETURNS)
       via  19b4fb2 ctdb-tools: CID 1125617 String not null terminated (STRING_NULL)
       via  a2abc78 ctdb-daemon: Compare interface pointers instead of using strcmp(3)
       via  a66072e ctdb-daemon: Use ctdb_find_iface() instead of duplicating logic
       via  2f46056 ctdb-deamon: Rename vnn_has_interface_with_name() to vnn_has_interface()
       via  b129c28 ctdb-daemon: Drop redundant uses of ctdb_find_iface()
       via  29787cb ctdb-daemon: Make vnn->iface a list of new struct vnn_interface
       via  e6258ac ctdb-daemon: Change ctdb_add_local_iface() to return struct ctdb_interface
       via  ff4b452 ctdb-daemon: Move interface addition into interface parsing
       via  1790f9f ctdb-daemon: Drop some uses of CTDB_NO_MEMORY{,_FATAL}()
       via  c3502cf ctdb-daemon: Consolidate interface checking with interface parsing
       via  05665d9 ctdb-daemon: Replace some uses of CTDB_NO_MEMORY_FATAL()
       via  d658d4e ctdb-daemon: Move and improve public IP duplicate checking
       via  f63fe7c ctdb-daemon: Drop use of strdup(3) and free(3) when releasing IP
      from  d1c30ab lib: call_backtrace() is no more

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c730f0b3374bb2708f79e65dcab89febbf76476c
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Sep 8 11:29:25 2015 +1000

    ctdb-scripts: Optimise tickle_tcp_connections()
    
    Pipe the connections to "ctdb tickle" on stdin to avoid having to fork
    so many "ctdb tickle" processes.  This maintains the current level of
    verbosity at the price of some extra memory usage.
    
    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): Thu Sep  8 10:45:42 CEST 2016 on sn-devel-144

commit 30c56a0c801dfb64085013a87ddedb1cd76b42a9
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 23 19:37:35 2015 +1100

    ctdb-scripts: Optimise update_tickles()
    
    Use addtickle and deltickle with stdin.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit a75a2c2c43808b6f1d63dec29a54d9138b12d7fd
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Sep 7 17:24:26 2015 +1000

    ctdb-tests: Allow "addtickle" and "deltickle" stubs to read from stdin
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit bacdb2e0f8a5f75c21dd108635d700b59acf2791
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Sep 2 13:23:36 2016 +1000

    ctdb-tests: CID 1125635 Dereference null return value (NULL_RETURNS)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12244
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 19b4fb22a6c62d0f616c5a914f1510ae15677249
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Sep 2 11:56:02 2016 +1000

    ctdb-tools: CID 1125617 String not null terminated (STRING_NULL)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12244
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit a2abc78c875ec530410410da0bdf7fbe2f78b9a5
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 25 11:48:36 2016 +1000

    ctdb-daemon: Compare interface pointers instead of using strcmp(3)
    
    If the interfaces have different names then they are different
    interfaces.
    
    Also, move assignment of new_name just above where is is first used.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit a66072efdf91723e87fd68642c6650c9df3f12d6
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 25 11:41:11 2016 +1000

    ctdb-daemon: Use ctdb_find_iface() instead of duplicating logic
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 2f46056228dd4a9f0b278e08066b03c3b65352df
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 24 20:41:49 2016 +1000

    ctdb-deamon: Rename vnn_has_interface_with_name() to vnn_has_interface()
    
    Now takes a pointer to an interface structure and does direct pointer
    comparisons.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit b129c288f58be75cf548486616f62f51fc8c97e1
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 24 20:38:03 2016 +1000

    ctdb-daemon: Drop redundant uses of ctdb_find_iface()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 29787cb3c89fc8bbe9ffc13b2b924a0dcdb4d3fc
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 24 18:21:51 2016 +1000

    ctdb-daemon: Make vnn->iface a list of new struct vnn_interface
    
    To keep this change small, this leaves behind some redundant calls to
    ctdb_find_iface() and similar.  They will be cleaned up later.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit e6258acf1b8aed0e216571c4eb42555e597a5dc5
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 24 16:59:46 2016 +1000

    ctdb-daemon: Change ctdb_add_local_iface() to return struct ctdb_interface
    
    This will allow a change to the way interfaces are handled in a VNN.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ff4b452c6a430bc0b70dd74917f54dbc42f1137e
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 24 16:55:15 2016 +1000

    ctdb-daemon: Move interface addition into interface parsing
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 1790f9f75422db309494227b8bd8eaf650be77cd
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 24 16:49:30 2016 +1000

    ctdb-daemon: Drop some uses of CTDB_NO_MEMORY{,_FATAL}()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit c3502cf9f9e99539e69ca92d1a78ca3aff71b3df
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Aug 20 20:34:33 2016 +1000

    ctdb-daemon: Consolidate interface checking with interface parsing
    
    There's no point parsing the interfaces twice, especially since it
    doesn't improve error handling.
    
    This also removes a use of strdup(3)/free(3), which is not generally
    used in our code.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 05665d9ede9f78e466ec40f1630a1fcb4ff357cb
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Aug 20 20:29:04 2016 +1000

    ctdb-daemon: Replace some uses of CTDB_NO_MEMORY_FATAL()
    
    Also add a missing out-of-memory check for vnn->ifaces.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit d658d4e70123b6869b82ec5bfc8b04b721c61f93
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Aug 20 20:21:34 2016 +1000

    ctdb-daemon: Move and improve public IP duplicate checking
    
    This also moves the interface validation down, making more obvious
    that it can be consolidated.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit f63fe7c3b9e66ff2d4048b071e651035cde394b5
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Aug 20 20:02:44 2016 +1000

    ctdb-daemon: Drop use of strdup(3) and free(3) when releasing IP
    
    If anything should be used here it should be talloc functions.
    However, this is a remnant from when ctdb_sys_find_ifname() was used
    here and, for some reason, it used strdup(3).
    
    In this case the interface string doesn't actually need to be copied.
    The only use of it is when ctdb_event_script_callback_v() uses it with
    the format string in a call to talloc_vasprintf().  In the same
    context the IP address isn't copied.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 ctdb/config/functions              |  31 ++----
 ctdb/server/ctdb_takeover.c        | 194 +++++++++++++++++++------------------
 ctdb/tests/eventscripts/stubs/ctdb |  68 ++++++++++---
 ctdb/tests/src/rb_test.c           |   1 +
 ctdb/tools/ctdb.c                  |   1 +
 5 files changed, 163 insertions(+), 132 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/config/functions b/ctdb/config/functions
index a29daf5..ac9aa91 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -520,21 +520,12 @@ tickle_tcp_connections ()
 {
     _ip="$1"
 
-    get_tcp_connections_for_ip "$_ip" |
-    {
-	_failed=false
-
-	while read dest src; do
-	    echo "Tickle TCP connection $src $dest"
-	    $CTDB tickle "$src" "$dest" >/dev/null 2>&1 || _failed=true
-	    echo "Tickle TCP connection $dest $src"
-	    $CTDB tickle "$dest" "$src" >/dev/null 2>&1 || _failed=true
-	done
+    # Get connections, both directions
+    _conns=$(get_tcp_connections_for_ip "$_ip" | \
+		    awk '{ print $1, $2 ; print $2, $1 }')
 
-	if $_failed ; then
-	    echo "Failed to send tickle control"
-	fi
-    }
+    echo "$_conns" | awk '{ print "Tickle TCP connection", $1, $2 }'
+    echo "$_conns" | ctdb tickle
 }
 
 get_tcp_connections_for_ip ()
@@ -1276,16 +1267,12 @@ update_tickles ()
 	sort >"$_my_tickles"
 
 	# Add tickles for connections that we haven't already got tickles for
-	comm -23 "$_my_connections" "$_my_tickles" |
-	while read _src _dst ; do
-		$CTDB addtickle "$_src" "$_dst"
-	done
+	comm -23 "$_my_connections" "$_my_tickles" | \
+		$CTDB addtickle
 
 	# Remove tickles for connections that are no longer there
-	comm -13 "$_my_connections" "$_my_tickles" |
-	while read _src _dst ; do
-		$CTDB deltickle "$_src" "$_dst"
-	done
+	comm -13 "$_my_connections" "$_my_tickles" | \
+		$CTDB deltickle
 
 	rm -f "$_my_connections" "$_my_tickles"
 
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index 2955b37..02e5c3d 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -55,12 +55,17 @@ struct ctdb_interface {
 	uint32_t references;
 };
 
+struct vnn_interface {
+	struct vnn_interface *prev, *next;
+	struct ctdb_interface *iface;
+};
+
 /* state associated with a public ip address */
 struct ctdb_vnn {
 	struct ctdb_vnn *prev, *next;
 
 	struct ctdb_interface *iface;
-	const char **ifaces;
+	struct vnn_interface *ifaces;
 	ctdb_sock_addr public_address;
 	uint8_t public_netmask_bits;
 
@@ -98,42 +103,52 @@ static const char *ctdb_vnn_iface_string(const struct ctdb_vnn *vnn)
 	return iface_string(vnn->iface);
 }
 
-static int ctdb_add_local_iface(struct ctdb_context *ctdb, const char *iface)
+static struct ctdb_interface *ctdb_find_iface(struct ctdb_context *ctdb,
+					      const char *iface);
+
+static struct ctdb_interface *
+ctdb_add_local_iface(struct ctdb_context *ctdb, const char *iface)
 {
 	struct ctdb_interface *i;
 
 	if (strlen(iface) > CTDB_IFACE_SIZE) {
 		DEBUG(DEBUG_ERR, ("Interface name too long \"%s\"\n", iface));
-		return -1;
+		return NULL;
 	}
 
 	/* Verify that we don't have an entry for this ip yet */
-	for (i=ctdb->ifaces;i;i=i->next) {
-		if (strcmp(i->name, iface) == 0) {
-			return 0;
-		}
+	i = ctdb_find_iface(ctdb, iface);
+	if (i != NULL) {
+		return i;
 	}
 
 	/* create a new structure for this interface */
 	i = talloc_zero(ctdb, struct ctdb_interface);
-	CTDB_NO_MEMORY_FATAL(ctdb, i);
+	if (i == NULL) {
+		DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
+		return NULL;
+	}
 	i->name = talloc_strdup(i, iface);
-	CTDB_NO_MEMORY(ctdb, i->name);
+	if (i->name == NULL) {
+		DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
+		talloc_free(i);
+		return NULL;
+	}
 
 	i->link_up = true;
 
 	DLIST_ADD(ctdb->ifaces, i);
 
-	return 0;
+	return i;
 }
 
-static bool vnn_has_interface_with_name(struct ctdb_vnn *vnn,
-					const char *name)
+static bool vnn_has_interface(struct ctdb_vnn *vnn,
+			      const struct ctdb_interface *iface)
 {
-	int n;
+	struct vnn_interface *i;
 
-	for (n = 0; vnn->ifaces[n] != NULL; n++) {
-		if (strcmp(name, vnn->ifaces[n]) == 0) {
+	for (i = vnn->ifaces; i != NULL; i = i->next) {
+		if (iface == i->iface) {
 			return true;
 		}
 	}
@@ -164,14 +179,14 @@ static void ctdb_remove_orphaned_ifaces(struct ctdb_context *ctdb,
 		next = i->next;
 
 		/* Only consider interfaces named in the given VNN. */
-		if (!vnn_has_interface_with_name(vnn, i->name)) {
+		if (!vnn_has_interface(vnn, i)) {
 			continue;
 		}
 
 		/* Search for a vnn with this interface. */
 		found = false;
 		for (tv=ctdb->vnn; tv; tv=tv->next) {
-			if (vnn_has_interface_with_name(tv, i->name)) {
+			if (vnn_has_interface(tv, i)) {
 				found = true;
 				break;
 			}
@@ -203,16 +218,13 @@ static struct ctdb_interface *ctdb_find_iface(struct ctdb_context *ctdb,
 static struct ctdb_interface *ctdb_vnn_best_iface(struct ctdb_context *ctdb,
 						  struct ctdb_vnn *vnn)
 {
-	int i;
+	struct vnn_interface *i;
 	struct ctdb_interface *cur = NULL;
 	struct ctdb_interface *best = NULL;
 
-	for (i=0; vnn->ifaces[i]; i++) {
+	for (i = vnn->ifaces; i != NULL; i = i->next) {
 
-		cur = ctdb_find_iface(ctdb, vnn->ifaces[i]);
-		if (cur == NULL) {
-			continue;
-		}
+		cur = i->iface;
 
 		if (!cur->link_up) {
 			continue;
@@ -285,7 +297,7 @@ static void ctdb_vnn_unassign_iface(struct ctdb_context *ctdb,
 static bool ctdb_vnn_available(struct ctdb_context *ctdb,
 			       struct ctdb_vnn *vnn)
 {
-	int i;
+	struct vnn_interface *i;
 
 	/* Nodes that are not RUNNING can not host IPs */
 	if (ctdb->runstate != CTDB_RUNSTATE_RUNNING) {
@@ -300,15 +312,8 @@ static bool ctdb_vnn_available(struct ctdb_context *ctdb,
 		return true;
 	}
 
-	for (i=0; vnn->ifaces[i]; i++) {
-		struct ctdb_interface *cur;
-
-		cur = ctdb_find_iface(ctdb, vnn->ifaces[i]);
-		if (cur == NULL) {
-			continue;
-		}
-
-		if (cur->link_up) {
+	for (i = vnn->ifaces; i != NULL; i = i->next) {
+		if (i->iface->link_up) {
 			return true;
 		}
 	}
@@ -650,9 +655,7 @@ static int32_t ctdb_do_updateip(struct ctdb_context *ctdb,
 		return -1;
 	}
 
-	new_name = ctdb_vnn_iface_string(vnn);
-	if (old_name != NULL && new_name != NULL &&
-	    strcmp(old_name, new_name) == 0) {
+	if (old == vnn->iface) {
 		/* A benign update from one interface onto itself.
 		 * no need to run the eventscripts in this case, just return
 		 * success.
@@ -671,6 +674,7 @@ static int32_t ctdb_do_updateip(struct ctdb_context *ctdb,
 	vnn->update_in_flight = true;
 	talloc_set_destructor(state, ctdb_updateip_destructor);
 
+	new_name = ctdb_vnn_iface_string(vnn);
 	DEBUG(DEBUG_NOTICE,("Update of IP %s/%u from "
 			    "interface %s to %s\n",
 			    ctdb_addr_to_str(&vnn->public_address),
@@ -928,7 +932,7 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
 	struct release_ip_callback_state *state;
 	struct ctdb_public_ip *pip = (struct ctdb_public_ip *)indata.dptr;
 	struct ctdb_vnn *vnn;
-	char *iface;
+	const char *iface;
 
 	/* update our vnn list */
 	vnn = find_public_ip_vnn(ctdb, &pip->addr);
@@ -985,7 +989,7 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
 		return -1;
 	}
 
-	iface = strdup(ctdb_vnn_iface_string(vnn));
+	iface = ctdb_vnn_iface_string(vnn);
 
 	DEBUG(DEBUG_NOTICE,("Release of IP %s/%u on interface %s  node:%d\n",
 		ctdb_addr_to_str(&pip->addr),
@@ -997,7 +1001,6 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
 	if (state == NULL) {
 		ctdb_set_error(ctdb, "Out of memory at %s:%d",
 			       __FILE__, __LINE__);
-		free(iface);
 		return -1;
 	}
 
@@ -1006,7 +1009,6 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
 	if (state->addr == NULL) {
 		ctdb_set_error(ctdb, "Out of memory at %s:%d",
 			       __FILE__, __LINE__);
-		free(iface);
 		talloc_free(state);
 		return -1;
 	}
@@ -1024,7 +1026,6 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
 					 iface,
 					 ctdb_addr_to_str(&pip->addr),
 					 vnn->public_netmask_bits);
-	free(iface);
 	if (ret != 0) {
 		DEBUG(DEBUG_ERR,(__location__ " Failed to release IP %s on interface %s\n",
 			ctdb_addr_to_str(&pip->addr),
@@ -1045,60 +1046,66 @@ static int ctdb_add_public_address(struct ctdb_context *ctdb,
 				   bool check_address)
 {
 	struct ctdb_vnn      *vnn;
-	uint32_t num = 0;
 	char *tmp;
 	const char *iface;
-	int i;
-	int ret;
 
-	tmp = strdup(ifaces);
-	for (iface = strtok(tmp, ","); iface; iface = strtok(NULL, ",")) {
-		if (!ctdb_sys_check_iface_exists(iface)) {
-			DEBUG(DEBUG_CRIT,("Interface %s does not exist. Can not add public-address : %s\n", iface, ctdb_addr_to_str(addr)));
-			free(tmp);
-			return -1;
-		}
-	}
-	free(tmp);
-
-	/* Verify that we don't have an entry for this ip yet */
-	for (vnn=ctdb->vnn;vnn;vnn=vnn->next) {
+	/* Verify that we don't have an entry for this IP yet */
+	for (vnn = ctdb->vnn; vnn != NULL; vnn = vnn->next) {
 		if (ctdb_same_sockaddr(addr, &vnn->public_address)) {
-			DEBUG(DEBUG_CRIT,("Same ip '%s' specified multiple times in the public address list \n", 
-				ctdb_addr_to_str(addr)));
+			DEBUG(DEBUG_ERR,
+			      ("Duplicate public IP address '%s'\n",
+			       ctdb_addr_to_str(addr)));
 			return -1;
-		}		
+		}
 	}
 
-	/* create a new vnn structure for this ip address */
+	/* Create a new VNN structure for this IP address */
 	vnn = talloc_zero(ctdb, struct ctdb_vnn);
-	CTDB_NO_MEMORY_FATAL(ctdb, vnn);
-	vnn->ifaces = talloc_array(vnn, const char *, num + 2);
+	if (vnn == NULL) {
+		DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
+		return -1;
+	}
 	tmp = talloc_strdup(vnn, ifaces);
-	CTDB_NO_MEMORY_FATAL(ctdb, tmp);
-	for (iface = strtok(tmp, ","); iface; iface = strtok(NULL, ",")) {
-		vnn->ifaces = talloc_realloc(vnn, vnn->ifaces, const char *, num + 2);
-		CTDB_NO_MEMORY_FATAL(ctdb, vnn->ifaces);
-		vnn->ifaces[num] = talloc_strdup(vnn, iface);
-		CTDB_NO_MEMORY_FATAL(ctdb, vnn->ifaces[num]);
-		num++;
+	if (tmp == NULL) {
+		DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
+		talloc_free(vnn);
+		return -1;
 	}
-	talloc_free(tmp);
-	vnn->ifaces[num] = NULL;
-	vnn->public_address      = *addr;
-	vnn->public_netmask_bits = mask;
-	vnn->pnn                 = -1;
+	for (iface = strtok(tmp, ","); iface; iface = strtok(NULL, ",")) {
+		struct vnn_interface *vnn_iface;
+		struct ctdb_interface *i;
+		if (!ctdb_sys_check_iface_exists(iface)) {
+			DEBUG(DEBUG_ERR,
+			      ("Unknown interface %s for public address %s\n",
+			       iface, ctdb_addr_to_str(addr)));
+			talloc_free(vnn);
+			return -1;
+		}
 
-	for (i=0; vnn->ifaces[i]; i++) {
-		ret = ctdb_add_local_iface(ctdb, vnn->ifaces[i]);
-		if (ret != 0) {
-			DEBUG(DEBUG_CRIT, (__location__ " failed to add iface[%s] "
-					   "for public_address[%s]\n",
-					   vnn->ifaces[i], ctdb_addr_to_str(addr)));
+		i = ctdb_add_local_iface(ctdb, iface);
+		if (i == NULL) {
+			DEBUG(DEBUG_ERR,
+			      ("Failed to add interface '%s' "
+			       "for public address %s\n",
+			       iface, ctdb_addr_to_str(addr)));
+			talloc_free(vnn);
+			return -1;
+		}
+
+		vnn_iface = talloc_zero(vnn, struct vnn_interface);
+		if (vnn_iface == NULL) {
+			DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
 			talloc_free(vnn);
 			return -1;
 		}
+
+		vnn_iface->iface = i;
+		DLIST_ADD_END(vnn->ifaces, vnn_iface);
 	}
+	talloc_free(tmp);
+	vnn->public_address      = *addr;
+	vnn->public_netmask_bits = mask;
+	vnn->pnn                 = -1;
 
 	DLIST_ADD(ctdb->vnn, vnn);
 
@@ -2248,6 +2255,7 @@ int32_t ctdb_control_get_public_ip_info(struct ctdb_context *ctdb,
 	ctdb_sock_addr *addr;
 	struct ctdb_public_ip_info_old *info;
 	struct ctdb_vnn *vnn;
+	struct vnn_interface *iface;
 
 	addr = (ctdb_sock_addr *)indata.dptr;
 
@@ -2261,7 +2269,7 @@ int32_t ctdb_control_get_public_ip_info(struct ctdb_context *ctdb,
 
 	/* count how many public ip structures we have */
 	num = 0;
-	for (;vnn->ifaces[num];) {
+	for (iface = vnn->ifaces; iface != NULL; iface = iface->next) {
 		num++;
 	}
 
@@ -2274,15 +2282,11 @@ int32_t ctdb_control_get_public_ip_info(struct ctdb_context *ctdb,
 	info->ip.pnn = vnn->pnn;
 	info->active_idx = 0xFFFFFFFF;
 
-	for (i=0; vnn->ifaces[i]; i++) {
+	i = 0;
+	for (iface = vnn->ifaces; iface != NULL; iface = iface->next) {
 		struct ctdb_interface *cur;
 
-		cur = ctdb_find_iface(ctdb, vnn->ifaces[i]);
-		if (cur == NULL) {
-			DEBUG(DEBUG_CRIT, (__location__ " internal error iface[%s] unknown\n",
-					   vnn->ifaces[i]));
-			return -1;
-		}
+		cur = iface->iface;
 		if (vnn->iface == cur) {
 			info->active_idx = i;
 		}
@@ -2291,6 +2295,8 @@ int32_t ctdb_control_get_public_ip_info(struct ctdb_context *ctdb,
 		info->ifaces[i].name[sizeof(info->ifaces[i].name)-1] = '\0';
 		info->ifaces[i].link_state = cur->link_up;
 		info->ifaces[i].references = cur->references;
+
+		i++;
 	}
 	info->num = i;
 	len = offsetof(struct ctdb_public_ip_info_old, ifaces) +
@@ -2992,7 +2998,7 @@ static int ctdb_reloadips_child(struct ctdb_context *ctdb)
 			struct ctdb_addr_info_old *pub;
 			const char *ifaces = NULL;
 			uint32_t len;
-			int iface = 0;
+			struct vnn_interface *iface = NULL;
 
 			DEBUG(DEBUG_NOTICE,
 			      ("New IP %s configured, adding it\n",
@@ -3016,12 +3022,12 @@ static int ctdb_reloadips_child(struct ctdb_context *ctdb)
 				first_add = false;
 			}
 
-			ifaces = vnn->ifaces[0];
-			iface = 1;
-			while (vnn->ifaces[iface] != NULL) {
+			ifaces = vnn->ifaces->iface->name;
+			iface = vnn->ifaces->next;
+			while (iface != NULL) {
 				ifaces = talloc_asprintf(vnn, "%s,%s", ifaces,
-							 vnn->ifaces[iface]);
-				iface++;
+							 iface->iface->name);
+				iface = iface->next;
 			}
 
 			len   = strlen(ifaces) + 1;
diff --git a/ctdb/tests/eventscripts/stubs/ctdb b/ctdb/tests/eventscripts/stubs/ctdb
index a1cba70..46b0c1f 100755
--- a/ctdb/tests/eventscripts/stubs/ctdb
+++ b/ctdb/tests/eventscripts/stubs/ctdb
@@ -59,6 +59,55 @@ setup_tickles ()
     touch "$tickles_file"
 }
 
+ctdb_gettickles ()
+{
+    _ip="$1"
+    _port="$2"
+
+    setup_tickles
+
+    echo "|source ip|port|destination ip|port|"
+    while read _src _dst ; do
+	if [ -z "$_ip" -o "$_ip" = "${_dst%:*}" ] ; then
+	    if [ -z "$_port" -o "$_port" = "${_dst##*:}" ] ; then
+		echo "|${_src%:*}|${_src##*:}|${_dst%:*}|${_dst##*:}|"
+	    fi
+	fi
+    done <"$tickles_file"
+}
+
+ctdb_addtickle ()
+{
+    _src="$1"
+    _dst="$2"
+
+    setup_tickles
+
+    if [ -n "$_dst" ] ; then
+	echo "${_src} ${_dst}" >>"$tickles_file"
+    else
+	cat >>"$tickles_file"
+    fi
+}
+
+ctdb_deltickle ()
+{
+    _src="$1"
+    _dst="$2"
+
+    setup_tickles
+
+    if [ -n "$_dst" ] ; then
+	_t=$(grep -F -v "${_src} $${_dst}" "$tickles_file")
+    else
+	_t=$(cat "$tickles_file")
+	while read _src _dst ; do
+	    _t=$(echo "$_t" | grep -F -v "${_src} ${_dst}")
+	done
+    fi
+    echo "$_t" >"$tickles_file"


-- 
Samba Shared Repository



More information about the samba-cvs mailing list