diff options
| author | Roy Marples <roy@marples.name> | 2008-11-24 22:30:41 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2008-11-24 22:30:41 +0000 |
| commit | 3a3c791b7a2b963d7b0a2220fc79041f8945cfa6 (patch) | |
| tree | 4c8c88d864075f94d3ed17b39a676a77b8896e92 /configure.c | |
| parent | 95a12dde2a813eeb921499df6b64d56e4adf01ba (diff) | |
| download | dhcpcd-3a3c791b7a2b963d7b0a2220fc79041f8945cfa6.tar.xz | |
Don't manipulate subnet routes when they are INADDR_BROADCAST as they don't exist.
Diffstat (limited to 'configure.c')
| -rw-r--r-- | configure.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/configure.c b/configure.c index 09b59dfe..768aa964 100644 --- a/configure.c +++ b/configure.c @@ -301,8 +301,13 @@ d_route(struct rt *rt, const struct interface *iface, int metric) static struct rt * add_subnet_route(struct rt *rt, const struct interface *iface) { - struct rt *r = xmalloc(sizeof(*r)); + struct rt *r; + /* We don't have subnet routes with host masks */ + if (iface->net.s_addr == INADDR_BROADCAST) + return rt; + + r = xmalloc(sizeof(*r)); r->dest.s_addr = iface->addr.s_addr & iface->net.s_addr; r->net.s_addr = iface->net.s_addr; r->gate.s_addr = 0; @@ -493,15 +498,16 @@ configure(struct interface *iface, const char *reason) /* We need to delete the subnet route to have our metric or * prefer the interface. */ + if (iface->net.s_addr != INADDR_BROADCAST) { #if HAVE_ROUTE_METRIC - if (iface->metric > 0 && - (rt.net.s_addr != iface->net.s_addr || - rt.dest.s_addr != (iface->addr.s_addr & iface->net.s_addr))) - del_route(iface, &rt.dest, &rt.net, &rt.gate, 0); + if (iface->metric > 0 && + (rt.net.s_addr != iface->net.s_addr || + rt.dest.s_addr !=(iface->addr.s_addr & iface->net.s_addr))) #else - if (!find_route(routes, &rt, NULL, NULL)) - del_route(iface, &rt.dest, &rt.net, &rt.gate, 0); + if (!find_route(routes, &rt, NULL, NULL)) #endif + del_route(iface, &rt.dest, &rt.net, &rt.gate, 0); + } iface->addr.s_addr = addr.s_addr; iface->net.s_addr = net.s_addr; |
