The branch, master has been updated via cbd6beb ctdb-daemon: Move a ZERO_STRUCT() to a better place via 151b02c ctdb-eventscripts: Add check for invalid policy routing configuration via e09147b ctdb-eventscripts: Update comment in 11.routing via be71a84 ctdb-eventscripts: Don't check if $iface is empty from 2995b93 poll_funcs: Fix a comment typo
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit cbd6beb469c63749d68e6fa52b101c19ee75314f Author: Martin Schwenke <mar...@meltin.net> Date: Fri Mar 28 16:18:17 2014 +1100 ctdb-daemon: Move a ZERO_STRUCT() to a better place It might as well be near where it is used. Add a comment explaining it. Also add/update comments at the top of the RELEASE_IP and TAKEOVER_IP loops to explain what is happening. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> Autobuild-User(master): Amitay Isaacs <ami...@samba.org> Autobuild-Date(master): Mon May 5 06:20:39 CEST 2014 on sn-devel-104 commit 151b02cd9e05b120cc88086cfa0be6eaad04f736 Author: Martin Schwenke <mar...@meltin.net> Date: Thu Jan 16 14:48:39 2014 +1100 ctdb-eventscripts: Add check for invalid policy routing configuration The range CTDB_PER_IP_ROUTING_TABLE_ID_LOW..CTDB_PER_IP_ROUTING_TABLE_ID_HIGH should not include 253-255. Otherwise policy routing may overwrite the default system routing tables. Add some corresponding tests. Signed-off-by: Martin Schwenke <mar...@meltin.net> Pair-programmed-with: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit e09147b6a31371d46b269563b707313619616564 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jan 15 14:16:52 2014 +1100 ctdb-eventscripts: Update comment in 11.routing Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit be71a84565e9e7532a77c175732b764d1f42c1cd Author: Martin Schwenke <mar...@meltin.net> Date: Thu Mar 27 16:31:54 2014 +1100 ctdb-eventscripts: Don't check if $iface is empty This is the loop variable. It can't be empty, especially given the way the list is built. This must have survived from an earlier version of the script. Given that there are whitespace changes associated with the above, clean-up the "virtio_net" avoidance check so that it reads less like line-noise. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> ----------------------------------------------------------------------- Summary of changes: ctdb/config/events.d/10.interface | 28 +++++++++++---------- ctdb/config/events.d/11.routing | 21 ++++++++++------ ctdb/config/events.d/13.per_ip_routing | 5 ++++ ctdb/server/ctdb_takeover.c | 15 +++++++++-- ctdb/tests/eventscripts/13.per_ip_routing.021.sh | 14 +++++++++++ ctdb/tests/eventscripts/13.per_ip_routing.022.sh | 14 +++++++++++ 6 files changed, 73 insertions(+), 24 deletions(-) create mode 100755 ctdb/tests/eventscripts/13.per_ip_routing.021.sh create mode 100755 ctdb/tests/eventscripts/13.per_ip_routing.022.sh Changeset truncated at 500 lines: diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface index 32d841f..979fa7b 100755 --- a/ctdb/config/events.d/10.interface +++ b/ctdb/config/events.d/10.interface @@ -110,22 +110,24 @@ monitor_interfaces() mark_up $iface ;; *) - [ -z "$iface" ] || { - [ "$(basename $(readlink /sys/class/net/$iface/device/driver) 2>/dev/null)" = virtio_net ] || + # Ignore virtio_net devices, assume they're always up + _driver_path="/sys/class/net/$iface/device/driver" + _driver=$(basename $(readlink "$_driver_path") 2>/dev/null) + [ "$_driver" = "virtio_net" ] && continue + + ethtool $iface | grep -q 'Link detected: yes' || { + # On some systems, this is not successful when a + # cable is plugged but the interface has not been + # brought up previously. Bring the interface up + # and try again... + ip link set $iface up ethtool $iface | grep -q 'Link detected: yes' || { - # On some systems, this is not successful when a - # cable is plugged but the interface has not been - # brought up previously. Bring the interface up and - # try again... - ip link set $iface up - ethtool $iface | grep -q 'Link detected: yes' || { - echo "ERROR: No link on the public network interface $iface" - mark_down $iface - continue - } + echo "ERROR: No link on the public network interface $iface" + mark_down $iface + continue } - mark_up $iface } + mark_up $iface ;; esac diff --git a/ctdb/config/events.d/11.routing b/ctdb/config/events.d/11.routing index ccc60e7..2fe560f 100755 --- a/ctdb/config/events.d/11.routing +++ b/ctdb/config/events.d/11.routing @@ -1,15 +1,20 @@ #!/bin/sh -# script to add entries to the routing table after we have performed a -# take ip event -# (when we do a "releaseip" event and remove an ip address from an interface -# the kernel might automatically remove associated entries from -# the routing table. This is where we add them back) + +# Attempt to add a set of static routes. +# +# Do this in "ipreallocated" rather than just "startup" because some +# of the routes might be missing because the corresponding interface +# has not previously had any IPs assigned or IPs were previously +# released and corresponding routes were dropped. +# +# Addition of some routes might fail, errors go to /dev/null. +# +# Routes to add are defined in $CTDB_BASE/static-routes. Syntax is: # -# Routes to add are defined in /etc/ctdb/static-routes. -# Syntax is : # IFACE NET/MASK GATEWAY # -# Example +# Example: +# # bond1 10.3.3.0/24 10.0.0.1 [ -n "$CTDB_BASE" ] || \ diff --git a/ctdb/config/events.d/13.per_ip_routing b/ctdb/config/events.d/13.per_ip_routing index de153a6..ee83632 100755 --- a/ctdb/config/events.d/13.per_ip_routing +++ b/ctdb/config/events.d/13.per_ip_routing @@ -19,6 +19,11 @@ table_id_prefix="ctdb." [ "$CTDB_PER_IP_ROUTING_TABLE_ID_LOW" -lt "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] 2>/dev/null || \ die "error: CTDB_PER_IP_ROUTING_TABLE_ID_LOW[$CTDB_PER_IP_ROUTING_TABLE_ID_LOW] and/or CTDB_PER_IP_ROUTING_TABLE_ID_HIGH[$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH] improperly configured" +if [ "$CTDB_PER_IP_ROUTING_TABLE_ID_LOW" -le 253 -a \ + 255 -le "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] ; then + die "error: range CTDB_PER_IP_ROUTING_TABLE_ID_LOW[$CTDB_PER_IP_ROUTING_TABLE_ID_LOW]..CTDB_PER_IP_ROUTING_TABLE_ID_HIGH[$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH] must not include 253-255" +fi + have_link_local_config () { [ "$CTDB_PER_IP_ROUTING_CONF" = "__auto_link_local__" ] diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index 1404954..6c21e2b 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -2691,8 +2691,6 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap, return -1; } - ZERO_STRUCT(ip); - /* Do the IP reassignment calculations */ ctdb_takeover_run_core(ctdb, ipflags, &all_ips, force_rebalance_nodes); @@ -2716,6 +2714,14 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap, async_data->fail_callback = takeover_run_fail_callback; async_data->callback_data = takeover_data; + ZERO_STRUCT(ip); /* Avoid valgrind warnings for union */ + + /* Send a RELEASE_IP to all nodes that should not be hosting + * each IP. For each IP, all but one of these will be + * redundant. However, the redundant ones are used to tell + * nodes which node should be hosting the IP so that commands + * like "ctdb ip" can display a particular nodes idea of who + * is hosting what. */ for (i=0;i<nodemap->num;i++) { /* don't talk to unconnected nodes, but do talk to banned nodes */ if (nodemap->nodes[i].flags & NODE_FLAGS_DISCONNECTED) { @@ -2770,7 +2776,10 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap, talloc_free(async_data); - /* tell all nodes to get their own IPs */ + /* For each IP, send a TAKOVER_IP to the node that should be + * hosting it. Many of these will often be redundant (since + * the allocation won't have changed) but they can be useful + * to recover from inconsistencies. */ async_data = talloc_zero(tmp_ctx, struct client_async_data); CTDB_NO_MEMORY_FATAL(ctdb, async_data); diff --git a/ctdb/tests/eventscripts/13.per_ip_routing.021.sh b/ctdb/tests/eventscripts/13.per_ip_routing.021.sh new file mode 100755 index 0000000..609ecad --- /dev/null +++ b/ctdb/tests/eventscripts/13.per_ip_routing.021.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "Invalid table ID range - includes system tables" + +setup_ctdb +setup_ctdb_policy_routing + +CTDB_PER_IP_ROUTING_TABLE_ID_LOW=100 +CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=500 + +required_result 1 "error: range CTDB_PER_IP_ROUTING_TABLE_ID_LOW[${CTDB_PER_IP_ROUTING_TABLE_ID_LOW}]..CTDB_PER_IP_ROUTING_TABLE_ID_HIGH[${CTDB_PER_IP_ROUTING_TABLE_ID_HIGH}] must not include 253-255" +simple_test_event "ipreallocated" diff --git a/ctdb/tests/eventscripts/13.per_ip_routing.022.sh b/ctdb/tests/eventscripts/13.per_ip_routing.022.sh new file mode 100755 index 0000000..28997e3 --- /dev/null +++ b/ctdb/tests/eventscripts/13.per_ip_routing.022.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "Invalid table ID range - reversed" + +setup_ctdb +setup_ctdb_policy_routing + +CTDB_PER_IP_ROUTING_TABLE_ID_LOW=9000 +CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=1000 + +required_result 1 "error: CTDB_PER_IP_ROUTING_TABLE_ID_LOW[${CTDB_PER_IP_ROUTING_TABLE_ID_LOW}] and/or CTDB_PER_IP_ROUTING_TABLE_ID_HIGH[${CTDB_PER_IP_ROUTING_TABLE_ID_HIGH}] improperly configured" +simple_test_event "ipreallocated" -- Samba Shared Repository