summaryrefslogtreecommitdiffhomepage
path: root/interface-ip.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-06-18 23:19:27 +0200
committerFelix Fietkau <nbd@openwrt.org>2012-06-18 23:19:27 +0200
commit88ae5a835d1c3184410f3023fc637d02bd58611e (patch)
tree03aa37932d95bf13830c18a55bce35fd9848259a /interface-ip.c
parent44c23888ad36a340ed6314728e073873240fcf0d (diff)
add support for defaultroute "host" dependencies
Diffstat (limited to 'interface-ip.c')
-rw-r--r--interface-ip.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/interface-ip.c b/interface-ip.c
index 6699d2e..d8d8606 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -141,6 +141,8 @@ interface_ip_add_target_route(union if_addr *addr, bool v6)
{
struct interface *iface;
struct device_route *route, *r_next = NULL;
+ bool defaultroute_target = false;
+ int addrsize = v6 ? sizeof(addr->in6) : sizeof(addr->in);
route = calloc(1, sizeof(*route));
if (!route)
@@ -148,7 +150,10 @@ interface_ip_add_target_route(union if_addr *addr, bool v6)
route->flags = v6 ? DEVADDR_INET6 : DEVADDR_INET4;
route->mask = v6 ? 128 : 32;
- memcpy(&route->addr, addr, v6 ? sizeof(addr->in6) : sizeof(addr->in));
+ if (memcmp(&route->addr, addr, addrsize) == 0)
+ defaultroute_target = true;
+ else
+ memcpy(&route->addr, addr, addrsize);
vlist_for_each_element(&interfaces, iface, node) {
/* look for locally addressable target first */
@@ -172,7 +177,10 @@ interface_ip_add_target_route(union if_addr *addr, bool v6)
done:
route->iface = iface;
- vlist_add(&iface->host_routes, &route->node, &route->flags);
+ if (defaultroute_target)
+ free(route);
+ else
+ vlist_add(&iface->host_routes, &route->node, &route->flags);
return iface;
}