Browse code

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

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20170720082338.1302-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15101.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Antonio Quartulli authored on 2017/07/20 17:23:38
Showing 1 changed files
... ...
@@ -3441,7 +3441,14 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
3441 3441
         if (nh->nlmsg_type == NLMSG_ERROR)
3442 3442
         {
3443 3443
             struct nlmsgerr *ne = (struct nlmsgerr *)NLMSG_DATA(nh);
3444
-            msg(M_WARN, "GDG6: NLSMG_ERROR: error %d\n", ne->error);
3444
+
3445
+            /* since linux-4.11 -ENETUNREACH is returned when no route can be
3446
+             * found. Don't print any error message in this case */
3447
+            if (ne->error != -ENETUNREACH)
3448
+            {
3449
+                msg(M_WARN, "GDG6: NLMSG_ERROR: error %s\n",
3450
+                    strerror(-ne->error));
3451
+            }
3445 3452
             break;
3446 3453
         }
3447 3454