Skip to contentSkip to conversation

route: improve error message

PATCH Superseded Antonio Quartulli 2 participants 8 messages Jul 18, 2017 – Jul 20, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 route: improve error message

- fix typ0 in message: NLSMG -> NLMSG
- use strerror() to print a human readable message

---
 src/openvpn/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/route.c +1 -1
index 349b2c76..d556514e 100644
@@ -3445,7 +3445,7 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
         if (nh->nlmsg_type == NLMSG_ERROR)
         {
             struct nlmsgerr *ne = (struct nlmsgerr *)NLMSG_DATA(nh);
-            msg(M_WARN, "GDG6: NLSMG_ERROR: error %d\n", ne->error);
+            msg(M_WARN, "GDG6: NLMSG_ERROR: error %d\n", strerror(-ne->error));
             break;
         }
 
Signature · 1 line
2.13.3
#1 lore raw

PATCH v2 1/1 route: improve error message

- fix typ0 in message: NLSMG -> NLMSG
- use strerror() to print a human readable message

---

v2:
- change %d to %s (thanks Michael Shiels for catching this)

 src/openvpn/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/route.c +1 -1
index 349b2c76..9c33863c 100644
@@ -3445,7 +3445,7 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
         if (nh->nlmsg_type == NLMSG_ERROR)
         {
             struct nlmsgerr *ne = (struct nlmsgerr *)NLMSG_DATA(nh);
-            msg(M_WARN, "GDG6: NLSMG_ERROR: error %d\n", ne->error);
+            msg(M_WARN, "GDG6: NLMSG_ERROR: error %s\n", strerror(-ne->error));
             break;
         }
 
Signature · 1 line
2.13.3
#2 lore raw

Hi,

Quoted 2 lines · Antonio Quartulli

- fix typ0 in message: NLSMG -> NLMSG
- use strerror() to print a human readable message

Thanks. What about "not printing an error for ENETUNREACH", if that's the new "no error, but there is no such route"?

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#3 lore raw
Quoted 8 lines · Gert Doering

Hi,

Quoted 2 lines · Antonio Quartulli

- fix typ0 in message: NLSMG -> NLMSG
- use strerror() to print a human readable message

Thanks. What about "not printing an error for ENETUNREACH", if that's the new "no error, but there is no such route"?

I wanted to rework that in another patch, but yeah, I'll provide v3 including everything.

Cheers,

Signature · 1 line
Antonio Quartulli
#4 lore raw

PATCH v3 1/1 route: improve error message

- fix typ0 in message: NLSMG -> NLMSG
- use strerror() to print a human readable message
- don't print error message if error is ENETUNREACH: it means no route found

---

v2:
- change %d to %s (thanks Michael Shiels for catching this)

v3:
- don't print error when ENETUNREACH is returned

 src/openvpn/route.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
src/openvpn/route.c +6 -1
index 349b2c76..69f4fd6d 100644
@@ -3445,7 +3445,12 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
         if (nh->nlmsg_type == NLMSG_ERROR)
         {
             struct nlmsgerr *ne = (struct nlmsgerr *)NLMSG_DATA(nh);
-            msg(M_WARN, "GDG6: NLSMG_ERROR: error %d\n", ne->error);
+
+            /* since linux-4.11 -ENETUNREACH is returned when no route can be
+             * found. Don't print any error message in this case */
+            if (ne->error != -ENETUNREACH)
+                msg(M_WARN, "GDG6: NLMSG_ERROR: error %s\n",
+                    strerror(-ne->error));
             break;
         }
 
Signature · 1 line
2.13.3
#5 lore raw

PATCH v3 1/1 route: improve error message

- fix typ0 in message: NLSMG -> NLMSG
- use strerror() to print a human readable message
- don't print error message if error is ENETUNREACH: it means no route found

---

v2:
- change %d to %s (thanks Michael Shiels for catching this)

v3:
- don't print error when ENETUNREACH is returned

 src/openvpn/route.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
src/openvpn/route.c +6 -1
index 349b2c76..69f4fd6d 100644
@@ -3445,7 +3445,12 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
         if (nh->nlmsg_type == NLMSG_ERROR)
         {
             struct nlmsgerr *ne = (struct nlmsgerr *)NLMSG_DATA(nh);
-            msg(M_WARN, "GDG6: NLSMG_ERROR: error %d\n", ne->error);
+
+            /* since linux-4.11 -ENETUNREACH is returned when no route can be
+             * found. Don't print any error message in this case */
+            if (ne->error != -ENETUNREACH)
+                msg(M_WARN, "GDG6: NLMSG_ERROR: error %s\n",
+                    strerror(-ne->error));
             break;
         }
 
Signature · 1 line
2.13.3
#6 lore raw

PATCH v4 1/1 route: improve error message

- fix typ0 in message: NLSMG -> NLMSG
- use strerror() to print a human readable message
- don't print error message if error is ENETUNREACH: it means no route found

---

v2:
- change %d to %s (thanks Michael Shiels for catching this)

v3:
- don't print error when ENETUNREACH is returned

v4:
- put { } around if block

 src/openvpn/route.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
src/openvpn/route.c +8 -1
index 349b2c76..5994cdca 100644
@@ -3445,7 +3445,14 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
         if (nh->nlmsg_type == NLMSG_ERROR)
         {
             struct nlmsgerr *ne = (struct nlmsgerr *)NLMSG_DATA(nh);
-            msg(M_WARN, "GDG6: NLSMG_ERROR: error %d\n", ne->error);
+
+            /* since linux-4.11 -ENETUNREACH is returned when no route can be
+             * found. Don't print any error message in this case */
+            if (ne->error != -ENETUNREACH)
+            {
+                msg(M_WARN, "GDG6: NLMSG_ERROR: error %s\n",
+                    strerror(-ne->error));
+            }
             break;
         }
 
Signature · 1 line
2.13.3
#7 lore raw

ACK. Have no such recent Linux system around, but I trust you to have tested it - tested on older linuxes where it does not break anything, and the code looks reasonable.

Your patch has been applied to the master and release/2.4 branch.

commit 20d98427ef37e3b748dbcca2174cd243dcc963dc (master) commit f62720269db5299b8779780476c533fba00b354a (release/2.4)

Author: Antonio Quartulli
Date:   Thu Jul 20 16:23:38 2017 +0800
     route: improve error message

     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]/msg15101.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering