]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Only warn about CSR when binding.
authorRoy Marples <roy@marples.name>
Wed, 23 Dec 2009 07:18:22 +0000 (07:18 +0000)
committerRoy Marples <roy@marples.name>
Wed, 23 Dec 2009 07:18:22 +0000 (07:18 +0000)
bind.c
dhcp.c
dhcp.h
if-options.h

diff --git a/bind.c b/bind.c
index 4fb683e4d818be1eeb21b82545c5c080dd01d3fb..40fc09e774914a90be793f5e9f7c69e445e9a9cd 100644 (file)
--- a/bind.c
+++ b/bind.c
@@ -222,6 +222,7 @@ bind_interface(void *arg)
                add_timeout_sec(lease->rebindtime, start_rebind, iface);
                add_timeout_sec(lease->leasetime, start_expire, iface);
        }
+       ifo->options &= ~ DHCPCD_CSR_WARNED;
        configure(iface);
        daemonise();
        state->state = DHS_BOUND;
diff --git a/dhcp.c b/dhcp.c
index 9f1ad7b61e9d87c186f24f280e8518f17696c42c..7ccda877c4ab53fbbc912ab4ce9cee312f171c2d 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -70,7 +70,7 @@ static const struct dhcp_opt const dhcp_opts[] = {
        { 1,    IPV4 | REQUEST, "subnet_mask" },
                /* RFC 3442 states that the CSR has to come before all other
                 * routes. For completeness, we also specify static routes,
-                * then routers. */
+                * then routers. */
        { 121,  RFC3442,        "classless_static_routes" },
        { 249,  RFC3442,        "ms_classless_static_routes" },
        { 33,   IPV4 | ARRAY | REQUEST, "static_routes" },
@@ -701,7 +701,8 @@ 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 char *ifname, const struct dhcp_message *dhcp)
+get_option_routes(const struct dhcp_message *dhcp,
+    const char *ifname, int *opts)
 {
        const uint8_t *p;
        const uint8_t *e;
@@ -716,10 +717,11 @@ get_option_routes(const char *ifname, const struct dhcp_message *dhcp)
                p = get_option(dhcp, DHO_MSCSR, &len, NULL);
        if (p) {
                routes = decode_rfc3442_rt(len, p);
-               if (routes) {
+               if (routes && !(*opts & DHCPCD_CSR_WARNED)) {
                        syslog(LOG_DEBUG,
                            "%s: using Classless Static Routes (RFC3442)",
                            ifname);
+                       *opts |= DHCPCD_CSR_WARNED;
                        return routes;
                }
        }
@@ -788,12 +790,12 @@ encode_rfc1035(const char *src, uint8_t *dst)
        return p - dst;
 }
 
-#define PUTADDR(_type, _val)                                           \
-       {                                                               \
-               *p++ = _type;                                           \
-               *p++ = 4;                                               \
-               memcpy(p, &_val.s_addr, 4);                             \
-               p += 4;                                                 \
+#define PUTADDR(_type, _val)                                                 \
+       {                                                                     \
+               *p++ = _type;                                                 \
+               *p++ = 4;                                                     \
+               memcpy(p, &_val.s_addr, 4);                                   \
+               p += 4;                                                       \
        }
 
 int
@@ -1138,7 +1140,7 @@ print_string(char *s, ssize_t len, int dl, const uint8_t *data)
                case '\'': /* FALLTHROUGH */
                case '$':  /* FALLTHROUGH */
                case '`':  /* FALLTHROUGH */
-               case '\\': /* FALLTHROUGH */
+               case '\\':
                        if (s) {
                                if (len < 3) {
                                        errno = ENOBUFS;
diff --git a/dhcp.h b/dhcp.h
index c9ebfd25aa0c4f2984a28c745537e7e78dae5a03..3562a5a02b530fd52a2f5bb4f1f1e36c0b920612 100644 (file)
--- a/dhcp.h
+++ b/dhcp.h
@@ -184,7 +184,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 char *, const struct dhcp_message *);
+struct rt *get_option_routes(const struct dhcp_message *, const char *, int *);
 ssize_t configure_env(char **, const char *, const struct dhcp_message *,
     const struct if_options *);
 
index 66fd69f24ad489e7ab29f7ac9bfffb0c6251f2ee..bb2adae87d64165da32b0baf1fcda92136730237 100644 (file)
@@ -73,6 +73,7 @@
 #define DHCPCD_TIMEOUT_IPV4LL  (1 << 24)
 #define DHCPCD_WAITIP          (1 << 25)
 #define DHCPCD_WAITUP          (1 << 26)
+#define DHCPCD_CSR_WARNED      (1 << 27)
 
 extern const struct option cf_options[];