Module Name:    src
Committed By:   bouyer
Date:           Mon May 18 21:23:34 UTC 2009

Modified Files:
        src/external/bsd/dhcpcd/dist [netbsd-5]: README bind.c config.h
            dhcpcd.c dhcpcd.conf net.c
        src/external/bsd/dhcpcd/dist/dhcpcd-hooks [netbsd-5]: 10-mtu
            20-resolv.conf 50-ntp.conf

Log Message:
external/bsd/dhcpcd/dist/README                         patch
external/bsd/dhcpcd/dist/bind.c                         patch
Apply patch, requested by roy in ticket #759:
        external/bsd/dhcpcd/dist/config.h                       patch
        external/bsd/dhcpcd/dist/dhcpcd.c                       patch
        external/bsd/dhcpcd/dist/dhcpcd.conf                    patch
        external/bsd/dhcpcd/dist/net.c                          patch
        external/bsd/dhcpcd/dist/dhcpcd-hooks/10-mtu            patch
        external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf    patch
        external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf       patch

Update dhcpcd to 5.0.4.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2.6.2 -r1.1.1.2.6.3 src/external/bsd/dhcpcd/dist/README \
    src/external/bsd/dhcpcd/dist/net.c
cvs rdiff -u -r1.1.1.2.2.2 -r1.1.1.2.2.3 src/external/bsd/dhcpcd/dist/bind.c
cvs rdiff -u -r1.1.1.2.6.3 -r1.1.1.2.6.4 \
    src/external/bsd/dhcpcd/dist/config.h \
    src/external/bsd/dhcpcd/dist/dhcpcd.c
cvs rdiff -u -r1.1.1.1.8.1 -r1.1.1.1.8.2 \
    src/external/bsd/dhcpcd/dist/dhcpcd.conf
cvs rdiff -u -r1.1.1.1.8.1 -r1.1.1.1.8.2 \
    src/external/bsd/dhcpcd/dist/dhcpcd-hooks/10-mtu
cvs rdiff -u -r1.1.1.2.6.1 -r1.1.1.2.6.2 \
    src/external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf
cvs rdiff -u -r1.1.1.2.6.2 -r1.1.1.2.6.3 \
    src/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf

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/README
diff -u src/external/bsd/dhcpcd/dist/README:1.1.1.2.6.2 src/external/bsd/dhcpcd/dist/README:1.1.1.2.6.3
--- src/external/bsd/dhcpcd/dist/README:1.1.1.2.6.2	Sun May 10 21:22:23 2009
+++ src/external/bsd/dhcpcd/dist/README	Mon May 18 21:23:34 2009
@@ -37,13 +37,15 @@
 routes. You can find discussion here:
     http://mail-index.netbsd.org/tech-net/2008/12/03/msg000896.html
 BSD systems where this has been fixed are:
-    NetBSD-5.99.6
+    NetBSD-5.0
 
 
 Hooks
 -----
 Not all the hooks in dhcpcd-hooks are installed by default.
-By default we install 01-test, 10-mtu, 20-resolv.conf and 30-hostname.
+By default we install 01-test, 10-mtu, 20-resolv.conf,
+29-lookup-hostname and 30-hostname.
+The default dhcpcd.conf does disable the lookup-hostname hook by default.
 To add more simply add them in the HOOKSCRIPTS variable.
 make HOOKSCRIPTS=50-ntp install
 
