Blame SOURCES/bz2055016-2-IPsrcaddr-error-message-route-not-found.patch

15568e
From 5a65f66ff803ad7ed15af958cc1efdde4d53dcb7 Mon Sep 17 00:00:00 2001
15568e
From: Reid Wahl <nrwahl@protonmail.com>
15568e
Date: Thu, 17 Feb 2022 03:53:21 -0800
15568e
Subject: [PATCH] IPsrcaddr: Better error message when no matching route found
15568e
15568e
If OCF_RESKEY_destination is not explicitly set and `ip route list`
15568e
can't find a route matching the specifications, the NETWORK variable
15568e
doesn't get set. This causes a certain failure of the start operation,
15568e
because there is no PREFIX argument to `ip route replace` (syntax
15568e
error). It may also cause unexpected behavior for stop operations (but
15568e
not in all cases). During a monitor, this event can only happen if
15568e
something has changed outside the cluster's control, and so is cause
15568e
for warning there.
15568e
15568e
Exit OCF_ERR_ARGS for start, log debug for probe, log warning for all
15568e
other ops.
15568e
15568e
Resolves: RHBZ#1654862
15568e
15568e
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
15568e
---
15568e
 heartbeat/IPsrcaddr | 14 ++++++++++++++
15568e
 1 file changed, 14 insertions(+)
15568e
15568e
diff --git a/heartbeat/IPsrcaddr b/heartbeat/IPsrcaddr
15568e
index fd7b6f68d..f0216722d 100755
15568e
--- a/heartbeat/IPsrcaddr
15568e
+++ b/heartbeat/IPsrcaddr
15568e
@@ -549,6 +549,20 @@ rc=$?
15568e
 INTERFACE=`echo $findif_out | awk '{print $1}'`
15568e
 if [ "$OCF_RESKEY_destination" = "0.0.0.0/0" ] ;then
15568e
 	NETWORK=`$IP2UTIL route list dev $INTERFACE scope link $PROTO match $ipaddress|grep -m 1 -o '^[^ ]*'`
15568e
+
15568e
+    if [ -z "$NETWORK" ]; then
15568e
+        err_str="command '$IP2UTIL route list dev $INTERFACE scope link $PROTO"
15568e
+        err_str="$err_str match $ipaddress' failed to find a matching route"
15568e
+
15568e
+        if [ "$__OCF_ACTION" = "start" ]; then
15568e
+            ocf_exit_reason "$err_str"
15568e
+            exit $OCF_ERR_ARGS
15568e
+        elif ! ocf_is_probe; then
15568e
+            ocf_log warn "$err_str"
15568e
+        else
15568e
+            ocf_log debug "$err_str"
15568e
+        fi
15568e
+    fi
15568e
 else
15568e
 	NETWORK="$OCF_RESKEY_destination"
15568e
 fi