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

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