[SCM] CTDB repository - branch 2.5 updated - ctdb-2.5.5-30-ged3c1f2

Amitay Isaacs amitay at samba.org
Wed Jul 22 03:55:05 UTC 2015


The branch, 2.5 has been updated
       via  ed3c1f234ea76d32c35361f5c92a9dc2ead86121 (commit)
       via  e7862c40247b51ecaedd6175924178f1581c62f4 (commit)
       via  b14199a07ea1649706a048bedb6ca4d3171d0eed (commit)
       via  daf7b5de5e57e7a6df21e2a510e40fadaf7a5fba (commit)
       via  64b70e26bc3973b17e681756ef9c623d83523a72 (commit)
       via  857d7ce8b371e1ea946757b1dad115b91345ebd4 (commit)
       via  2694ce9361252287848dd5bde8dfbafabd7a92f4 (commit)
       via  ec67cd5a6f031aebf70a2d6932ec5e40211a1092 (commit)
       via  6d52d77c36f2d1df0080aa1215db65d5b2e9ab62 (commit)
       via  c48d2d6301b10ad7bf14402af10bd46624515480 (commit)
       via  7742baef6595ca95900d25118bf70a96cf5d0451 (commit)
       via  640d678bba91fa9343651fa70dd82a2caa1fbf96 (commit)
       via  9550a76dc282c5432c70f90c9a840b152539a865 (commit)
       via  e99963c6aa5169933d26b097536866a0b30bcbba (commit)
      from  93deb93164a0522448bdafa60ecb3f1892aad8f1 (commit)

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


- Log -----------------------------------------------------------------
commit ed3c1f234ea76d32c35361f5c92a9dc2ead86121
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 21 12:23:27 2015 +1000

    daemon: Ignore SIGUSR1
    
    No use dying or failing eventscripts if someone sends a random
    SIGUSR1.
    
    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 Jul 21 11:00:17 CEST 2015 on sn-devel-104
    
    (Imported from commit 65515919142c922fe6ddf63d0f50449eec445b30)

commit e7862c40247b51ecaedd6175924178f1581c62f4
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 14 16:54:59 2015 +1000

    daemon: Return correct sequence number for CONTROL_GET_DB_SEQNUM
    
    Due to the missing cast of uint64_t, CONTROL_GET_DB_SEQNUM always returned
    seqnum <= 256.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11398
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Tue Jul 14 13:03:25 CEST 2015 on sn-devel-104
    
    (Imported from commit 1023db2543f7785e4527a4565db91edcde4ca7f1)

commit b14199a07ea1649706a048bedb6ca4d3171d0eed
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 14 13:43:14 2015 +1000

    daemon: Allow a new monitor event to cancel one already in progress
    
    Before commit cbffbb7c2f406fc1d8ebad3c531cc2757232690e this was
    possible and some users depend on this behaviour.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 182ebc07289c776ca104e648911a53209bcdaf00)

commit daf7b5de5e57e7a6df21e2a510e40fadaf7a5fba
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jul 6 12:02:00 2015 +1000

    daemon: Improve error messages when eventscript control is cancelled
    
    Warn specifically about cancellation instead of printing a generic
    error message.  Also pass back an error message for the tool - it
    could just rely on the status but it already looks at the error
    message.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 122a4fda7272ec4d63452037f0b838d2bdc5a79a)

commit 64b70e26bc3973b17e681756ef9c623d83523a72
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jul 6 11:48:28 2015 +1000

    tools: Avoiding printing "(null)" on "ctdb eventscript" error
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit b71d18d2dc090e99d67c6bd8552380b44f8db810)

commit 857d7ce8b371e1ea946757b1dad115b91345ebd4
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jul 10 14:02:29 2015 +1000

    daemon: Avoid double-free during monitor cancellation
    
    The eventscript state should never be freed externally, so it should
    never be allocated off a temporary context.  It will either be freed
    by the handler or in the cancellation code.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Pair-programmed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit f951ff13838e796cd6661d800daf460247cac60b)

