Blame SOURCES/bz1757837-IPsrcaddr-fix-regression-without-NetworkManager.patch

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