Index: src/external/bsd/dhcpcd/dist/net.c
diff -u src/external/bsd/dhcpcd/dist/net.c:1.1.1.2.6.2 src/external/bsd/dhcpcd/dist/net.c:1.1.1.2.6.3
--- src/external/bsd/dhcpcd/dist/net.c:1.1.1.2.6.2	Sun May 10 21:22:25 2009
+++ src/external/bsd/dhcpcd/dist/net.c	Mon May 18 21:23:34 2009
@@ -272,13 +272,16 @@
 
 	ifs = ifl = NULL;
 	for (ifa = ifaddrs; ifa; ifa = ifa->ifa_next) {
+		if (ifa->ifa_addr != NULL) {
 #ifdef AF_LINK
-		if (ifa->ifa_addr->sa_family != AF_LINK)
-			continue;
+			if (ifa->ifa_addr->sa_family != AF_LINK)
+				continue;
 #elif AF_PACKET
-		if (ifa->ifa_addr->sa_family != AF_PACKET)
-			continue;
+			if (ifa->ifa_addr->sa_family != AF_PACKET)
+				continue;
 #endif
+		}
+
 		/* It's possible for an interface to have >1 AF_LINK.
 		 * For our purposes, we use the first one. */
 		for (ifp = ifs; ifp; ifp = ifp->next)
@@ -325,7 +328,7 @@
 				free_interface(ifp);
 				continue;
 			}