commit 2694ce9361252287848dd5bde8dfbafabd7a92f4
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 8 22:22:09 2015 +1000

    tests: Add some 10.interfaces VLAN tests
    
    One without a bond, one with a bond.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 8ed0cacaf4aa9fc63b8c8d610a6164c5d01e473a)

commit ec67cd5a6f031aebf70a2d6932ec5e40211a1092
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 8 22:14:51 2015 +1000

    tests: Add VLAN support to the "ip link" stub
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 8e41cb1e4e7b4a7d92628771260649ded4432772)

commit 6d52d77c36f2d1df0080aa1215db65d5b2e9ab62
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 8 21:39:51 2015 +1000

    tests: Interface number in "ip link show" stub defaults to 42
    
    It needs to have a default for the standalone case, when it is not run
    in a loop inside "ip addr show".
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 4f84d42b511a4c9a79bd835eeca0a80082e76227)

commit c48d2d6301b10ad7bf14402af10bd46624515480
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 8 21:23:48 2015 +1000

    scripts: Support monitoring of interestingly named VLANs on bonds
    
    VLAN interfaces on bonds with a name other than <iface>.<id>@<iface>
    are not currently supported.  That is, where the VLAN name isn't based
    on the underlying bond name.  Such VLAN interfaces can be created with
    the "ip link" command, as opposed to the "vconfig" command, or by
    renaming a VLAN interface.
    
    This is improved by determining the underlying interface name for a
    VLAN from the output of "ip link".
    
    No serious attempt is made to support VLANs with '@' in their name,
    although this seems to be legal.  Why would you do that?
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit bc71251433ce618c95c674d7cbe75b01a94adad9)

commit 7742baef6595ca95900d25118bf70a96cf5d0451
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jul 9 14:55:59 2015 +1000

    daemon: Fix valgrind invalid read error in db_statistics control
    
      ==20761== Invalid read of size 8
      ==20761==    at 0x11BE30: ctdb_ctrl_dbstatistics (ctdb_client.c:1286)
      ==20761==    by 0x12BA89: control_dbstatistics (ctdb.c:713)
      ==20761==    by 0x1312E0: main (ctdb.c:6543)
      ==20761==  Address 0x713b0d0 is 0 bytes after a block of size 560 alloc'd
      ==20761==    at 0x4C27A2E: malloc (vg_replace_malloc.c:270)
      ==20761==    by 0x5CB0954: _talloc_memdup (talloc.c:615)
      ==20761==    by 0x11395C: ctdb_control_recv (ctdb_client.c:1146)
      ==20761==    by 0x11BDD7: ctdb_ctrl_dbstatistics (ctdb_client.c:1265)
      ==20761==    by 0x12BA89: control_dbstatistics (ctdb.c:713)
      ==20761==    by 0x1312E0: main (ctdb.c:6543)
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 9aa90482f8ffbddf898eb8a900112f45d82f0930)

commit 640d678bba91fa9343651fa70dd82a2caa1fbf96
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jun 17 15:05:30 2015 +1000

    daemon: Promote debug messages about --start-as-* to NOTICE level
    
    It is important to know when ctdbd is started with --start-as-stopped
    or --start-as-disabled.  Given that this only happens once it makes
    sense to promote these debug items to NOTICE level.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit eb159f3ff530de8828631b04e17bf0990aed906e)

commit 9550a76dc282c5432c70f90c9a840b152539a865
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jun 11 15:49:25 2015 +1000

    recoverd: Clear IP assignment tree on election loss
    
    If a node was previously recovery master (say, 20 years ago) and it
    becomes recovery master again then, if IP assignments have changed,
    verify_remote_ip_allocation() can produce messages like the following
    when called during recovery:
    
      ctdbd: recoverd:Inconsistent IP allocation - node 0 thinks 10.1.1.1 is held by node 0 while it is assigned to node 1
    
    When a node loses an election it should clear all data specific to it
    being the recovery master.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit b234ae0a900052b03ca22efab8fa1b9e11f44ecc)

commit e99963c6aa5169933d26b097536866a0b30bcbba
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jun 11 15:46:27 2015 +1000

    recoverd: Add new function clear_ip_assignment_tree()
    
    This needs to be cleared to avoid stale data when a new recovery
    master is elected.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 036c2a92438585ab6b99a22fcf67b67890c525f0)

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

