From: Roy Marples Date: Mon, 15 Feb 2016 21:19:56 +0000 (+0000) Subject: Export STATIC6 to libdhcpcd. X-Git-Tag: v6.10.2~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aafc7d05c869821038ec54de2a81cfd68b42575d;p=thirdparty%2Fdhcpcd.git Export STATIC6 to libdhcpcd. --- diff --git a/dhcpcd.c b/dhcpcd.c index 78e08196..23af13f7 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -1329,6 +1329,8 @@ dhcpcd_getinterfaces(void *arg) len++; if (IPV4LL_STATE_RUNNING(ifp)) len++; + if (IPV6_STATE_RUNNING(ifp)) + len++; if (RS_STATE_RUNNING(ifp)) len++; if (D6_STATE_RUNNING(ifp)) diff --git a/ipv6.c b/ipv6.c index 492f4b2e..8a6d011d 100644 --- a/ipv6.c +++ b/ipv6.c @@ -1382,6 +1382,25 @@ ipv6_env(char **env, const char *prefix, const struct interface *ifp) return n; } +int +ipv6_staticdadcompleted(const struct interface *ifp) +{ + const struct ipv6_state *state; + const struct ipv6_addr *ia; + int n; + + if ((state = IPV6_CSTATE(ifp)) == NULL) + return 0; + n = 0; +#define COMPLETED (IPV6_AF_STATIC | IPV6_AF_ADDED | IPV6_AF_DADCOMPLETED) + TAILQ_FOREACH(ia, &state->addrs, next) { + if ((ia->flags & COMPLETED) == COMPLETED && + !(ia->addr_flags & IN6_IFF_NOTUSEABLE)) + n++; + } + return n; +} + int ipv6_startstatic(struct interface *ifp) { diff --git a/ipv6.h b/ipv6.h index 952c1dcf..988ae701 100644 --- a/ipv6.h +++ b/ipv6.h @@ -218,6 +218,7 @@ struct ipv6_state { ((struct ipv6_state *)(ifp)->if_data[IF_DATA_IPV6]) #define IPV6_CSTATE(ifp) \ ((const struct ipv6_state *)(ifp)->if_data[IF_DATA_IPV6]) +#define IPV6_STATE_RUNNING(ifp) ipv6_staticdadcompleted((ifp)) /* dhcpcd requires CMSG_SPACE to evaluate to a compile time constant. */ #ifdef __QNX__ @@ -310,6 +311,7 @@ void ipv6_addtempaddrs(struct interface *, const struct timespec *); #endif int ipv6_start(struct interface *); +int ipv6_staticdadcompleted(const struct interface *); int ipv6_startstatic(struct interface *); ssize_t ipv6_env(char **, const char *, const struct interface *); void ipv6_ctxfree(struct dhcpcd_ctx *); @@ -321,6 +323,7 @@ void ipv6_buildroutes(struct dhcpcd_ctx *); #define ipv6_init(a) (NULL) #define ipv6_start(a) (-1) #define ipv6_startstatic(a) +#define ipv6_staticdadcompleted(a) (0) #define ipv6_hasaddr(a) (0) #define ipv6_free_ll_callbacks(a) {} #define ipv6_free(a) {} diff --git a/script.c b/script.c index 7fb3db6e..195da697 100644 --- a/script.c +++ b/script.c @@ -356,20 +356,13 @@ make_env(const struct interface *ifp, const char *reason, char ***argv) { env[9] = strdup("if_up=false"); env[10] = strdup("if_down=false"); -#ifdef INET6 - } else if (strcmp(reason, "STATIC6") == 0) { - /* For the time being, a static IPv6 address is does not qualify - * the interface to be up. - * Should we consider the presence of a static DNS server? */ - env[9] = strdup("if_up=false"); - env[10] = strdup("if_down=false"); -#endif } else if (1 == 2 /* appease ifdefs */ #ifdef INET || (dhcp && state && state->new) || (ipv4ll && IPV4LL_STATE_RUNNING(ifp)) #endif #ifdef INET6 + || (static6 && IPV6_STATE_RUNNING(ifp)) || (dhcp6 && d6_state && d6_state->new) || (ra && ipv6nd_hasra(ifp)) #endif @@ -644,6 +637,10 @@ send_interface(struct fd_list *fd, const struct interface *ifp) #endif #ifdef INET6 + if (IPV6_STATE_RUNNING(ifp)) { + if (send_interface1(fd, ifp, "STATIC6") == -1) + retval = -1; + } if (RS_STATE_RUNNING(ifp)) { if (send_interface1(fd, ifp, "ROUTERADVERT") == -1) retval = -1;