From: Roy Marples Date: Wed, 14 Nov 2012 10:31:25 +0000 (+0000) Subject: If we receive >1 MTU option, last one takes precendence. X-Git-Tag: v5.6.3~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8d26e9d7b4019a73aa28acc94a8f03e4c0c3781;p=thirdparty%2Fdhcpcd.git If we receive >1 MTU option, last one takes precendence. --- diff --git a/ipv6rs.c b/ipv6rs.c index 0972ffde..e97fb064 100644 --- a/ipv6rs.c +++ b/ipv6rs.c @@ -613,8 +613,7 @@ ipv6rs_handledata(_unused void *arg) ifp->name, mtuv); break; } - if (rap->mtu == 0 || mtuv < rap->mtu) - rap->mtu = mtuv; + rap->mtu = mtuv; snprintf(buf, sizeof(buf), "%d", mtuv); opt = xstrdup(buf); break; @@ -790,6 +789,7 @@ ssize_t ipv6rs_env(char **env, const char *prefix, const struct interface *ifp) { ssize_t l; + size_t len; struct timeval now; const struct ra *rap; const struct ra_opt *rao; @@ -800,7 +800,6 @@ ipv6rs_env(char **env, const char *prefix, const struct interface *ifp) i = 0; l = 0; - pref = rdnss = dnssl = NULL; get_monotonic(&now); TAILQ_FOREACH(rap, &ipv6_routers, next) { i++; @@ -813,10 +812,12 @@ ipv6rs_env(char **env, const char *prefix, const struct interface *ifp) } l++; + pref = mtu = rdnss = dnssl = NULL; TAILQ_FOREACH(rao, &rap->options, next) { if (rao->option == NULL) continue; - switch (rao->type) { + var = NULL; + switch(rao->type) { case ND_OPT_PREFIX_INFORMATION: optn = "prefix"; var = &pref; @@ -840,6 +841,30 @@ ipv6rs_env(char **env, const char *prefix, const struct interface *ifp) *var = env ? env : &new; l++; } else if (env) { + /* With single only options, last one takes + * precedence */ + if (rao->type == ND_OPT_MTU) { + new = strchr(**var, '='); + if (new == NULL) { + syslog(LOG_ERR, "new is null"); + continue; + } else + new++; + len = (new - **var) + strlen(rao->option) + 1; + if (len > strlen(**var)) + new = realloc(**var, len); + else + new = **var; + if (new) { + **var = new; + new = strchr(**var, '='); + if (new) + strcpy(new + 1, rao->option); + else + syslog(LOG_ERR, "new is null"); + } + continue; + } new = realloc(**var, strlen(**var) + 1 + strlen(rao->option) + 1);