From: Roy Marples Date: Wed, 23 Dec 2009 07:18:22 +0000 (+0000) Subject: Only warn about CSR when binding. X-Git-Tag: v5.1.4~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e90c590913662febcc501d94ff2b711d510b539d;p=thirdparty%2Fdhcpcd.git Only warn about CSR when binding. --- diff --git a/bind.c b/bind.c index 4fb683e4..40fc09e7 100644 --- 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 9f1ad7b6..7ccda877 100644 --- 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 c9ebfd25..3562a5a0 100644 --- 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 *); diff --git a/if-options.h b/if-options.h index 66fd69f2..bb2adae8 100644 --- a/if-options.h +++ b/if-options.h @@ -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[];