From 1cf517bfc104c97a1eeb5a0f94becd0b8999ceaa Mon Sep 17 00:00:00 2001 From: Sebastien Vincent Date: Mon, 9 Jul 2018 21:35:57 +0200 Subject: [PATCH] Disables netlink RTA_METRICS exception. RTA_METRIC response processing is far more complex than just casting data to unsigned int. Data parameter is an array of rtattr. So to not block possible GNU/Linux distributions than can be impacted by exception, we disable it and set metric to 0 (as it is by default). --- libs/netlinkplus/src/manager.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libs/netlinkplus/src/manager.cpp b/libs/netlinkplus/src/manager.cpp index 554c1a20..874b8f5b 100644 --- a/libs/netlinkplus/src/manager.cpp +++ b/libs/netlinkplus/src/manager.cpp @@ -141,11 +141,18 @@ namespace netlinkplus } case RTA_METRICS: { - if (buffer_size(data) != sizeof(result.priority)) + if (buffer_size(data) != sizeof(result.metric)) { - throw boost::system::system_error(make_error_code(netlinkplus_error::invalid_route_metric)); + // On some old GNU/Linux distributions, it causes issues. + // In addition, RTA_METRICS processing is more complex than + // that (data should be an array of rtattr structures). + // So disable the exception from now. + //throw boost::system::system_error(make_error_code(netlinkplus_error::invalid_route_metric)); + result.metric = 0; + break; } + // TODO handle properly RTA_METRICS result.metric = *boost::asio::buffer_cast(data); break;