-		} else {
+		} else if (ifa->ifa_addr != NULL) {
 #ifdef AF_LINK
 			sdl = (const struct sockaddr_dl *)(void *)ifa->ifa_addr;
 			switch(sdl->sdl_type) {
@@ -372,7 +375,8 @@
 
 	retval = 0;
 	for (ifa = ifaddrs; ifa; ifa = ifa->ifa_next) {
-		if (ifa->ifa_addr->sa_family != AF_INET ||
+		if (ifa->ifa_addr == NULL ||
+		    ifa->ifa_addr->sa_family != AF_INET ||
 		    strcmp(ifa->ifa_name, ifname) != 0)
 			continue;
 		a = (const struct sockaddr_in *)(void *)ifa->ifa_addr;

Index: src/external/bsd/dhcpcd/dist/bind.c
diff -u src/external/bsd/dhcpcd/dist/bind.c:1.1.1.2.2.2 src/external/bsd/dhcpcd/dist/bind.c:1.1.1.2.2.3
--- src/external/bsd/dhcpcd/dist/bind.c:1.1.1.2.2.2	Sun May 10 21:22:24 2009
+++ src/external/bsd/dhcpcd/dist/bind.c	Mon May 18 21:23:34 2009
@@ -49,6 +49,9 @@
 #  define _PATH_DEVNULL "/dev/null"
 #endif
 
+/* We do things after aquiring the lease, so ensure we have enough time for them */
+#define DHCP_MIN_LEASE 20
+
 #ifndef THERE_IS_NO_FORK
 pid_t
 daemonise(void)
@@ -164,6 +167,12 @@
 			syslog(LOG_INFO, "%s: leased %s for infinity",
 			    iface->name, inet_ntoa(lease->addr));
 		} else {
+			if (lease->leasetime < DHCP_MIN_LEASE) {
+				syslog(LOG_WARNING,
+				    "%s: minimum lease is %d seconds",
+				    iface->name, DHCP_MIN_LEASE);
+				lease->leasetime = DHCP_MIN_LEASE;
+			}
 			if (lease->rebindtime == 0)
 				lease->rebindtime = lease->leasetime * T2;
 			else if (lease->rebindtime >= lease->leasetime) {

Index: src/external/bsd/dhcpcd/dist/config.h
diff -u src/external/bsd/dhcpcd/dist/config.h:1.1.1.2.6.3 src/external/bsd/dhcpcd/dist/config.h:1.1.1.2.6.4
--- src/external/bsd/dhcpcd/dist/config.h:1.1.1.2.6.3	Sun May 10 21:22:24 2009
+++ src/external/bsd/dhcpcd/dist/config.h	Mon May 18 21:23:34 2009
@@ -28,7 +28,7 @@
 #define CONFIG_H
 
 #define PACKAGE			"dhcpcd"
-#define VERSION			"5.0.1"
+#define VERSION			"5.0.4"
 
 /* Some systems do not have a working fork. */
 /* #define THERE_IS_NO_FORK */
Index: src/external/bsd/dhcpcd/dist/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.c:1.1.1.2.6.3 src/external/bsd/dhcpcd/dist/dhcpcd.c:1.1.1.2.6.4
--- src/external/bsd/dhcpcd/dist/dhcpcd.c:1.1.1.2.6.3	Sun May 10 21:22:25 2009
+++ src/external/bsd/dhcpcd/dist/dhcpcd.c	Mon May 18 21:23:34 2009
@@ -365,19 +365,6 @@
 }
 
 void
-start_rebind(void *arg)
-{
-	struct interface *iface = arg;
-
-	syslog(LOG_ERR, "%s: failed to renew, attmepting to rebind",
-	    iface->name);
-	iface->state->state = DHS_REBIND;
-	delete_timeout(send_renew, iface);
-	iface->state->lease.server.s_addr = 0;
-	send_rebind(iface);
-}
-
-void
 start_expire(void *arg)
 {
 	struct interface *iface = arg;
@@ -413,10 +400,11 @@
 
 	if (strcmp(msg, "NAK:") == 0)
 		a = get_option_string(dhcp, DHO_MESSAGE);
-	else {
+	else if (dhcp->yiaddr != 0) {
 		addr.s_addr = dhcp->yiaddr;
 		a = xstrdup(inet_ntoa(addr));
-	}
+	} else
+		a = NULL;
 	r = get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID);
 	if (dhcp->servername[0] && r == 0)
 		syslog(lvl, "%s: %s %s from %s `%s'", iface->name, msg, a,
@@ -424,8 +412,10 @@
 	else if (r == 0)
 		syslog(lvl, "%s: %s %s from %s",
 		    iface->name, msg, a, inet_ntoa(addr));
-	else
+	else if (a != NULL)
 		syslog(lvl, "%s: %s %s", iface->name, msg, a);
+	else
+		syslog(lvl, "%s: %s", iface->name, msg);
 	free(a);
 }
 
@@ -457,15 +447,16 @@
 	/* We may have found a BOOTP server */
 	if (get_option_uint8(&type, dhcp, DHO_MESSAGETYPE) == -1) 
 		type = 0;
-	else if (get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID) == -1) {
-		/* We should ignore invalid NAK messages without a ServerID */
-		syslog(LOG_WARNING, "%s: ignoring DHCP message; no Server ID",
-		    iface->name);
-		return;
-	}
 
-	/* We should restart on a NAK */
 	if (type == DHCP_NAK) {
+		/* For NAK, only check if we require the ServerID */
+		if (has_option_mask(ifo->requiremask, DHO_SERVERID) &&
+		    get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID) == -1)
+		{
+			log_dhcp(LOG_WARNING, "reject NAK", iface, dhcp);
+			return;
+		}
+		/* We should restart on a NAK */
 		log_dhcp(LOG_WARNING, "NAK:", iface, dhcp);
 		drop_config(iface, "NAK");
 		unlink(iface->leasefile);
@@ -482,27 +473,31 @@
 		return;
 	}
 
-	/* No NAK, so reset the backoff */
-	state->nakoff = 1;
-
 	/* Ensure that all required options are present */
 	for (i = 1; i < 255; i++) {
 		if (has_option_mask(ifo->requiremask, i) &&
 		    get_option_uint8(&tmp, dhcp, i) != 0)
 		{
-			log_dhcp(LOG_WARNING, "reject", iface, dhcp);
+			/* If we are bootp, then ignore the need for serverid.
+			 * To ignore bootp, require dhcp_message_type instead. */
+			if (type == 0 && i == DHO_SERVERID)
+				continue;
+			log_dhcp(LOG_WARNING, "reject DHCP", iface, dhcp);
 			return;
 		}
-	}
+	}		
+
+	/* No NAK, so reset the backoff */
+	state->nakoff = 1;
 
 	if ((type == 0 || type == DHCP_OFFER) &&
 	    state->state == DHS_DISCOVER)
 	{
 		lease->frominfo = 0;
 		lease->addr.s_addr = dhcp->yiaddr;
-		lease->server.s_addr = 0;
+		lease->server.s_addr = INADDR_ANY;
 		if (type != 0)
-			lease->server.s_addr = addr.s_addr;
+			get_option_addr(&lease->server.s_addr, dhcp, DHO_SERVERID);
 		log_dhcp(LOG_INFO, "offered", iface, dhcp);
 		free(state->offer);
 		state->offer = dhcp;
@@ -871,6 +866,21 @@
 	send_renew(iface);
 }
 
+void
+start_rebind(void *arg)
+{
+	struct interface *iface = arg;
+
+	syslog(LOG_ERR, "%s: failed to renew, attmepting to rebind",
+	    iface->name);
+	iface->state->state = DHS_REBIND;
+	delete_timeout(send_renew, iface);
+	iface->state->lease.server.s_addr = 0;
+	if (iface->raw_fd == -1)
+		open_sockets(iface);
+	send_rebind(iface);
+}
+
 static void
 start_timeout(void *arg)
 {
@@ -1596,31 +1606,31 @@
 		    PACKAGE " will not work correctly unless run as root");
 
 	if (sig != 0) {
-		i = -1;
 		pid = read_pid();
 		if (pid != 0)
 			syslog(LOG_INFO, "sending signal %d to pid %d",
 			    sig, pid);
-
-		if (!pid || (i = kill(pid, sig))) {
+		if (pid == 0 || kill(pid, sig) != 0) {
 			if (sig != SIGALRM)
 				syslog(LOG_ERR, ""PACKAGE" not running");
 			unlink(pidfile);
-			exit(EXIT_FAILURE);
-		}
-		if (sig == SIGALRM)
-			exit(EXIT_SUCCESS);
-		/* Spin until it exits */
-		syslog(LOG_INFO, "waiting for pid %d to exit", pid);
-		ts.tv_sec = 0;
-		ts.tv_nsec = 100000000; /* 10th of a second */
-		for(i = 0; i < 100; i++) {
-			nanosleep(&ts, NULL);
-			if (read_pid() == 0)
+			if (sig != SIGALRM)
+				exit(EXIT_FAILURE);
+		} else {
+			if (sig == SIGALRM)
 				exit(EXIT_SUCCESS);
+			/* Spin until it exits */
+			syslog(LOG_INFO, "waiting for pid %d to exit", pid);
+			ts.tv_sec = 0;
+			ts.tv_nsec = 100000000; /* 10th of a second */
+			for(i = 0; i < 100; i++) {
+				nanosleep(&ts, NULL);
+				if (read_pid() == 0)
+					exit(EXIT_SUCCESS);
+			}
+			syslog(LOG_ERR, "pid %d failed to exit", pid);
+			exit(EXIT_FAILURE);
 		}
-		syslog(LOG_ERR, "pid %d failed to exit", pid);
-		exit(EXIT_FAILURE);
 	}
 
 	if (!(options & DHCPCD_TEST)) {

Index: src/external/bsd/dhcpcd/dist/dhcpcd.conf
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.conf:1.1.1.1.8.1 src/external/bsd/dhcpcd/dist/dhcpcd.conf:1.1.1.1.8.2
--- src/external/bsd/dhcpcd/dist/dhcpcd.conf:1.1.1.1.8.1	Sun May 10 21:22:25 2009
+++ src/external/bsd/dhcpcd/dist/dhcpcd.conf	Mon May 18 21:23:34 2009
@@ -1,15 +1,25 @@
 # A sample configuration for dhcpcd.
 # See dhcpcd.conf(5) for details.
 
-# We normally want to inform the DHCP server of our hostname for DDNS.
+# Inform the DHCP server of our hostname for DDNS.
 hostname
 
-# A list of options we should request from the DHCP server.
+# A list of options to request from the DHCP server.
 option domain_name_servers, domain_name, domain_search, host_name
-# Most distros have ntp support.
+# Most distributions have NTP support.
 option ntp_servers
 
-# We should behave nicely on networks and respect their MTU.
+# Behave nicely on networks and respect their MTU.
 # However, a lot of buggy DHCP servers set invalid MTUs so this is not
 # enabled by default.
 #option interface_mtu
+
+# A ServerID is required by RFC2131.
+# Some broken DHCP servers do not send one and dhcpcd can work without it.
+# Some broken DHCP servers NAK incorrectly and do not include a ServerID either so
+# the default is to require a ServerID.
+require dhcp_server_identifier
+
+# A hook script is provided to lookup the hostname if not set by the DHCP
+# server, but it should not be run by default.
+nohook lookup-hostname

Index: src/external/bsd/dhcpcd/dist/dhcpcd-hooks/10-mtu
diff -u src/external/bsd/dhcpcd/dist/dhcpcd-hooks/10-mtu:1.1.1.1.8.1 src/external/bsd/dhcpcd/dist/dhcpcd-hooks/10-mtu:1.1.1.1.8.2
--- src/external/bsd/dhcpcd/dist/dhcpcd-hooks/10-mtu:1.1.1.1.8.1	Sun May 10 21:22:26 2009
+++ src/external/bsd/dhcpcd/dist/dhcpcd-hooks/10-mtu	Mon May 18 21:23:34 2009
@@ -1,5 +1,8 @@
 # Configure the MTU for the interface
 
 if [ -n "$new_interface_mtu" ]; then
-	ifconfig "$interface" mtu "$new_interface_mtu"
+	# The smalled MTU dhcpcd can work with is 576
+	if [ "$new_interface_mtu" -ge 576 ]; then
+		ifconfig "$interface" mtu "$new_interface_mtu"
+	fi
 fi

Index: src/external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf
diff -u src/external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf:1.1.1.2.6.1 src/external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf:1.1.1.2.6.2
--- src/external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf:1.1.1.2.6.1	Sun May 10 21:22:26 2009
+++ src/external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf	Mon May 18 21:23:34 2009
@@ -48,6 +48,7 @@
 
 	# Assemble resolv.conf using our head and tail files
 	[ -f "$cf" ] && rm -f "$cf"
+	[ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
 	echo "$header" > "$cf"
 	if [ -f /etc/resolv.conf.head ]; then
 		cat /etc/resolv.conf.head >> "$cf"
@@ -101,9 +102,7 @@
 	if [ -e "$resolv_conf_dir/$interface" ]; then
 		rm -f "$resolv_conf_dir/$interface"
 	fi
-	if [ ! -d "$resolv_conf_dir" ]; then
-		mkdir -p "$resolv_conf_dir"
-	fi
+	[ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
 	printf "$conf" > "$resolv_conf_dir/$interface"
 	build_resolv_conf
 }

Index: src/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf
diff -u src/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf:1.1.1.2.6.2 src/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf:1.1.1.2.6.3
--- src/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf:1.1.1.2.6.2	Sun May 10 21:22:26 2009
+++ src/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf	Mon May 18 21:23:34 2009
@@ -11,11 +11,11 @@
 # Detect OpenRC or BSD rc
 # Distributions may want to just have their command here instead of this
 if type rc-service >/dev/null 2>&1 && rc-service --exists ntpd; then
-	ntpd_restart_cmd="rc-service ntpd -- --ifstarted --quiet restart"
+	ntpd_restart_cmd="rc-service ntpd -- -Ds restart"
 elif [ -x /etc/rc.d/ntpd ]; then
-	ntpd_restart_cmd="/etc/rc.d/ntpd status && /etc/rc.d/ntpd restart"
+	ntpd_restart_cmd="/etc/rc.d/ntpd status >/dev/null 2>&1 && /etc/rc.d/ntpd restart"
 elif [ -x /usr/local/etc/rc.d/ntpd ]; then
-	ntpd_restart_cmd="/usr/local/etc/rc.d/ntpd status && /usr/local/etc/rc.d/ntpd restart"
+	ntpd_restart_cmd="/usr/local/etc/rc.d/ntpd status >/dev/null 2>&1 && /usr/local/etc/rc.d/ntpd restart"
 fi
 
 ntp_conf_dir="$state_dir/ntp.conf"
@@ -47,6 +47,7 @@
 
 	# Merge our config into ntp.conf
 	[ -e "$cf" ] && rm -f "$cf"
+	[ -d "$ntp_conf_dir" ] || mkdir -p "$ntp_conf_dir"
 	remove_markers "$signature_base" "$signature_base_end" \
 		"$ntp_conf" > "$cf"
 	if [ -n "$servers" ]; then

Reply via email to