changeset 4069:026bd55d5f0f draft

Remove more prefix delegation code for small binaries.
author Roy Marples <roy@marples.name>
date Tue, 09 May 2017 12:40:28 +0100
parents 25c85f059ac4
children 81fdcb3738e7
files src/dhcp6.c src/ipv6.c src/ipv6.h
diffstat 3 files changed, 35 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/dhcp6.c	Tue May 09 12:29:40 2017 +0100
+++ b/src/dhcp6.c	Tue May 09 12:40:28 2017 +0100
@@ -1353,7 +1353,11 @@
 		{
 			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 @@
 				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 @@
 		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 @@
 			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 @@
 			    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 @@
 	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 @@
 	free(pfx);
 
 delegated:
+#ifndef SMALL
         /* Needed for Delegated Prefixes */
 	state = D6_CSTATE(ifp);
 	i = 0;
@@ -3717,6 +3731,7 @@
         }
 	if (i)
 		n++;
+#endif
 
 	return (ssize_t)n;
 }
--- a/src/ipv6.c	Tue May 09 12:29:40 2017 +0100
+++ b/src/ipv6.c	Tue May 09 12:40:28 2017 +0100
@@ -582,12 +582,16 @@
 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 @@
 
 	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 @@
 void
 ipv6_freeaddr(struct ipv6_addr *ap)
 {
+#ifndef SMALL
 	struct ipv6_addr *ia;
 
 	/* Forget the reference */
@@ -958,6 +965,7 @@
 	} 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 @@
 	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 &&
--- a/src/ipv6.h	Tue May 09 12:29:40 2017 +0100
+++ b/src/ipv6.h	Tue May 09 12:40:28 2017 +0100
@@ -166,12 +166,14 @@
 	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;