Summary of changes:
 client/ctdb_client.c                           |  2 +-
 config/events.d/10.interface                   | 28 +++++++++++++--
 include/ctdb_private.h                         |  3 +-
 server/ctdb_daemon.c                           |  5 +--
 server/ctdb_ltdb_server.c                      |  3 +-
 server/ctdb_persistent.c                       |  5 +--
 server/ctdb_recoverd.c                         |  2 ++
 server/ctdb_takeover.c                         |  4 +++
 server/eventscript.c                           | 23 +++++++++---
 tests/eventscripts/10.interface.monitor.017.sh | 20 +++++++++++
 tests/eventscripts/10.interface.monitor.018.sh | 20 +++++++++++
 tests/eventscripts/stubs/ip                    | 50 +++++++++++++++++++++++++-
 tools/ctdb.c                                   |  7 +++-
 13 files changed, 154 insertions(+), 18 deletions(-)
 create mode 100755 tests/eventscripts/10.interface.monitor.017.sh
 create mode 100755 tests/eventscripts/10.interface.monitor.018.sh


Changeset truncated at 500 lines:

diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index cf6835a..1c33e66 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -1283,7 +1283,7 @@ int ctdb_ctrl_dbstatistics(struct ctdb_context *ctdb, uint32_t destnode, uint32_
 	}
 
 	wire = (struct ctdb_db_statistics *)outdata.dptr;
-	*s = *wire;
+	memcpy(s, wire, offsetof(struct ctdb_db_statistics, hot_keys_wire));
 	ptr = &wire->hot_keys_wire[0];
 	for (i=0; i<wire->num_hot_keys; i++) {
 		s->hot_keys[i].key.dptr = talloc_size(mem_ctx, s->hot_keys[i].key.dsize);
diff --git a/config/events.d/10.interface b/config/events.d/10.interface
index 51d1b97..bcd5cf9 100755
--- a/config/events.d/10.interface
+++ b/config/events.d/10.interface
@@ -52,6 +52,30 @@ get_all_interfaces ()
     all_interfaces=$(echo $all_interfaces $ctdb_ifaces | tr ' ' '\n' | sort -u)
 }
 
