Blame SOURCES/bz1582685-IPsrcaddr-2-local-rule-destination-fixes.patch

011c77
From 0e73d3f474d08779b64ed99fb3f80c1e806ff1b7 Mon Sep 17 00:00:00 2001
011c77
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
011c77
Date: Thu, 28 Nov 2019 16:11:51 +0100
011c77
Subject: [PATCH] IPsrcaddr: fixes to replace local rule if using local table,
011c77
 and set src back to primary for device on stop
011c77
011c77
---
011c77
 heartbeat/IPsrcaddr | 14 ++++++++++++--
011c77
 1 file changed, 12 insertions(+), 2 deletions(-)
011c77
011c77
diff --git a/heartbeat/IPsrcaddr b/heartbeat/IPsrcaddr
011c77
index d80b72165..f9085f082 100755
011c77
--- a/heartbeat/IPsrcaddr
011c77
+++ b/heartbeat/IPsrcaddr
011c77
@@ -75,6 +75,10 @@ USAGE="usage: $0 {start|stop|status|monitor|validate-all|meta-data}";
011c77
   CMDSHOW="$IP2UTIL route show   $TABLE to exact $OCF_RESKEY_destination"
011c77
 CMDCHANGE="$IP2UTIL route change to "
011c77
 
011c77
+if [ "$OCF_RESKEY_table" = "local" ]; then
011c77
+	TABLE="$TABLE local"
011c77
+fi
011c77
+
011c77
 SYSTYPE="`uname -s`"
011c77
 
011c77
 usage() {
011c77
@@ -247,8 +251,14 @@ srca_stop() {
011c77
 	  
011c77
 	[ $rc = 2 ] && errorexit "The address you specified to stop does not match the preferred source address"
011c77
 
011c77
-	$IP2UTIL route replace $TABLE $NETWORK dev $INTERFACE || \
011c77
-		errorexit "command 'ip route replace $TABLE $NETWORK dev $INTERFACE' failed"
011c77
+	OPTS=""
011c77
+	if [ "$OCF_RESKEY_destination" != "0.0.0.0/0" ] ;then
011c77
+		PRIMARY_IP="$($IP2UTIL -4 -o addr show dev eth0 primary | awk '{split($4,a,"/");print a[1]}')"
011c77
+		OPTS="proto kernel scope host src $PRIMARY_IP"
011c77
+	fi
011c77
+
011c77
+	$IP2UTIL route replace $TABLE $NETWORK dev $INTERFACE $OPTS || \
011c77
+		errorexit "command 'ip route replace $TABLE $NETWORK dev $INTERFACE $OPTS' failed"
011c77
 
011c77
 	if [ "$OCF_RESKEY_destination" = "0.0.0.0/0" ] ;then
011c77
 		$CMDCHANGE $ROUTE_WO_SRC || \