From: Roy Marples Date: Mon, 24 Nov 2008 22:30:41 +0000 (+0000) Subject: Don't manipulate subnet routes when they are INADDR_BROADCAST as they don't exist. X-Git-Tag: v5.0.0~167 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a3c791b7a2b963d7b0a2220fc79041f8945cfa6;p=thirdparty%2Fdhcpcd.git Don't manipulate subnet routes when they are INADDR_BROADCAST as they don't exist. --- 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;