+get_real_iface ()
+{
+    # Output of "ip link show <iface>"
+    _iface_info="$1"
+
+    # Extract the full interface description to see if it is a VLAN
+    _t=$(echo "$_iface_info" |
+		awk 'NR == 1 { iface = $2; sub(":$", "", iface) ; \
+			       print iface }')
+    case "$_t" in
+	*@*)
+	    # VLAN: use the underlying interface, after the '@'
+	    echo "${_t##*@}"
+	    ;;
+	*)
+	    # Not a regular VLAN.  For backward compatibility, assume
+	    # there is some other sort of VLAN that doesn't have the
+	    # '@' in the output and only use what is before a '.'.  If
+	    # there is no '.' then this will be the whole interface
+	    # name.
+	    echo "${_t%%.*}"
+    esac
+}
+
 monitor_interfaces()
 {
 	get_all_interfaces
@@ -65,7 +89,7 @@ monitor_interfaces()
 	# problem with an interface then set fail=true and continue.
 	for iface in $all_interfaces ; do
 
-	    ip link show $iface 2>/dev/null >/dev/null || {
+	    _iface_info=$(ip link show $iface 2>&1) || {
 		echo "ERROR: Interface $iface does not exist but it is used by public addresses."
 		mark_down $iface
 		continue
@@ -74,7 +98,7 @@ monitor_interfaces()
 	    # These interfaces are sometimes bond devices
 	    # When we use VLANs for bond interfaces, there will only
 	    # be an entry in /proc for the underlying real interface
-	    realiface=`echo $iface |sed -e 's/\..*$//'`
+	    realiface=$(get_real_iface "$_iface_info")
 	    bi=$(get_proc "net/bonding/$realiface" 2>/dev/null) && {
 		echo "$bi" | grep -q 'Currently Active Slave: None' && {
 			echo "ERROR: No active slaves for bond device $realiface"
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 30905ac..f68ba60 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -1499,11 +1499,12 @@ void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event);
 
 void ctdb_fault_setup(void);
 
-int verify_remote_ip_allocation(struct ctdb_context *ctdb, 
+int verify_remote_ip_allocation(struct ctdb_context *ctdb,
 				struct ctdb_all_public_ips *ips,
 				uint32_t pnn);
 int update_ip_assignment_tree(struct ctdb_context *ctdb,
 				struct ctdb_public_ip *ip);
+void clear_ip_assignment_tree(struct ctdb_context *ctdb);
 
 int ctdb_init_tevent_logging(struct ctdb_context *ctdb);
 
diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c
index fe995c6..1d8bde4 100644
--- a/server/ctdb_daemon.c
+++ b/server/ctdb_daemon.c
@@ -1024,12 +1024,12 @@ static void initialise_node_flags (struct ctdb_context *ctdb)
 
 	/* do we start out in DISABLED mode? */
 	if (ctdb->start_as_disabled != 0) {
-		DEBUG(DEBUG_INFO, ("This node is configured to start in DISABLED state\n"));
+		DEBUG(DEBUG_NOTICE, ("This node is configured to start in DISABLED state\n"));
 		ctdb->nodes[ctdb->pnn]->flags |= NODE_FLAGS_DISABLED;
 	}
 	/* do we start out in STOPPED mode? */
 	if (ctdb->start_as_stopped != 0) {
-		DEBUG(DEBUG_INFO, ("This node is configured to start in STOPPED state\n"));
+		DEBUG(DEBUG_NOTICE, ("This node is configured to start in STOPPED state\n"));
 		ctdb->nodes[ctdb->pnn]->flags |= NODE_FLAGS_STOPPED;
 	}
 }
@@ -1172,6 +1172,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog)
 		}
 	}
 	ignore_signal(SIGPIPE);
+	ignore_signal(SIGUSR1);
 
 	ctdb->ctdbd_pid = getpid();
 	DEBUG(DEBUG_ERR, ("Starting CTDBD (Version %s) as PID: %u\n",
diff --git a/server/ctdb_ltdb_server.c b/server/ctdb_ltdb_server.c
index 3b71918..a7ae813 100644
--- a/server/ctdb_ltdb_server.c
+++ b/server/ctdb_ltdb_server.c
@@ -1627,7 +1627,8 @@ int32_t ctdb_control_get_db_statistics(struct ctdb_context *ctdb,
 		return -1;
 	}
 
-	*stats = ctdb_db->statistics;
+	memcpy(stats, &ctdb_db->statistics,
+	       offsetof(struct ctdb_db_statistics, hot_keys_wire));
 
 	stats->num_hot_keys = MAX_HOT_KEYS;
 
diff --git a/server/ctdb_persistent.c b/server/ctdb_persistent.c
index cfbea63..88b8387 100644
--- a/server/ctdb_persistent.c
+++ b/server/ctdb_persistent.c
@@ -369,14 +369,11 @@ int32_t ctdb_control_get_db_seqnum(struct ctdb_context *ctdb,
 	}
 
 	outdata->dsize = sizeof(uint64_t);
-	outdata->dptr = (uint8_t *)talloc_zero(outdata, uint64_t);
+	outdata->dptr = talloc_memdup(outdata, &seqnum, sizeof(uint64_t));
 	if (outdata->dptr == NULL) {
 		ret = -1;
-		goto done;
 	}
 
-	*(outdata->dptr) = seqnum;
-
 done:
 	return ret;
 }
diff --git a/server/ctdb_recoverd.c b/server/ctdb_recoverd.c
index 793ef1f..650af2f 100644
--- a/server/ctdb_recoverd.c
+++ b/server/ctdb_recoverd.c
@@ -2742,6 +2742,8 @@ static void election_handler(struct ctdb_context *ctdb, uint64_t srvid,
 		}
 	}
 
+	clear_ip_assignment_tree(ctdb);
+
 	/* ok, let that guy become recmaster then */
 	ret = ctdb_ctrl_setrecmaster(ctdb, CONTROL_TIMEOUT(), ctdb_get_pnn(ctdb), em->pnn);
 	if (ret != 0) {
diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c
index caffd17..29d54f2 100644
--- a/server/ctdb_takeover.c
+++ b/server/ctdb_takeover.c
@@ -4412,6 +4412,10 @@ int update_ip_assignment_tree(struct ctdb_context *ctdb, struct ctdb_public_ip *
 	return 0;
 }
 
+void clear_ip_assignment_tree(struct ctdb_context *ctdb)
+{
+	TALLOC_FREE(ctdb->ip_tree);
+}
 
 struct ctdb_reloadips_handle {
 	struct ctdb_context *ctdb;
diff --git a/server/eventscript.c b/server/eventscript.c
index 84dcf68..b08a797 100644
--- a/server/eventscript.c
+++ b/server/eventscript.c
@@ -711,8 +711,12 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
 		}
 	}
 
-	/* Do not run new monitor events if some event is already running */
-	if (call == CTDB_EVENT_MONITOR && ctdb->active_events > 0) {
+	/* Do not run new monitor events if some event is already
+	 * running, unless the running event is a monitor event, in
+	 * which case running a new one should cancel the old one. */
+	if (call == CTDB_EVENT_MONITOR &&
+	    ctdb->active_events > 0 &&
+	    ctdb->current_monitor == NULL) {
 		if (callback != NULL) {
 			callback(ctdb, -ECANCELED, private_data);
 		}
@@ -905,14 +909,23 @@ struct eventscript_callback_state {
 static void run_eventscripts_callback(struct ctdb_context *ctdb, int status, 
 				 void *private_data)
 {
+	const char *errmsg = NULL;
+
 	struct eventscript_callback_state *state = 
 		talloc_get_type(private_data, struct eventscript_callback_state);
 
 	if (status != 0) {
-		DEBUG(DEBUG_ERR,(__location__ " Failed to run eventscripts\n"));
+		if (status == -ECANCELED) {
+			DEBUG(DEBUG_WARNING,
+			      (__location__ " Eventscript cancelled\n"));
+			errmsg = "cancelled";
+		} else {
+			DEBUG(DEBUG_ERR,
+			      (__location__ " Failed to run eventscripts\n"));
+		}
 	}
 
-	ctdb_request_control_reply(ctdb, state->c, NULL, status, NULL);
+	ctdb_request_control_reply(ctdb, state->c, NULL, status, errmsg);
 	/* This will free the struct ctdb_event_script_state we are in! */
 	talloc_free(state);
 	return;
@@ -972,7 +985,7 @@ int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb,
 	DEBUG(DEBUG_NOTICE,("Running eventscripts with arguments %s\n", indata.dptr));
 
 	ret = ctdb_event_script_callback(ctdb, 
-			 state, run_eventscripts_callback, state,
+			 ctdb, run_eventscripts_callback, state,
 			 call, "%s", options);
 
 	if (ret != 0) {
diff --git a/tests/eventscripts/10.interface.monitor.017.sh b/tests/eventscripts/10.interface.monitor.017.sh
new file mode 100755
index 0000000..6e30040
--- /dev/null
+++ b/tests/eventscripts/10.interface.monitor.017.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "1 VLAN, link down"
+
+setup_ctdb
+
+iface=$(ctdb_get_1_interface)
+
+ethtool_interfaces_down "$iface"
+
+# This just exercises the VLAN checking code, which will allow us to
+# determine that real0 is not a bond.
+realiface="real0"
+ip link add link "$realiface" name "$iface" type vlan id 11
+ip link set "${iface}@${realiface}" up
+
+required_result 1 "ERROR: No link on the public network interface ${iface}"
+simple_test
diff --git a/tests/eventscripts/10.interface.monitor.018.sh b/tests/eventscripts/10.interface.monitor.018.sh
new file mode 100755
index 0000000..aac23b8
--- /dev/null
+++ b/tests/eventscripts/10.interface.monitor.018.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "VLAN on bond, active slaves, link down"
+
+setup_ctdb
+
+iface=$(ctdb_get_1_interface)
+
+bond="bond0"
+
+setup_bond "$bond" "" "down"
+
+ip link add link "$bond" name "$iface" type vlan id 11
+ip link set "${iface}@${bond}" up
+
+required_result 1 "ERROR: public network interface ${bond} is down"
+
+simple_test
diff --git a/tests/eventscripts/stubs/ip b/tests/eventscripts/stubs/ip
index e8f17d8..2021758 100755
--- a/tests/eventscripts/stubs/ip
+++ b/tests/eventscripts/stubs/ip
@@ -23,15 +23,58 @@ ip_link ()
 	    esac
 	    ;;
 	show) shift ; ip_link_show "$@" ;;
+	add*) shift ; ip_link_add "$@" ;;
 	del*) shift ; ip_link_delete "$@" ;;
 	*) not_implemented "$*" ;;
     esac
 }
 
+ip_link_add ()
+{
+    _link=""
+    _name=""
+    _type=""
+
+    while [ -n "$1" ] ; do
+	case "$1" in
+	    link)
+		_link="$2"
+		shift 2
+		;;
+	    name)
+		_name="$2"
+		shift 2
+		;;
+	    type)
+		if [ "$2" != "vlan" ] ; then
+		    not_implemented "link type $1"
+		fi
+		_type="$2"
+		shift 2
+		;;
+	    id) shift 2 ;;
+	    *) not_implemented "$1" ;;
+	esac
+    done
+
+    case "$_type" in
+	vlan)
+	    if [ -z "$_name" -o -z "$_link" ] ; then
+		not_implemented "ip link add with null name or link"
+	    fi
+
+	    mkdir -p "${FAKE_IP_STATE}/interfaces-vlan"
+	    echo "$_link" >"${FAKE_IP_STATE}/interfaces-vlan/${_name}"
+	    ip_link_set_down "$_name"
+	    ;;
+    esac
+}
+
 ip_link_delete ()
 {
     mkdir -p "${FAKE_IP_STATE}/interfaces-deleted"
     touch "${FAKE_IP_STATE}/interfaces-deleted/$1"
+    rm -f "${FAKE_IP_STATE}/interfaces-vlan/$1"
 }
 
 ip_link_set_up ()
