From 0c609c95051ff8c1e8fd61acc6abc7e4b4c4441b Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 24 Jun 2015 21:06:22 +1000 Subject: [PATCH] ctdb-scripts: Only write to /proc route flush files if they exist On IPv4-only or IPv6-only systems one of these files will not exist. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/config/functions | 11 +++++++++-- ctdb/tests/eventscripts/etc-ctdb/rc.local | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ctdb/config/functions b/ctdb/config/functions index ec695830713..bcef4c78b0b 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -221,6 +221,13 @@ set_proc () echo "$2" >"/proc/$1" } +set_proc_maybe () +{ + if [ -w "/proc/$1" ] ; then + set_proc "$1" "$2" + fi +} + ###################################################### # wrapper around getting file contents from /proc/ to allow # this to be hooked for testing @@ -977,8 +984,8 @@ drop_all_public_ips () flush_route_cache () { - set_proc sys/net/ipv4/route/flush 1 - set_proc sys/net/ipv6/route/flush 1 + set_proc_maybe sys/net/ipv4/route/flush 1 + set_proc_maybe sys/net/ipv6/route/flush 1 } ######################################################## diff --git a/ctdb/tests/eventscripts/etc-ctdb/rc.local b/ctdb/tests/eventscripts/etc-ctdb/rc.local index 0291e574589..0932ab4ad03 100755 --- a/ctdb/tests/eventscripts/etc-ctdb/rc.local +++ b/ctdb/tests/eventscripts/etc-ctdb/rc.local @@ -23,6 +23,7 @@ nice_service () # Always succeeds set_proc () { : ; } +set_proc_maybe () { : ; } get_proc () { -- 2.47.3