resource-agents/SOURCES/bz1757837-IPsrcaddr-fix-regression-without-NetworkManager.patch

76 lines
2.5 KiB
Diff
Raw Normal View History

2021-05-14 04:17:31 +00:00
From 6052e8fd37d23f46db217f915b445c7e67dccb34 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 4 Apr 2019 13:31:27 +0200
Subject: [PATCH] IPsrcaddr: make proto optional to fix regression when used
without NetworkManager
---
heartbeat/IPsrcaddr | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/heartbeat/IPsrcaddr b/heartbeat/IPsrcaddr
index 4ca3d2364..5a447196e 100755
--- a/heartbeat/IPsrcaddr
+++ b/heartbeat/IPsrcaddr
@@ -50,12 +50,17 @@
#######################################################################
# Initialization:
-
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
+# Defaults
+OCF_RESKEY_proto_default=""
+
+: ${OCF_RESKEY_proto=${OCF_RESKEY_proto_default}}
#######################################################################
+[ -z "$OCF_RESKEY_proto" ] && PROTO="" || PROTO="proto $OCF_RESKEY_proto"
+
USAGE="usage: $0 {start|stop|status|monitor|validate-all|meta-data}";
CMDSHOW="$IP2UTIL route show to exact 0.0.0.0/0"
@@ -97,6 +102,14 @@ dotted quad notation 255.255.255.0).
<shortdesc lang="en">Netmask</shortdesc>
<content type="string" default=""/>
</parameter>
+
+<parameter name="proto">
+<longdesc lang="en">
+Proto to match when finding network. E.g. "kernel".
+</longdesc>
+<shortdesc lang="en">Proto</shortdesc>
+<content type="string" default="" />
+</parameter>
</parameters>
<actions>
@@ -172,7 +185,7 @@ srca_start() {
rc=$OCF_SUCCESS
ocf_log info "The ip route has been already set.($NETWORK, $INTERFACE, $ROUTE_WO_SRC)"
else
- ip route replace $NETWORK dev $INTERFACE src $1 || \
+ $IP2UTIL route replace $NETWORK dev $INTERFACE src $1 || \
errorexit "command 'ip route replace $NETWORK dev $INTERFACE src $1' failed"
$CMDCHANGE $ROUTE_WO_SRC src $1 || \
@@ -204,7 +217,7 @@ srca_stop() {
[ $rc = 2 ] && errorexit "The address you specified to stop does not match the preferred source address"
- ip route replace $NETWORK dev $INTERFACE || \
+ $IP2UTIL route replace $NETWORK dev $INTERFACE || \
errorexit "command 'ip route replace $NETWORK dev $INTERFACE' failed"
$CMDCHANGE $ROUTE_WO_SRC || \
@@ -473,7 +486,7 @@ rc=$?
}
INTERFACE=`echo $findif_out | awk '{print $1}'`
-NETWORK=`ip route list dev $INTERFACE scope link proto kernel match $ipaddress|grep -o '^[^ ]*'`
+NETWORK=`$IP2UTIL route list dev $INTERFACE scope link $PROTO match $ipaddress|grep -m 1 -o '^[^ ]*'`
case $1 in
start) srca_start $ipaddress