@@ -59,6 +102,11 @@ ip_link_show ()
 	exit 255
     fi
 
+    if [ -r "${FAKE_IP_STATE}/interfaces-vlan/${dev}" ] ; then
+	read _link <"${FAKE_IP_STATE}/interfaces-vlan/${dev}"
+	dev="${dev}@${_link}"
+    fi
+
     mac=$(echo $dev | md5sum | sed -r -e 's@(..)(..)(..)(..)(..)(..).*@\1:\2:\3:\4:\5:\6@')
     _state="UP"
     _flags=",UP,LOWER_UP"
@@ -66,7 +114,7 @@ ip_link_show ()
 	_state="DOWN"
 	_flags=""
     fi
-    echo "${n}: ${dev}: <BROADCAST,MULTICAST${_flags}> mtu 1500 qdisc pfifo_fast state ${_state} qlen 1000"
+    echo "${n:-42}: ${dev}: <BROADCAST,MULTICAST${_flags}> mtu 1500 qdisc pfifo_fast state ${_state} qlen 1000"
     echo "    link/ether ${mac} brd ff:ff:ff:ff:ff:ff"
 }
 
diff --git a/tools/ctdb.c b/tools/ctdb.c
index 82f095d..ebbe84e 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -5515,7 +5515,12 @@ static int control_eventscript(struct ctdb_context *ctdb, int argc, const char *
 	ret = ctdb_control(ctdb, options.pnn, 0, CTDB_CONTROL_RUN_EVENTSCRIPTS,
 			   0, data, tmp_ctx, NULL, &res, NULL, &errmsg);
 	if (ret != 0 || res != 0) {
-		DEBUG(DEBUG_ERR,("Failed to run eventscripts - %s\n", errmsg));
+		if (errmsg != NULL) {
+			DEBUG(DEBUG_ERR,
+			      ("Failed to run eventscripts - %s\n", errmsg));
+		} else {
+			DEBUG(DEBUG_ERR, ("Failed to run eventscripts\n"));
+		}
 		talloc_free(tmp_ctx);
 		return -1;
 	}


-- 
CTDB repository



More information about the samba-cvs mailing list