Don't call get_route recursively if a route's gateway matches the destination
authorTobias Brunner <tobias@strongswan.org>
Mon, 12 Nov 2012 16:12:18 +0000 (17:12 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 13 Nov 2012 08:06:02 +0000 (09:06 +0100)
src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c

index 8b8ab21..79ab35c 100644 (file)
@@ -1557,8 +1557,11 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
                        host_t *gtw;
 
                        gtw = host_create_from_chunk(msg->rtm_family, route->gtw, 0);
-                       route->src_host = get_route(this, gtw, FALSE, candidate);
-                       gtw->destroy(gtw);
+                       if (gtw && !gtw->ip_equals(gtw, dest))
+                       {
+                               route->src_host = get_route(this, gtw, FALSE, candidate);
+                       }
+                       DESTROY_IF(gtw);
                        if (route->src_host)
                        {       /* more of the same */
                                if (!candidate ||