]> 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:45:05 +0000 (09:45 +0000)
committerRoy Marples <roy@marples.name>
Mon, 28 Jan 2013 09:45:05 +0000 (09:45 +0000)
configure.c
dhcp.c
dhcp.h

index 7d8475d245caaaecb0031d592dc558d28d5d145b..01b0d861cb1b21a0d62b8ac067cc67f4c42f0c43 100644 (file)
@@ -636,7 +636,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;
 
@@ -659,8 +659,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
@@ -750,7 +749,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 b27e0a2172a1b89ee86d4ac0c591b0e2276ddef9..5c7199872bd938547cf5a186e7acc336383c9f41 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -751,9 +751,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;
@@ -761,25 +761,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) {
@@ -798,7 +802,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 64a5ff82d0e6a581e3430b6929268ac3e82963b3..c0ddaa92323667fbabbce31f244a85b2180d84f5 100644 (file)
--- a/dhcp.h
+++ b/dhcp.h
@@ -214,8 +214,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 print_option(char *, ssize_t, int, int, const uint8_t *, const char *);