summaryrefslogtreecommitdiffhomepage
path: root/interface-ip.c
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2013-05-13 10:55:01 +0200
committerSteven Barth <steven@midlink.org>2013-05-13 10:55:01 +0200
commit570302d28d18d47f095f864be161045e169b5941 (patch)
tree186fc425d49a6fcc25075d4d517df43f466248ab /interface-ip.c
parent3b8673edadc8ce6d1d90c12e6b8e57eeb291c521 (diff)
Add support for IPv6 and interface target-routes & dependencies
Signed-off-by: Steven Barth <steven@midlink.org>
Diffstat (limited to 'interface-ip.c')
-rw-r--r--interface-ip.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/interface-ip.c b/interface-ip.c
index e0bcdc0..31842c4 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -170,9 +170,8 @@ interface_ip_find_route_target(struct interface *iface, union if_addr *a,
}
struct interface *
-interface_ip_add_target_route(union if_addr *addr, bool v6)
+interface_ip_add_target_route(union if_addr *addr, bool v6, struct interface *iface)
{
- struct interface *iface;
struct device_route *route, *r_next = NULL;
bool defaultroute_target = false;
int addrsize = v6 ? sizeof(addr->in6) : sizeof(addr->in);
@@ -188,7 +187,7 @@ interface_ip_add_target_route(union if_addr *addr, bool v6)
else
memcpy(&route->addr, addr, addrsize);
- vlist_for_each_element(&interfaces, iface, node) {
+ if (iface) {
/* look for locally addressable target first */
if (interface_ip_find_addr_target(iface, addr, v6))
goto done;
@@ -196,6 +195,16 @@ interface_ip_add_target_route(union if_addr *addr, bool v6)
/* do not stop at the first route, let the lookup compare
* masks to find the best match */
interface_ip_find_route_target(iface, addr, v6, &r_next);
+ } else {
+ vlist_for_each_element(&interfaces, iface, node) {
+ /* look for locally addressable target first */
+ if (interface_ip_find_addr_target(iface, addr, v6))
+ goto done;
+
+ /* do not stop at the first route, let the lookup compare
+ * masks to find the best match */
+ interface_ip_find_route_target(iface, addr, v6, &r_next);
+ }
}
if (!r_next) {