Blame SOURCES/bz2134539-IPsrcaddr-proto-metric-scope-default-route-fixes.patch

4491bb
From 237d55120a7c8d761f839c96651e722b3bb3bc88 Mon Sep 17 00:00:00 2001
4491bb
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
4491bb
Date: Wed, 12 Oct 2022 13:57:30 +0200
4491bb
Subject: [PATCH 1/4] IPsrcaddr: fix PROTO regex
4491bb
4491bb
---
4491bb
 heartbeat/IPsrcaddr | 2 +-
4491bb
 1 file changed, 1 insertion(+), 1 deletion(-)
4491bb
4491bb
diff --git a/heartbeat/IPsrcaddr b/heartbeat/IPsrcaddr
4491bb
index 7dbf65ff5..24406d296 100755
4491bb
--- a/heartbeat/IPsrcaddr
4491bb
+++ b/heartbeat/IPsrcaddr
4491bb
@@ -188,7 +188,7 @@ IPADDR="\($OCTET\.\)\{3\}$OCTET"
4491bb
 SRCCLAUSE="src$WS$WS*\($IPADDR\)"
4491bb
 MATCHROUTE="\(.*${WS}\)\($SRCCLAUSE\)\($WS.*\|$\)"
4491bb
 METRICCLAUSE=".*\(metric$WS[^ ]\+\)"
4491bb
-PROTOCLAUSE=".*\(proto$WS[^ ]\+\)"
4491bb
+PROTOCLAUSE=".*\(proto$WS[^ ]\+\).*"
4491bb
 FINDIF=findif
4491bb
 
4491bb
 # findif needs that to be set
4491bb
4491bb
From c70ba457851a401cb201cb87d23bdbc5f4fcd2b3 Mon Sep 17 00:00:00 2001
4491bb
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
4491bb
Date: Wed, 12 Oct 2022 14:00:30 +0200
4491bb
Subject: [PATCH 2/4] IPsrcaddr: detect metric for main table only, and allow
4491bb
 specifying metric if necessary
4491bb
4491bb
---
4491bb
 heartbeat/IPsrcaddr | 18 +++++++++++++++++-
4491bb
 1 file changed, 17 insertions(+), 1 deletion(-)
4491bb
4491bb
diff --git a/heartbeat/IPsrcaddr b/heartbeat/IPsrcaddr
4491bb
index 24406d296..4745eb8a7 100755
4491bb
--- a/heartbeat/IPsrcaddr
4491bb
+++ b/heartbeat/IPsrcaddr
4491bb
@@ -59,12 +59,14 @@ OCF_RESKEY_ipaddress_default=""
4491bb
 OCF_RESKEY_cidr_netmask_default=""
4491bb
 OCF_RESKEY_destination_default="0.0.0.0/0"
4491bb
 OCF_RESKEY_proto_default=""
4491bb
+OCF_RESKEY_metric_default=""
4491bb
 OCF_RESKEY_table_default=""
4491bb
 
4491bb
 : ${OCF_RESKEY_ipaddress=${OCF_RESKEY_ipaddress_default}}
4491bb
 : ${OCF_RESKEY_cidr_netmask=${OCF_RESKEY_cidr_netmask_default}}
4491bb
 : ${OCF_RESKEY_destination=${OCF_RESKEY_destination_default}}
4491bb
 : ${OCF_RESKEY_proto=${OCF_RESKEY_proto_default}}
4491bb
+: ${OCF_RESKEY_metric=${OCF_RESKEY_metric_default}}
4491bb
 : ${OCF_RESKEY_table=${OCF_RESKEY_table_default}}
4491bb
 #######################################################################
4491bb
 
4491bb
@@ -143,6 +145,14 @@ Proto to match when finding network. E.g. "kernel".
4491bb
 <content type="string" default="${OCF_RESKEY_proto_default}" />
4491bb
 </parameter>
4491bb
 
4491bb
+<parameter name="metric">
4491bb
+<longdesc lang="en">
4491bb
+Metric. Only needed if incorrect metric value is used.
4491bb
+</longdesc>
4491bb
+<shortdesc lang="en">Metric</shortdesc>
4491bb
+<content type="string" default="${OCF_RESKEY_metric_default}" />
4491bb
+</parameter>
4491bb
+
4491bb
 <parameter name="table">
4491bb
 <longdesc lang="en">
4491bb
 Table to modify. E.g. "local".
4491bb
@@ -548,8 +558,14 @@ rc=$?
4491bb
 
4491bb
 INTERFACE=`echo $findif_out | awk '{print $1}'`
4491bb
 LISTROUTE=`$IP2UTIL route list dev $INTERFACE scope link $PROTO match $ipaddress`
4491bb
-METRIC=`echo $LISTROUTE | sed -n "s/$METRICCLAUSE/\1/p"`
4491bb
 [ -z "$PROTO" ] && PROTO=`echo $LISTROUTE | sed -n "s/$PROTOCLAUSE/\1/p"`
