kernel-netlink: Ignore local routes in any table
authorTobias Brunner <tobias@strongswan.org>
Mon, 26 Feb 2018 14:07:15 +0000 (15:07 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 28 Feb 2018 14:32:41 +0000 (15:32 +0100)
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

index ce3b9e0..931646a 100644 (file)
@@ -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;
                                }