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

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