4491bb
+if [ -n "$OCF_RESKEY_metric" ]; then
4491bb
+	METRIC="metric $OCF_RESKEY_metric"
4491bb
+elif [ -z "$TABLE" ] || [ "${TABLE#table }" = "main" ]; then
4491bb
+	METRIC=`echo $LISTROUTE | sed -n "s/$METRICCLAUSE/\1/p"`
4491bb
+else
4491bb
+	METRIC=""
4491bb
+fi
4491bb
 if [ "$OCF_RESKEY_destination" = "0.0.0.0/0" ] ;then
4491bb
 	NETWORK=`echo $LISTROUTE | grep -m 1 -o '^[^ ]*'`
4491bb
 
4491bb
4491bb
From c514f12f7a19440f475938f2a4659e5e9667fa25 Mon Sep 17 00:00:00 2001
4491bb
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
4491bb
Date: Wed, 12 Oct 2022 14:01:26 +0200
4491bb
Subject: [PATCH 3/4] IPsrcaddr: use scope host when using non-main tables
4491bb
4491bb
---
4491bb
 heartbeat/IPsrcaddr | 8 +++++++-
4491bb
 1 file changed, 7 insertions(+), 1 deletion(-)
4491bb
4491bb
diff --git a/heartbeat/IPsrcaddr b/heartbeat/IPsrcaddr
4491bb
index 4745eb8a7..926246008 100755
4491bb
--- a/heartbeat/IPsrcaddr
4491bb
+++ b/heartbeat/IPsrcaddr
4491bb
@@ -279,8 +279,14 @@ srca_stop() {
4491bb
 	  
4491bb
 	[ $rc = 2 ] && errorexit "The address you specified to stop does not match the preferred source address"
4491bb
 
4491bb
+	if [ -z "$TABLE" ] || [ "${TABLE#table }" = "main" ]; then
4491bb
+		SCOPE="link"
4491bb
+	else
4491bb
+		SCOPE="host"
4491bb
+	fi
4491bb
+
4491bb
 	PRIMARY_IP="$($IP2UTIL -4 -o addr show dev $INTERFACE primary | awk '{split($4,a,"/");print a[1]}')"
4491bb
-	OPTS="proto kernel scope link src $PRIMARY_IP"
4491bb
+	OPTS="proto kernel scope $SCOPE src $PRIMARY_IP"
4491bb
 
4491bb
 	$IP2UTIL route replace $TABLE $NETWORK dev $INTERFACE $OPTS $METRIC || \
4491bb
 		errorexit "command 'ip route replace $TABLE $NETWORK dev $INTERFACE $OPTS $METRIC' failed"
4491bb
4491bb
From 1f387ac8017b3eee23b41eadafd58ce21a29eb21 Mon Sep 17 00:00:00 2001
4491bb
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
4491bb
Date: Thu, 13 Oct 2022 13:11:28 +0200
4491bb
Subject: [PATCH 4/4] IPsrcaddr: fix monitor/status for default route not being
4491bb
 equal to src IP before start, and change route src correctly in stop-action
4491bb
4491bb
---
4491bb
 heartbeat/IPsrcaddr | 5 +++--
4491bb
 1 file changed, 3 insertions(+), 2 deletions(-)
4491bb
4491bb
diff --git a/heartbeat/IPsrcaddr b/heartbeat/IPsrcaddr
4491bb
index 926246008..1bd41a930 100755
4491bb
--- a/heartbeat/IPsrcaddr
4491bb
+++ b/heartbeat/IPsrcaddr
4491bb
@@ -229,6 +229,7 @@ srca_read() {
4491bb
 
4491bb
 	[ -z "$SRCIP" ] && return 1
4491bb
 	[ $SRCIP = $1 ] && return 0
4491bb
+	[ "$__OCF_ACTION" = "monitor" ] || [ "$__OCF_ACTION" = "status" ] && [ "${ROUTE%% *}" = "default" ] && return 1
4491bb
 	return 2
4491bb
 }
4491bb
 
4491bb
@@ -292,8 +293,8 @@ srca_stop() {
4491bb
 		errorexit "command 'ip route replace $TABLE $NETWORK dev $INTERFACE $OPTS $METRIC' failed"
4491bb
 
4491bb
 	if [ "$OCF_RESKEY_destination" = "0.0.0.0/0" ] ;then
4491bb
-		$CMDCHANGE $ROUTE_WO_SRC || \
4491bb
-			errorexit "command '$CMDCHANGE $ROUTE_WO_SRC' failed"
4491bb
+		$CMDCHANGE $ROUTE_WO_SRC src $PRIMARY_IP || \
4491bb
+			errorexit "command '$CMDCHANGE $ROUTE_WO_SRC src $PRIMARY_IP' failed"
4491bb
 	fi
4491bb
 
4491bb
 	return $?