From 2f5d6be5a026411e37c638e5aef730c7fc4f77af Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Mon, 26 Feb 2018 15:07:15 +0100 Subject: [PATCH] kernel-netlink: Ignore local routes in any table Such routes seem to show up in tables other than local with recent kernels. Fixes #2555. --- src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c b/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c index ce3b9e01f2..931646a814 100644 --- a/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c +++ b/src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c @@ -1797,7 +1797,7 @@ static void rt_entry_destroy(rt_entry_t *this) /** * Check if the route received with RTM_NEWROUTE is usable based on its type. */ -static bool route_usable(struct nlmsghdr *hdr) +static bool route_usable(struct nlmsghdr *hdr, bool allow_local) { struct rtmsg *msg; @@ -1809,6 +1809,8 @@ static bool route_usable(struct nlmsghdr *hdr) case RTN_PROHIBIT: case RTN_THROW: return FALSE; + case RTN_LOCAL: + return allow_local; default: return TRUE; } @@ -1984,7 +1986,7 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest, rt_entry_t *other; uintptr_t table; - if (!route_usable(current)) + if (!route_usable(current, TRUE)) { continue; } @@ -2258,7 +2260,7 @@ METHOD(enumerator_t, enumerate_subnets, bool, { rt_entry_t route; - if (!route_usable(this->current)) + if (!route_usable(this->current, FALSE)) { break; } -- 2.47.2