Skip to contentSkip to conversation

sitnl: fix failure reporting by keeping error negative

PATCH In review Antonio Quartulli 2 participants 2 messages Apr 18, 2020 – Apr 19, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sitnl: fix failure reporting by keeping error negative

The err->errno value reported by netlink is already negative.

Prepending ierr->errno with '-' when forwarding it to the caller results in a positive value and thus not detected as error.

Fix error handling in sitnl by not negating the sign of the value returned by sitnl_send() in case of generic error.

While at it, print the errno in decimal form along with its string represenation.

---
 src/openvpn/networking_sitnl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
src/openvpn/networking_sitnl.c +3 -3
index b93697e9..7adcb64c 100644
@@ -365,9 +365,9 @@ sitnl_send(struct nlmsghdr *payload, pid_t peer, unsigned int groups,
                     }
                     else
                     {
-                        msg(M_WARN, "%s: rtnl: generic error: %s",
-                            __func__, strerror(-err->error));
-                        ret = -err->error;
+                        msg(M_WARN, "%s: rtnl: generic error (%d): %s",
+                            __func__, err->error, strerror(-err->error));
+                        ret = err->error;
                     }
                 }
                 goto out;
Signature · 1 line
2.26.1
Acked-by on v1 1/1
#1 lore raw

"Does what it says on the tin, and makes sense".

Your patch has been applied to the master branch.

commit 74fadcf4ebe860c15d12cb4e065c7ca0e0dc4497

Author: Antonio Quartulli
Date:   Sat Apr 18 03:18:49 2020 +0200
     sitnl: fix failure reporting by keeping error negative

     Signed-off-by: Antonio Quartulli <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg19773.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering