summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2012-06-15 17:22:02 +1000
committerMartin Schwenke <martin@meltin.net>2012-09-11 12:52:22 +1000
commit0d35a8c43910cc9310177e6036a5a1339f2a42f8 (patch)
treeb113e333f09d3034ade22ad898ebdb7fb3e4745f
parentaed0f9d1b935920999ed63f4640543e4bc57c974 (diff)
downloadsamba-0d35a8c43910cc9310177e6036a5a1339f2a42f8.tar.gz
samba-0d35a8c43910cc9310177e6036a5a1339f2a42f8.tar.xz
samba-0d35a8c43910cc9310177e6036a5a1339f2a42f8.zip
eventscripts: 13.per_ip_routing should remove bogus routes on ipreallocated
Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit d0d0a6f19960f233224970b8d5d19b0e37222616)
-rwxr-xr-xctdb/config/events.d/13.per_ip_routing26
1 files changed, 26 insertions, 0 deletions
diff --git a/ctdb/config/events.d/13.per_ip_routing b/ctdb/config/events.d/13.per_ip_routing
index ea3cffea80..9f71669e51 100755
--- a/ctdb/config/events.d/13.per_ip_routing
+++ b/ctdb/config/events.d/13.per_ip_routing
@@ -293,6 +293,31 @@ add_missing_routes ()
} || exit $?
}
+# Remove rules/routes for addresses that we're not hosting. If a
+# releaseip event failed in an earlier script then we might not have
+# had a chance to remove the corresponding rules/routes.
+remove_bogus_routes ()
+{
+ # Get a IPs current hosted by this node, each anchored with '@'.
+ _ips=$(ctdb ip -v -Y | awk -F: 'NR > 1 && $4 != "" {printf "@%s@\n", $2}')
+
+ ip rule show |
+ while read _p _x _i _x _t ; do
+ # Remove trailing colon after priority/preference.
+ _p="${_p%:}"
+ # Only remove rules that match our priority/preference.
+ [ "$CTDB_PER_IP_ROUTING_RULE_PREF" = "$_p" ] || continue
+ # Only remove rules for which we don't have an IP. This could
+ # be done with grep, but let's do it with shell prefix removal
+ # to avoid unnecessary processes. This falls through if
+ # "@${_i}@" isn't present in $_ips.
+ [ "$_ips" = "${_ips#*@${_i}@}" ] || continue
+
+ echo "Removing ip rule/routes for unhosted public address $_i"
+ del_routing_for_ip "$_i"
+ done
+}
+
######################################################################
ctdb_check_args "$@"
@@ -354,6 +379,7 @@ case "$1" in
ipreallocated)
add_missing_routes
+ remove_bogus_routes
;;
*)