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

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