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

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