Check routes with equal prefix if preferred source is specified
authorTobias Brunner <tobias@strongswan.org>
Fri, 30 Sep 2011 15:41:01 +0000 (17:41 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 21 Sep 2012 16:16:25 +0000 (18:16 +0200)
src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c

index 73d7ed2..9d82a4e 100644 (file)
@@ -1236,8 +1236,10 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
                                        }
                                        rta = RTA_NEXT(rta, rtasize);
                                }
                                        }
                                        rta = RTA_NEXT(rta, rtasize);
                                }
-                               if (msg->rtm_dst_len <= best)
-                               {       /* not better than a previous one */
+                               if (msg->rtm_dst_len < best ||
+                                       msg->rtm_dst_len == best && (nexthop || !candidate))
+                               {       /* not better than a previous one, but if a preferred source
+                                        * address is specified, we still check equal routes */
                                        continue;
                                }
                                enumerator = this->rt_exclude->create_enumerator(this->rt_exclude);
                                        continue;
                                }
                                enumerator = this->rt_exclude->create_enumerator(this->rt_exclude);