From: Roy Marples Date: Tue, 9 May 2017 11:40:28 +0000 (+0100) Subject: Remove more prefix delegation code for small binaries. X-Git-Tag: v7.0.0-rc1~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=895a1ae3a1e2ab7d9e1724db2ce5e449c5c2eb26;p=thirdparty%2Fdhcpcd.git Remove more prefix delegation code for small binaries. --- diff --git a/src/dhcp6.c b/src/dhcp6.c index 7d9b20a8..f7505765 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -1353,7 +1353,11 @@ dhcp6_dadcallback(void *arg) { struct ipv6_addr *ap2; +#ifdef SMALL + valid = true; +#else valid = (ap->delegating_prefix == NULL); +#endif TAILQ_FOREACH(ap2, &state->addrs, next) { if (ap2->flags & IPV6_AF_ADDED && !(ap2->flags & IPV6_AF_DADCOMPLETED)) @@ -1366,8 +1370,10 @@ dhcp6_dadcallback(void *arg) logdebugx("%s: DHCPv6 DAD completed", ifp->name); script_runreason(ifp, - ap->delegating_prefix ? - "DELEGATED6" : state->reason); +#ifndef SMALL + ap->delegating_prefix ? "DELEGATED6" : +#endif + state->reason); if (valid) dhcpcd_daemonise(ifp->ctx); } @@ -2184,6 +2190,7 @@ dhcp6_deprecateaddrs(struct ipv6_addrhead *addrs) else continue; +#ifndef SMALL /* If we delegated from this prefix, deprecate or remove * the delegations. */ if (ia->flags & IPV6_AF_DELEGATEDPFX) { @@ -2204,6 +2211,7 @@ dhcp6_deprecateaddrs(struct ipv6_addrhead *addrs) if (touched) ipv6_addaddrs(&ia->pd_pfxs); } +#endif if (ia->flags & IPV6_AF_REQUEST) { ia->prefix_vltime = ia->prefix_pltime = 0; @@ -2548,9 +2556,12 @@ dhcp6_script_try_run(struct interface *ifp, int delegated) ipv6_iffindaddr(ap->iface, &ap->addr, IN6_IFF_TENTATIVE)) ap->flags |= IPV6_AF_DADCOMPLETED; - if ((ap->flags & IPV6_AF_DADCOMPLETED) == 0 && - ((delegated && ap->delegating_prefix) || - (!delegated && !ap->delegating_prefix))) + if ((ap->flags & IPV6_AF_DADCOMPLETED) == 0 +#ifndef SMALL + && ((delegated && ap->delegating_prefix) || + (!delegated && !ap->delegating_prefix)) +#endif + ) { completed = 0; break; @@ -3583,9 +3594,11 @@ dhcp6_env(char **env, const char *prefix, const struct interface *ifp, char *pfx; uint32_t en; const struct dhcpcd_ctx *ctx; +#ifndef SMALL const struct dhcp6_state *state; const struct ipv6_addr *ap; char *v, *val; +#endif n = 0; if (m == NULL) @@ -3686,6 +3699,7 @@ dhcp6_env(char **env, const char *prefix, const struct interface *ifp, free(pfx); delegated: +#ifndef SMALL /* Needed for Delegated Prefixes */ state = D6_CSTATE(ifp); i = 0; @@ -3717,6 +3731,7 @@ delegated: } if (i) n++; +#endif return (ssize_t)n; } diff --git a/src/ipv6.c b/src/ipv6.c index b4214883..bd385694 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -582,12 +582,16 @@ static void ipv6_deletedaddr(struct ipv6_addr *ia) { +#ifdef SMALL + UNUSED(ia); +#else /* NOREJECT is set if we delegated exactly the prefix to another * address. * This can only be one address, so just clear the flag. * This should ensure the reject route will be restored. */ if (ia->delegating_prefix != NULL) ia->delegating_prefix->flags &= ~IPV6_AF_NOREJECT; +#endif } static void @@ -723,8 +727,10 @@ ipv6_addaddr1(struct ipv6_addr *ap, const struct timespec *now) ap->flags &= ~IPV6_AF_NEW; ap->flags |= IPV6_AF_ADDED; +#ifndef SMALL if (ap->delegating_prefix != NULL) ap->flags |= IPV6_AF_DELEGATED; +#endif #ifdef IPV6_POLLADDRFLAG eloop_timeout_delete(ap->iface->ctx->eloop, @@ -948,6 +954,7 @@ ipv6_addaddrs(struct ipv6_addrhead *addrs) void ipv6_freeaddr(struct ipv6_addr *ap) { +#ifndef SMALL struct ipv6_addr *ia; /* Forget the reference */ @@ -958,6 +965,7 @@ ipv6_freeaddr(struct ipv6_addr *ap) } else if (ap->delegating_prefix != NULL) { TAILQ_REMOVE(&ap->delegating_prefix->pd_pfxs, ap, pd_next); } +#endif eloop_q_timeout_delete(ap->iface->ctx->eloop, 0, NULL, ap); free(ap); @@ -970,12 +978,17 @@ ipv6_freedrop_addrs(struct ipv6_addrhead *addrs, int drop, struct ipv6_addr *ap, *apn, *apf; struct timespec now; +#ifdef SMALL + UNUSED(ifd); +#endif timespecclear(&now); TAILQ_FOREACH_SAFE(ap, addrs, next, apn) { +#ifndef SMALL if (ifd != NULL && (ap->delegating_prefix == NULL || ap->delegating_prefix->iface != ifd)) continue; +#endif if (drop != 2) TAILQ_REMOVE(addrs, ap, next); if (drop && ap->flags & IPV6_AF_ADDED && diff --git a/src/ipv6.h b/src/ipv6.h index df6f9fa8..bd0f900f 100644 --- a/src/ipv6.h +++ b/src/ipv6.h @@ -166,12 +166,14 @@ struct ipv6_addr { uint8_t iaid[4]; uint16_t ia_type; +#ifndef SMALL struct ipv6_addr *delegating_prefix; struct ipv6_addrhead pd_pfxs; TAILQ_ENTRY(ipv6_addr) pd_next; uint8_t prefix_exclude_len; struct in6_addr prefix_exclude; +#endif void (*dadcallback)(void *); int dadcounter;