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

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