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

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