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

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