summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-03-05 16:31:05 +0000
committerRoy Marples <roy@marples.name>2009-03-05 16:31:05 +0000
commit90bf8aef219963ebaa215a0de1a0fe6441e683b8 (patch)
treebad9f52a06323cc575a2fc6185be9e95069b176d
parent746e44f9c2425916efb61485ae22cf67b9a38408 (diff)
downloaddhcpcd-90bf8aef219963ebaa215a0de1a0fe6441e683b8.tar.xz
Don't add subnet routes to INADDR_ANY or those without a gateway.
-rw-r--r--configure.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/configure.c b/configure.c
index e2e6a272..f8120503 100644
--- a/configure.c
+++ b/configure.c
@@ -481,7 +481,7 @@ get_subnet_route(struct dhcp_message *dhcp)
/* Ensure we have all the needed values */
if (get_option_addr(&net, dhcp, DHO_SUBNETMASK) == -1)
net = get_netmask(addr);
- if (net == INADDR_BROADCAST)
+ if (net == INADDR_BROADCAST || net == INADDR_ANY)
return NULL;
rt = malloc(sizeof(*rt));
rt->dest.s_addr = addr & net;
@@ -495,8 +495,8 @@ add_subnet_route(struct rt *rt, const struct interface *iface)
{
struct rt *r;
- /* We don't have subnet routes with host masks */
- if (iface->net.s_addr == INADDR_BROADCAST)
+ if (iface->net.s_addr == INADDR_BROADCAST ||
+ iface->net.s_addr == INADDR_ANY)
return rt;
r = xmalloc(sizeof(*r));
@@ -509,13 +509,15 @@ add_subnet_route(struct rt *rt, const struct interface *iface)
static struct rt *
get_routes(const struct interface *iface) {
- struct rt *rt, *nrt, *r = NULL;
+ struct rt *rt, *nrt = NULL, *r = NULL;
if (iface->state->options->routes != NULL) {
for (rt = iface->state->options->routes;
rt != NULL;
rt = rt->next)
{
+ if (rt->gate.s_addr == 0)
+ break;
if (r == NULL)
r = nrt = xmalloc(sizeof(*r));
else {