From: Antonio Quartulli Date: Thu, 20 Jul 2017 16:22:20 +0800 Message-Id: <20170720082220.31160-1-a@...2181...> In-Reply-To: <20170720081421.15894-1-a@...2181...> References: <20170720081421.15894-1-a@...2181...> Subject: [Openvpn-devel] [PATCH v3] route: improve error message List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: openvpn-devel@lists.sourceforge.net Cc: Antonio Quartulli - 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 Signed-off-by: Antonio Quartulli --- 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(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 349b2c76..69f4fd6d 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -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; } -- 2.13.3