]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Ensure that nooption correctly woks for routes.
authorRoy Marples <roy@marples.name>
Mon, 28 Jan 2013 09:47:40 +0000 (09:47 +0000)
committerRoy Marples <roy@marples.name>
Mon, 28 Jan 2013 09:47:40 +0000 (09:47 +0000)
configure.c
dhcp.c
dhcp.h

index 8003507acdfea1939ad976ca3fdd21943ab212d2..8325707ae213cea655bb917ee21cbf5370e28b0f 100644 (file)
@@ -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 ca564fcb3856dfec6f22c04416b66cb3dfc7a18c..7b678d5a2270989e4359dc666f348876a472ded9 100644 (file)
--- 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 2d8dcea9196294bc16fc7294dc1dbda8f31d35d9..ea6a86e088ff1c2e330ce5205691ce8b2502d9c3 100644 (file)
--- 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 *,