route: improve error message
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
@@ -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
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
@@ -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
Hi,
Quoted 2 lines · Antonio Quartulli
- fix typ0 in message: NLSMG -> NLMSG
- usestrerror()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]...Quoted 8 lines · Gert Doering
Hi,
Quoted 2 lines · Antonio Quartulli
- fix typ0 in message: NLSMG -> NLMSG
- usestrerror()to print a human readable messageThanks. 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
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
@@ -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
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
@@ -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
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
@@ -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
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