summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2013-01-28 09:47:40 +0000
committerRoy Marples <roy@marples.name>2013-01-28 09:47:40 +0000
commitae57bef8b0ae537ae201eb4053016ee631830773 (patch)
tree6bdd81a2c1952eef95aff9bb587498cec77063b3
parent90eef833b7a116ca62ac72c6a0a9e825b09eacae (diff)
downloaddhcpcd-ae57bef8b0ae537ae201eb4053016ee631830773.tar.xz
Ensure that nooption correctly woks for routes.
-rw-r--r--configure.c7
-rw-r--r--dhcp.c25
-rw-r--r--dhcp.h3
3 files changed, 20 insertions, 15 deletions
diff --git a/configure.c b/configure.c
index 8003507a..8325707a 100644
--- a/configure.c
+++ b/configure.c
@@ -573,7 +573,7 @@ add_subnet_route(struct rt *rt, const struct interface *iface)
}
static struct rt *
-get_routes(const struct interface *iface)
+get_routes(struct interface *iface)
{
struct rt *rt, *nrt = NULL, *r = NULL;
@@ -596,8 +596,7 @@ get_routes(const struct interface *iface)
return nrt;
}
- return get_option_routes(iface->state->new,
- iface->name, &iface->state->options->options);
+ return get_option_routes(iface, iface->state->new);
}
/* Some DHCP servers add set host routes by setting the gateway
@@ -687,7 +686,7 @@ void
build_routes(void)
{
struct rt *nrs = NULL, *dnr, *or, *rt, *rtn, *rtl, *lrt = NULL;
- const struct interface *ifp;
+ struct interface *ifp;
for (ifp = ifaces; ifp; ifp = ifp->next) {
if (ifp->state->new == NULL)
diff --git a/dhcp.c b/dhcp.c
index ca564fcb..7b678d5a 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -789,9 +789,9 @@ route_netmask(uint32_t ip_in)
* If we have a CSR then we only use that.
* Otherwise we add static routes and then routers. */
struct rt *
-get_option_routes(const struct dhcp_message *dhcp,
- const char *ifname, unsigned long long *opts)
+get_option_routes(struct interface *ifp, const struct dhcp_message *dhcp)
{
+ struct if_options *ifo = ifp->state->options;
const uint8_t *p;
const uint8_t *e;
struct rt *routes = NULL;
@@ -799,25 +799,29 @@ get_option_routes(const struct dhcp_message *dhcp,
int len;
/* If we have CSR's then we MUST use these only */
- p = get_option(dhcp, DHO_CSR, &len, NULL);
+ if (!has_option_mask(ifo->nomask, DHO_CSR))
+ p = get_option(dhcp, DHO_CSR, &len, NULL);
+ else
+ p = NULL;
/* Check for crappy MS option */
- if (!p)
+ if (!p && !has_option_mask(ifo->nomask, DHO_MSCSR))
p = get_option(dhcp, DHO_MSCSR, &len, NULL);
if (p) {
routes = decode_rfc3442_rt(len, p);
if (routes) {
- if (!(*opts & DHCPCD_CSR_WARNED)) {
+ if (!(ifo->options & DHCPCD_CSR_WARNED)) {
syslog(LOG_DEBUG,
"%s: using Classless Static Routes",
- ifname);
- *opts |= DHCPCD_CSR_WARNED;
+ ifp->name);
+ ifo->options |= DHCPCD_CSR_WARNED;
}
return routes;
}
}
/* OK, get our static routes first. */
- p = get_option(dhcp, DHO_STATICROUTE, &len, NULL);
+ if (!has_option_mask(ifo->nomask, DHO_STATICROUTE))
+ p = get_option(dhcp, DHO_STATICROUTE, &len, NULL);
if (p) {
e = p + len;
while (p < e) {
@@ -836,7 +840,10 @@ get_option_routes(const struct dhcp_message *dhcp,
}
/* Now grab our routers */
- p = get_option(dhcp, DHO_ROUTER, &len, NULL);
+ if (!has_option_mask(ifo->nomask, DHO_ROUTER))
+ p = get_option(dhcp, DHO_ROUTER, &len, NULL);
+ else
+ p = NULL;
if (p) {
e = p + len;
while (p < e) {
diff --git a/dhcp.h b/dhcp.h
index 2d8dcea9..ea6a86e0 100644
--- a/dhcp.h
+++ b/dhcp.h
@@ -186,8 +186,7 @@ int get_option_uint8(uint8_t *, const struct dhcp_message *, uint8_t);
#define is_bootp(m) (m && \
!IN_LINKLOCAL(htonl((m)->yiaddr)) && \
get_option_uint8(NULL, m, DHO_MESSAGETYPE) == -1)
-struct rt *get_option_routes(const struct dhcp_message *, const char *,
- unsigned long long *);
+struct rt *get_option_routes(struct interface *, const struct dhcp_message *);
ssize_t decode_rfc3397(char *, ssize_t, int, const uint8_t *);
ssize_t print_string(char *, ssize_t, int, const uint8_t *);
ssize_t configure_env(char **, const char *, const struct dhcp_message *,