Module Name:    src
Committed By:   roy
Date:           Thu Feb  7 21:37:36 UTC 2019

Modified Files:
        src/external/bsd/dhcpcd/dist/hooks: dhcpcd-run-hooks.in
        src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.c if-bsd.c
            if-options.c ipv6nd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
    src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcpcd/dist/src/dhcp6.c \
    src/external/bsd/dhcpcd/dist/src/if-bsd.c \
    src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.16 -r1.17 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/src/if-options.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in
diff -u src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.2 src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.3
--- src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in:1.2	Sat Sep 22 13:17:46 2018
+++ src/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in	Thu Feb  7 21:37:36 2019
@@ -239,8 +239,9 @@ detect_init()
 		_service_exists="/usr/bin/systemctl --quiet is-enabled \$1.service"
 		_service_status="/usr/bin/systemctl --quiet is-active \$1.service"
 		_service_cmd="/usr/bin/systemctl \$2 \$1.service"
-	elif [ -x /sbin/rc-service ] && [ -s /libexec/rc/init.d/softlevel ] ||
-	     [ -s /run/openrc/softlevel ]
+	elif [ -x /sbin/rc-service ] &&
+	     { [ -s /libexec/rc/init.d/softlevel ] ||
+	     [ -s /run/openrc/softlevel ]; }
 	then
 		_service_exists="/sbin/rc-service -e \$1"
 		_service_cmd="/sbin/rc-service \$1 -- -D \$2"

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.15 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.16
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.15	Tue Jan 22 15:20:21 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Thu Feb  7 21:37:36 2019
@@ -1764,7 +1764,7 @@ send_message(struct interface *ifp, uint
 
 	if (!callback) {
 		/* No carrier? Don't bother sending the packet. */
-		if (ifp->carrier == LINK_DOWN)
+		if (ifp->carrier <= LINK_DOWN)
 			return;
 		logdebugx("%s: sending %s with xid 0x%x",
 		    ifp->name,
@@ -1784,7 +1784,7 @@ send_message(struct interface *ifp, uint
 		timespecnorm(&tv);
 		/* No carrier? Don't bother sending the packet.
 		 * However, we do need to advance the timeout. */
-		if (ifp->carrier == LINK_DOWN)
+		if (ifp->carrier <= LINK_DOWN)
 			goto fail;
 		logdebugx("%s: sending %s (xid 0x%x), next in %0.1f seconds",
 		    ifp->name,
@@ -1965,7 +1965,7 @@ dhcp_expire1(struct interface *ifp)
 	dhcp_drop(ifp, "EXPIRE");
 	unlink(state->leasefile);
 	state->interval = 0;
-	if (!(ifp->options->options & DHCPCD_LINK) || ifp->carrier != LINK_DOWN)
+	if (!(ifp->options->options & DHCPCD_LINK) || ifp->carrier > LINK_DOWN)
 		dhcp_discover(ifp);
 }
 
@@ -2601,7 +2601,7 @@ dhcp_reboot(struct interface *ifp)
 	state->state = DHS_REBOOT;
 	state->interval = 0;
 
-	if (ifo->options & DHCPCD_LINK && ifp->carrier == LINK_DOWN) {
+	if (ifo->options & DHCPCD_LINK && ifp->carrier <= LINK_DOWN) {
 		loginfox("%s: waiting for carrier", ifp->name);
 		return;
 	}
@@ -2691,7 +2691,7 @@ dhcp_drop(struct interface *ifp, const c
 		state->state = DHS_RELEASE;
 
 		unlink(state->leasefile);
-		if (ifp->carrier != LINK_DOWN &&
+		if (ifp->carrier > LINK_DOWN &&
 		    state->new != NULL &&
 		    state->lease.server.s_addr != INADDR_ANY)
 		{

Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.3 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.4
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.3	Tue Jan 22 15:20:21 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c	Thu Feb  7 21:37:36 2019
@@ -1169,7 +1169,7 @@ dhcp6_sendmessage(struct interface *ifp,
 	struct ipv6_addr *lla;
 	int s;
 
-	if (!callback && ifp->carrier == LINK_DOWN)
+	if (!callback && ifp->carrier <= LINK_DOWN)
 		return 0;
 
 	memset(&dst, 0, sizeof(dst));
@@ -1262,7 +1262,7 @@ dhcp6_sendmessage(struct interface *ifp,
 		}
 
 logsend:
-		if (ifp->carrier != LINK_DOWN)
+		if (ifp->carrier > LINK_DOWN)
 			logdebugx("%s: %s %s (xid 0x%02x%02x%02x),"
 			    " next in %0.1f seconds",
 			    ifp->name,
@@ -1286,7 +1286,7 @@ logsend:
 		}
 	}
 
-	if (ifp->carrier == LINK_DOWN)
+	if (ifp->carrier <= LINK_DOWN)
 		return 0;
 
 	/* Update the elapsed time */
@@ -3416,6 +3416,8 @@ dhcp6_recvif(struct interface *ifp, stru
 			break;
 		}
 		return;
+#else
+		break;
 #endif
 	default:
 		logerrx("%s: invalid DHCP6 type %s (%d)",
Index: src/external/bsd/dhcpcd/dist/src/if-bsd.c
diff -u src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.3 src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.4
--- src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.3	Tue Jan 22 15:20:21 2019
+++ src/external/bsd/dhcpcd/dist/src/if-bsd.c	Thu Feb  7 21:37:36 2019
@@ -197,7 +197,6 @@ if_closesockets_os(struct dhcpcd_ctx *ct
 		close(priv->pf_inet6_fd);
 }
 
-#if defined(INET) || defined(INET6)
 static void
 if_linkaddr(struct sockaddr_dl *sdl, const struct interface *ifp)
 {
@@ -208,7 +207,6 @@ if_linkaddr(struct sockaddr_dl *sdl, con
 	sdl->sdl_nlen = sdl->sdl_alen = sdl->sdl_slen = 0;
 	sdl->sdl_index = (unsigned short)ifp->index;
 }
-#endif
 
 #if defined(SIOCG80211NWID) || defined(SIOCGETVLAN)
 static int if_direct_ioctl(int s, const char *ifname,
@@ -359,7 +357,6 @@ get_addrs(int type, const void *data, co
 	}
 }
 
-#if defined(INET) || defined(INET6)
 static struct interface *
 if_findsdl(struct dhcpcd_ctx *ctx, const struct sockaddr_dl *sdl)
 {
@@ -504,7 +501,17 @@ if_route(unsigned char cmd, const struct
 		    !sa_is_loopback(&rt->rt_gateway))
 		{
 			rtm->rtm_index = (unsigned short)rt->rt_ifp->index;
-#ifdef __OpenBSD__
+/*
+ * OpenBSD rejects the message for on-link routes.
+ * FreeBSD-12 kernel apparently panics.
+ * I can't replicate the panic, but better safe than sorry!
+ * https://roy.marples.name/archives/dhcpcd-discuss/0002286.html
+ *
+ * Neither OS currently allows IPv6 address sharing anyway, so let's
+ * try to encourage someone to fix that by logging a waring during compile.
+ */
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
+#warning OS does not allow IPv6 address sharing
 			if (!gateway_unspec || rt->rt_dest.sa_family!=AF_INET6)
 #endif
 			rtm->rtm_addrs |= RTA_IFP;
@@ -688,8 +695,6 @@ if_initrt(struct dhcpcd_ctx *ctx, int af
 	return 0;
 }
 
-#endif
-
 #ifdef INET
 int
 if_address(unsigned char cmd, const struct ipv4_addr *ia)
@@ -951,16 +956,22 @@ if_ifinfo(struct dhcpcd_ctx *ctx, const 
 	if ((ifp = if_findindex(ctx->ifaces, ifm->ifm_index)) == NULL)
 		return;
 
-	/* If we get LINK_STATE_UNKNOWN here, it means the interface
-	 * doesn't support reporting carrier state.
-	 * As such, we need to rely on IFF_UP.
-	 * Even if LINK_STATE_UP is reported, we also need IFF_UP as well
-	 * so for dhcpcd they are equivalent and we only need to check
-	 * LINK_STATE_DOWN. */
-	if (ifm->ifm_data.ifi_link_state == LINK_STATE_DOWN)
-		link_state = LINK_DOWN;
-	else
+	switch (ifm->ifm_data.ifi_link_state) {
+	case LINK_STATE_UNKNOWN:
+		if (ifp->media_valid) {
+			link_state = LINK_DOWN;
+			break;
+		}
+		/* Interface does not report media state, so we have
+		 * to rely on IFF_UP. */
+		/* FALLTHROUGH */
+	case LINK_STATE_UP:
 		link_state = ifm->ifm_flags & IFF_UP ? LINK_UP : LINK_DOWN;
+		break;
+	default:
+		link_state = LINK_DOWN;
+		break;
+	}
 
 	dhcpcd_handlecarrier(ctx, link_state,
 	    (unsigned int)ifm->ifm_flags, ifp->name);
Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.3 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.4
--- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.3	Tue Jan 22 15:20:21 2019
+++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c	Thu Feb  7 21:37:36 2019
@@ -45,6 +45,7 @@
 #define ELOOP_QUEUE 3
 #include "common.h"
 #include "dhcpcd.h"
+#include "dhcp-common.h"
 #include "dhcp6.h"
 #include "eloop.h"
 #include "if.h"
@@ -328,7 +329,9 @@ ipv6nd_sendrsprobe(void *arg)
 	else {
 		logwarnx("%s: no IPv6 Routers available", ifp->name);
 		ipv6nd_drop(ifp);
+#ifdef DHCP6
 		dhcp6_dropnondelegates(ifp);
+#endif
 	}
 }
 
@@ -343,7 +346,7 @@ ipv6nd_sendadvertisement(void *arg)
 	struct in6_pktinfo pi;
 	const struct rs_state *state = RS_CSTATE(ifp);
 
-	if (state == NULL || ifp->carrier == LINK_DOWN)
+	if (state == NULL || ifp->carrier <= LINK_DOWN)
 		goto freeit;
 
 	memset(&dst, 0, sizeof(dst));
@@ -405,7 +408,7 @@ ipv6nd_advertise(struct ipv6_addr *ia)
 	iaf = NULL;
 	TAILQ_FOREACH(ifp, ctx->ifaces, next) {
 		state = IPV6_STATE(ifp);
-		if (state == NULL || ifp->carrier == LINK_DOWN)
+		if (state == NULL || ifp->carrier <= LINK_DOWN)
 			continue;
 
 		TAILQ_FOREACH(iap, &state->addrs, next) {
@@ -855,7 +858,10 @@ try_script:
 #ifndef DHCP6
 /* If DHCPv6 is compiled out, supply a shim to provide an error message
  * if IPv6RA requests DHCPv6. */
-#undef dhcp6_start
+enum DH6S {
+	DH6S_REQUEST,
+	DH6S_INFORM,
+};
 static int
 dhcp6_start(__unused struct interface *ifp, __unused enum DH6S init_state)
 {
@@ -1239,8 +1245,10 @@ handle_flag:
 		if (new_data && dhcp6_start(ifp, DH6S_INFORM) == -1)
 			LOG_DHCP6("dhcp6_start: %s", ifp->name);
 	} else {
+#ifdef DHCP6
 		if (new_data)
 			logdebugx("%s: No DHCPv6 instruction in RA", ifp->name);
+#endif
 nodhcp6:
 		if (ifp->ctx->options & DHCPCD_TEST) {
 			eloop_exit(ifp->ctx->eloop, EXIT_SUCCESS);
@@ -1451,19 +1459,21 @@ ipv6nd_expirera(void *arg)
 	struct interface *ifp;
 	struct ra *rap, *ran;
 	struct timespec now, lt, expire, next;
-	uint8_t expired, anyvalid, valid, validone;
+	bool expired, valid, validone;
 	struct ipv6_addr *ia;
+#ifdef DHCP6
+	bool anyvalid = false;
+#endif
 
 	ifp = arg;
 	clock_gettime(CLOCK_MONOTONIC, &now);
-	expired = 0;
+	expired = false;
 	timespecclear(&next);
 
-	anyvalid = 0;
 	TAILQ_FOREACH_SAFE(rap, ifp->ctx->ra_routers, next, ran) {
 		if (rap->iface != ifp)
 			continue;
-		valid = validone = 0;
+		valid = validone = false;
 		if (rap->lifetime) {
 			lt.tv_sec = (time_t)rap->lifetime;
 			lt.tv_nsec = 0;
@@ -1477,7 +1487,7 @@ ipv6nd_expirera(void *arg)
 					rap->lifetime = 0;
 				}
 			} else {
-				valid = 1;
+				valid = true;
 				timespecsub(&expire, &now, &lt);
 				if (!timespecisset(&next) ||
 				    timespeccmp(&next, &lt, >))
@@ -1492,7 +1502,7 @@ ipv6nd_expirera(void *arg)
 			if (ia->prefix_vltime == 0)
 				continue;
 			if (ia->prefix_vltime == ND6_INFINITE_LIFETIME) {
-				validone = 1;
+				validone = true;
 				continue;
 			}
 			lt.tv_sec = (time_t)ia->prefix_vltime;
@@ -1510,13 +1520,13 @@ ipv6nd_expirera(void *arg)
 				ia->prefix_vltime = ia->prefix_pltime = 0;
 				ia->flags &=
 				    ~(IPV6_AF_ADDED | IPV6_AF_DADCOMPLETED);
-				expired = 1;
+				expired = true;
 			} else {
 				timespecsub(&expire, &now, &lt);
 				if (!timespecisset(&next) ||
 				    timespeccmp(&next, &lt, >))
 					next = lt;
-				validone = 1;
+				validone = true;
 			}
 		}
 
@@ -1529,8 +1539,10 @@ ipv6nd_expirera(void *arg)
 		 * as well punt it. */
 		if (!valid && !validone)
 			ipv6nd_free_ra(rap);
+#ifdef DHCP6
 		else
-			anyvalid = 1;
+			anyvalid = true;
+#endif
 	}
 
 	if (timespecisset(&next))
@@ -1541,9 +1553,11 @@ ipv6nd_expirera(void *arg)
 		script_runreason(ifp, "ROUTERADVERT");
 	}
 
+#ifdef DHCP6
 	/* No valid routers? Kill any DHCPv6. */
 	if (!anyvalid)
 		dhcp6_dropnondelegates(ifp);
+#endif
 }
 
 void

Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.16 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.17
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.16	Tue Jan 22 21:38:08 2019
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Thu Feb  7 21:37:36 2019
@@ -52,6 +52,7 @@ const char dhcpcd_copyright[] = "Copyrig
 #include "common.h"
 #include "control.h"
 #include "dev.h"
+#include "dhcp-common.h"
 #include "dhcpcd.h"
 #include "dhcp6.h"
 #include "duid.h"
@@ -151,6 +152,7 @@ free_globals(struct dhcpcd_ctx *ctx)
 		free(ctx->nd_opts);
 		ctx->nd_opts = NULL;
 	}
+#ifdef DHCP6
 	if (ctx->dhcp6_opts) {
 		for (opt = ctx->dhcp6_opts;
 		    ctx->dhcp6_opts_len > 0;
@@ -160,6 +162,7 @@ free_globals(struct dhcpcd_ctx *ctx)
 		ctx->dhcp6_opts = NULL;
 	}
 #endif
+#endif
 	if (ctx->vivso) {
 		for (opt = ctx->vivso;
 		    ctx->vivso_len > 0;
@@ -205,18 +208,39 @@ int
 dhcpcd_ifafwaiting(const struct interface *ifp)
 {
 	unsigned long long opts;
+	bool foundany = false;
 
 	if (ifp->active != IF_ACTIVE_USER)
 		return AF_MAX;
 
+#define DHCPCD_WAITALL	(DHCPCD_WAITIP4 | DHCPCD_WAITIP6)
 	opts = ifp->options->options;
-	if (opts & DHCPCD_WAITIP4 && !ipv4_hasaddr(ifp))
-		return AF_INET;
-	if (opts & DHCPCD_WAITIP6 && !ipv6_hasaddr(ifp))
-		return AF_INET6;
-	if (opts & DHCPCD_WAITIP &&
-	    !(opts & (DHCPCD_WAITIP4 | DHCPCD_WAITIP6)) &&
-	    !ipv4_hasaddr(ifp) && !ipv6_hasaddr(ifp))
+#ifdef INET
+	if (opts & DHCPCD_WAITIP4 ||
+	    (opts & DHCPCD_WAITIP && !(opts & DHCPCD_WAITALL)))
+	{
+		bool foundaddr = ipv4_hasaddr(ifp);
+
+		if (opts & DHCPCD_WAITIP4 && !foundaddr)
+			return AF_INET;
+		if (foundaddr)
+			foundany = true;
+	}
+#endif
+#ifdef INET6
+	if (opts & DHCPCD_WAITIP6 ||
+	    (opts & DHCPCD_WAITIP && !(opts & DHCPCD_WAITALL)))
+	{
+		bool foundaddr = ipv6_hasaddr(ifp);
+
+		if (opts & DHCPCD_WAITIP6 && !foundaddr)
+			return AF_INET;
+		if (foundaddr)
+			foundany = true;
+	}
+#endif
+
+	if (opts & DHCPCD_WAITIP && !(opts & DHCPCD_WAITALL) && !foundany)
 		return AF_UNSPEC;
 	return AF_MAX;
 }
@@ -233,12 +257,16 @@ dhcpcd_afwaiting(const struct dhcpcd_ctx
 
 	opts = ctx->options;
 	TAILQ_FOREACH(ifp, ctx->ifaces, next) {
+#ifdef INET
 		if (opts & (DHCPCD_WAITIP | DHCPCD_WAITIP4) &&
 		    ipv4_hasaddr(ifp))
 			opts &= ~(DHCPCD_WAITIP | DHCPCD_WAITIP4);
+#endif
+#ifdef INET6
 		if (opts & (DHCPCD_WAITIP | DHCPCD_WAITIP6) &&
 		    ipv6_hasaddr(ifp))
 			opts &= ~(DHCPCD_WAITIP | DHCPCD_WAITIP6);
+#endif
 		if (!(opts & DHCPCD_WAITOPTS))
 			break;
 	}
@@ -529,7 +557,7 @@ configure_interface1(struct interface *i
 		ifo->options |= DHCPCD_IAID;
 	}
 
-#ifdef INET6
+#ifdef DHCP6
 	if (ifo->ia_len == 0 && ifo->options & DHCPCD_IPV6 &&
 	    ifp->name[0] != '\0')
 	{
@@ -727,18 +755,30 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *
 		if (ifp->carrier != LINK_DOWN) {
 			if (ifp->carrier == LINK_UP)
 				loginfox("%s: carrier lost", ifp->name);
-			ifp->carrier = LINK_DOWN;
+#ifdef NOCARRIER_PRESERVE_IP
+			if (ifp->flags & IFF_UP)
+				ifp->carrier = LINK_DOWN_IFFUP;
+			else
+#endif
+				ifp->carrier = LINK_DOWN;
 			script_runreason(ifp, "NOCARRIER");
 #ifdef NOCARRIER_PRESERVE_IP
+			if (ifp->flags & IFF_UP) {
 #ifdef ARP
-			arp_drop(ifp);
+				arp_drop(ifp);
 #endif
-			dhcp_abort(ifp);
-			ipv6nd_expire(ifp, 0);
-			dhcp6_abort(ifp);
-#else
-			dhcpcd_drop(ifp, 0);
+#ifdef INET
+				dhcp_abort(ifp);
+#endif
+#ifdef INET6
+				ipv6nd_expire(ifp, 0);
 #endif
+#ifdef DHCP6
+				dhcp6_abort(ifp);
+#endif
+			} else
+#endif
+				dhcpcd_drop(ifp, 0);
 		}
 	} else if (carrier == LINK_UP && ifp->flags & IFF_UP) {
 		if (ifp->carrier != LINK_UP) {
@@ -772,6 +812,7 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *
 			}
 			dhcpcd_initstate(ifp, 0);
 			script_runreason(ifp, "CARRIER");
+#ifdef INET6
 #ifdef NOCARRIER_PRESERVE_IP
 			/* Set any IPv6 Routers we remembered to expire
 			 * faster than they would normally as we
@@ -780,6 +821,7 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *
 #endif
 			/* RFC4941 Section 3.5 */
 			ipv6_gentempifid(ifp);
+#endif
 			dhcpcd_startinterface(ifp);
 		}
 	}
@@ -885,10 +927,12 @@ dhcpcd_startinterface(void *arg)
 #endif
 	}
 
+#ifdef INET6
 	if (ifo->options & DHCPCD_IPV6 && ipv6_start(ifp) == -1) {
 		logerr("%s: ipv6_start", ifp->name);
 		ifo->options &= ~DHCPCD_IPV6;
 	}
+
 	if (ifo->options & DHCPCD_IPV6) {
 		if (ifp->active == IF_ACTIVE_USER) {
 			ipv6_startstatic(ifp);
@@ -897,7 +941,7 @@ dhcpcd_startinterface(void *arg)
 				ipv6nd_startrs(ifp);
 		}
 
-
+#ifdef DHCP6
 		if (ifo->options & DHCPCD_DHCP6) {
 			dhcp6_find_delegates(ifp);
 
@@ -914,7 +958,9 @@ dhcpcd_startinterface(void *arg)
 					logerr("%s: dhcp6_start", ifp->name);
 			}
 		}
+#endif
 	}
+#endif
 
 #ifdef INET
 	if (ifo->options & DHCPCD_IPV4 && ifp->active == IF_ACTIVE_USER) {
@@ -1173,8 +1219,12 @@ if_reboot(struct interface *ifp, int arg
 	oldopts = ifp->options->options;
 	script_runreason(ifp, "RECONFIGURE");
 	dhcpcd_initstate1(ifp, argc, argv, 0);
+#ifdef INET
 	dhcp_reboot_newopts(ifp, oldopts);
+#endif
+#ifdef DHCP6
 	dhcp6_reboot(ifp);
+#endif
 	dhcpcd_prestartinterface(ifp);
 }
 
@@ -1212,8 +1262,10 @@ reconf_reboot(struct dhcpcd_ctx *ctx, in
 		if (ifp->active == IF_ACTIVE_USER) {
 			if (action)
 				if_reboot(ifp, argc, argv);
+#ifdef INET
 			else
 				ipv4_applyaddr(ifp);
+#endif
 		} else if (i != argc) {
 			ifp->active = IF_ACTIVE_USER;
 			dhcpcd_initstate1(ifp, argc, argv, 0);
@@ -1252,11 +1304,17 @@ dhcpcd_ifrenew(struct interface *ifp)
 	    ifp->carrier == LINK_DOWN)
 		return;
 
+#ifdef INET
 	dhcp_renew(ifp);
+#endif
+#ifdef INET6
 #define DHCPCD_RARENEW (DHCPCD_IPV6 | DHCPCD_IPV6RS)
 	if ((ifp->options->options & DHCPCD_RARENEW) == DHCPCD_RARENEW)
 		ipv6nd_startrs(ifp);
+#endif
+#ifdef DHCP6
 	dhcp6_renew(ifp);
+#endif
 }
 
 static void
@@ -1338,16 +1396,24 @@ dhcpcd_getinterfaces(void *arg)
 		if (!ifp->active)
 			continue;
 		len++;
+#ifdef INET
 		if (D_STATE_RUNNING(ifp))
 			len++;
+#endif
+#ifdef IPV4LL
 		if (IPV4LL_STATE_RUNNING(ifp))
 			len++;
+#endif
+#ifdef INET6
 		if (IPV6_STATE_RUNNING(ifp))
 			len++;
 		if (RS_STATE_RUNNING(ifp))
 			len++;
+#endif
+#ifdef DHCP6
 		if (D6_STATE_RUNNING(ifp))
 			len++;
+#endif
 	}
 	if (write(fd->fd, &len, sizeof(len)) != sizeof(len))
 		return;
@@ -1666,9 +1732,11 @@ main(int argc, char **argv)
 			printf("\nND options:\n");
 			ipv6nd_printoptions(&ctx,
 			    ifo->nd_override, ifo->nd_override_len);
+#ifdef DHCP6
 			printf("\nDHCPv6 options:\n");
 			dhcp6_printoptions(&ctx,
 			    ifo->dhcp6_override, ifo->dhcp6_override_len);
+#endif
 		}
 #endif
 		goto exit_success;
@@ -1795,12 +1863,22 @@ printpidfile:
 		configure_interface(ifp, ctx.argc, ctx.argv, 0);
 		i = 0;
 		if (family == 0 || family == AF_INET) {
+#ifdef INET
 			if (dhcp_dump(ifp) == -1)
 				i = -1;
+#else
+			if (family == AF_INET)
+				logerrx("No INET support");
+#endif
 		}
 		if (family == 0 || family == AF_INET6) {
+#ifdef DHCP6
 			if (dhcp6_dump(ifp) == -1)
 				i = -1;
+#else
+			if (family == AF_INET6)
+				logerrx("No DHCP6 support");
+#endif
 		}
 		if (i == -1)
 			goto exit_failure;
@@ -2059,7 +2137,9 @@ exit1:
 	}
 	if_closesockets(&ctx);
 	free_globals(&ctx);
+#ifdef INET6
 	ipv6_ctxfree(&ctx);
+#endif
 	dev_stop(&ctx);
 	eloop_free(ctx.eloop);
 	free(ctx.iov[0].iov_base);

Index: src/external/bsd/dhcpcd/dist/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.11 src/external/bsd/dhcpcd/dist/src/if-options.c:1.12
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.11	Tue Jan 22 15:20:21 2019
+++ src/external/bsd/dhcpcd/dist/src/if-options.c	Thu Feb  7 21:37:36 2019
@@ -541,6 +541,7 @@ set_option_space(struct dhcpcd_ctx *ctx,
 		return arg + strlen("nd_");
 	}
 
+#ifdef DHCP6
 	if (strncmp(arg, "dhcp6_", strlen("dhcp6_")) == 0) {
 		*d = ctx->dhcp6_opts;
 		*dl = ctx->dhcp6_opts_len;
@@ -553,6 +554,7 @@ set_option_space(struct dhcpcd_ctx *ctx,
 		return arg + strlen("dhcp6_");
 	}
 #endif
+#endif
 
 #ifdef INET
 	*d = ctx->dhcp_opts;
@@ -1420,9 +1422,13 @@ parse_option(struct dhcpcd_ctx *ctx, con
 			ia->sla = NULL;
 #endif
 		}
+
+#ifdef SMALL
+		break;
+#else
 		if (ia->ia_type != D6_OPTION_IA_PD)
 			break;
-#ifndef SMALL
+
 		for (p = fp; p; p = fp) {
 			fp = strwhite(p);
 			if (fp) {
@@ -2430,8 +2436,10 @@ read_config(struct dhcpcd_ctx *ctx,
 #ifdef INET6
 		ctx->nd_opts = ifo->nd_override;
 		ctx->nd_opts_len = ifo->nd_override_len;
+#ifdef DHCP6
 		ctx->dhcp6_opts = ifo->dhcp6_override;
 		ctx->dhcp6_opts_len = ifo->dhcp6_override_len;
+#endif
 #else
 		for (i = 0, opt = ifo->nd_override;
 		    i < ifo->nd_override_len;

Reply via email to