Module Name: src
Committed By: snj
Date: Tue Aug 4 20:23:37 UTC 2009
Modified Files:
src/doc [netbsd-5-0]: 3RDPARTY CHANGES
src/external/bsd/dhcpcd/dist [netbsd-5-0]: client.c config.h
configure.c dhcp.c dhcp.h dhcpcd-run-hooks.8.in dhcpcd.8.in
dhcpcd.c dhcpcd.conf.5.in net.c net.h signals.c
Log Message:
Apply patch (requested by roy in ticket #880):
Update dhcpcd to 4.0.14.
To generate a diff of this commit:
cvs rdiff -u -r1.647.2.6 -r1.647.2.6.2.1 src/doc/3RDPARTY
cvs rdiff -u -r1.1142.2.7 -r1.1142.2.7.2.1 src/doc/CHANGES
cvs rdiff -u -r1.1.1.2.6.2 -r1.1.1.2.6.2.2.1 \
src/external/bsd/dhcpcd/dist/client.c \
src/external/bsd/dhcpcd/dist/config.h src/external/bsd/dhcpcd/dist/dhcp.c \
src/external/bsd/dhcpcd/dist/dhcpcd.c
cvs rdiff -u -r1.1.1.2.6.1 -r1.1.1.2.6.1.2.1 \
src/external/bsd/dhcpcd/dist/configure.c \
src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in \
src/external/bsd/dhcpcd/dist/dhcpcd.8.in \
src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in \
src/external/bsd/dhcpcd/dist/net.c src/external/bsd/dhcpcd/dist/signals.c
cvs rdiff -u -r1.1.1.2 -r1.1.1.2.10.1 src/external/bsd/dhcpcd/dist/dhcp.h
cvs rdiff -u -r1.1.1.1.8.1 -r1.1.1.1.8.1.2.1 \
src/external/bsd/dhcpcd/dist/net.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.647.2.6 src/doc/3RDPARTY:1.647.2.6.2.1
--- src/doc/3RDPARTY:1.647.2.6 Mon Mar 2 20:24:26 2009
+++ src/doc/3RDPARTY Tue Aug 4 20:23:37 2009
@@ -1,4 +1,4 @@
-# $NetBSD: 3RDPARTY,v 1.647.2.6 2009/03/02 20:24:26 snj Exp $
+# $NetBSD: 3RDPARTY,v 1.647.2.6.2.1 2009/08/04 20:23:37 snj Exp $
#
# This file contains a list of the software that has been integrated into
# NetBSD where we are not the primary maintainer.
@@ -232,8 +232,8 @@
top of the current tree.
Package: dhcpcd
-Version: 4.0.10
-Current Vers: 4.0.10
+Version: 4.0.14
+Current Vers: 4.0.14/5.0.7
Maintainer: roy
Archive Site: ftp://roy.marples.name/pub/dhcpcd/
Home Page: http://roy.marples.name/projects/dhcpcd/
Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.1142.2.7 src/doc/CHANGES:1.1142.2.7.2.1
--- src/doc/CHANGES:1.1142.2.7 Mon Mar 2 21:02:25 2009
+++ src/doc/CHANGES Tue Aug 4 20:23:37 2009
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1142.2.7 $>
+# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1142.2.7.2.1 $>
#
#
# [Note: This file does not mention every change made to the NetBSD source tree.
@@ -1161,3 +1161,4 @@
ntp: import ntp 4.2.4p6.
openssl API related security fix. [kardel 20090108]
dhcpcd(8): Import 4.0.10 [roy 20090204]
+ dhcpcd(8): Import 4.0.14 [roy 20090804]
Index: src/external/bsd/dhcpcd/dist/client.c
diff -u src/external/bsd/dhcpcd/dist/client.c:1.1.1.2.6.2 src/external/bsd/dhcpcd/dist/client.c:1.1.1.2.6.2.2.1
--- src/external/bsd/dhcpcd/dist/client.c:1.1.1.2.6.2 Fri Feb 6 02:25:38 2009
+++ src/external/bsd/dhcpcd/dist/client.c Tue Aug 4 20:23:37 2009
@@ -368,7 +368,7 @@
return;
lease->addr.s_addr = dhcp->yiaddr;
- if (get_option_addr(&lease->net.s_addr, dhcp, DHO_SUBNETMASK) == -1)
+ if (get_option_addr(&lease->net, dhcp, DHO_SUBNETMASK) == -1)
lease->net.s_addr = get_netmask(dhcp->yiaddr);
if (get_option_uint32(&lease->leasetime, dhcp, DHO_LEASETIME) == 0) {
/* Ensure that we can use the lease */
@@ -685,7 +685,9 @@
if (r == -1) {
state->state = STATE_INIT;
timerclear(&state->timeout);
- timerclear(&state->stop);
+ /* We need to set a timeout so we fall through gracefully */
+ state->stop.tv_sec = 1;
+ state->stop.tv_usec = 0;
do_socket(state, SOCKET_CLOSED);
}
return r;
@@ -835,12 +837,24 @@
}
/* We configured our array in the order we should deal with them */
- for (i = 0; i < nfds; i++)
- if (fds[i].revents & POLLIN) {
+ for (i = 0; i < nfds; i++) {
+ if (fds[i].revents & POLLERR) {
+ syslog(LOG_ERR, "poll: POLLERR on fd %d", fds[i].fd);
+ errno = EBADF;
+ return -1;
+ }
+ if (fds[i].revents & POLLNVAL) {
+ syslog(LOG_ERR, "poll: POLLNVAL on fd %d", fds[i].fd);
+ errno = EINVAL;
+ return -1;
+ }
+ if (fds[i].revents & (POLLIN | POLLHUP)) {
*fd = fds[i].fd;
return r;
}
- return r;
+ }
+ /* We should never get here. */
+ return 0;
}
static int
@@ -1039,6 +1053,7 @@
{
logger(LOG_INFO, "probing for an IPV4LL address");
free(state->offer);
+ lease->frominfo = 0;
state->offer = ipv4ll_get_dhcp(0);
gotlease = 0;
}
@@ -1246,6 +1261,8 @@
timerclear(&state->stop);
/* FALLTHROUGH */
case STATE_INIT:
+ if (state->carrier == LINK_DOWN)
+ return 0;
do_socket(state, SOCKET_OPEN);
state->xid = arc4random();
iface->start_uptime = uptime();
@@ -1269,8 +1286,6 @@
}
/* FALLTHROUGH */
case STATE_INIT:
- if (state->carrier == LINK_DOWN)
- return 0;
if (lease->addr.s_addr == 0 ||
IN_LINKLOCAL(ntohl(iface->addr.s_addr)))
{
@@ -1346,7 +1361,7 @@
addr.s_addr = dhcp->yiaddr;
a = xstrdup(inet_ntoa(addr));
}
- r = get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID);
+ r = get_option_addr(&addr, dhcp, DHO_SERVERID);
if (dhcp->servername[0] && r == 0)
logger(lvl, "%s %s from %s `%s'", msg, a,
inet_ntoa(addr), dhcp->servername);
@@ -1374,7 +1389,12 @@
/* We have to have DHCP type to work */
if (get_option_uint8(&type, dhcp, DHO_MESSAGETYPE) == -1) {
- log_dhcp(LOG_ERR, "no DHCP type in", dhcp);
+ logger(LOG_ERR, "ignoring message; no DHCP type");
+ return 0;
+ }
+ /* Every DHCP message should include ServerID */
+ if (get_option_addr(&addr, dhcp, DHO_SERVERID) == -1) {
+ logger(LOG_ERR, "ignoring message; no Server ID");
return 0;
}
@@ -1382,7 +1402,7 @@
* We should expand this to check IP and/or hardware address
* at the packet level. */
if (options->blacklist_len != 0 &&
- get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID) == 0)
+ get_option_addr(&addr, dhcp, DHO_SERVERID) == 0)
{
for (i = 0; i < options->blacklist_len; i++) {
if (options->blacklist[i] != addr.s_addr)
@@ -1434,7 +1454,7 @@
if (type == DHCP_OFFER && state->state == STATE_DISCOVERING) {
lease->addr.s_addr = dhcp->yiaddr;
- get_option_addr(&lease->server.s_addr, dhcp, DHO_SERVERID);
+ get_option_addr(&lease->server, dhcp, DHO_SERVERID);
log_dhcp(LOG_INFO, "offered", dhcp);
if (state->options & DHCPCD_TEST) {
run_script(options, iface->name, "TEST", dhcp, NULL);
@@ -1467,7 +1487,7 @@
case STATE_RENEWING:
case STATE_REBINDING:
if (!(state->options & DHCPCD_INFORM)) {
- get_option_addr(&lease->server.s_addr,
+ get_option_addr(&lease->server,
dhcp, DHO_SERVERID);
log_dhcp(LOG_INFO, "acknowledged", dhcp);
}
@@ -1533,7 +1553,7 @@
}
if (bytes == -1)
break;
- if (valid_udp_packet(packet) == -1)
+ if (valid_udp_packet(packet, bytes) == -1)
continue;
bytes = get_udp_data(&pp, packet);
if ((size_t)bytes > sizeof(*dhcp)) {
Index: src/external/bsd/dhcpcd/dist/config.h
diff -u src/external/bsd/dhcpcd/dist/config.h:1.1.1.2.6.2 src/external/bsd/dhcpcd/dist/config.h:1.1.1.2.6.2.2.1
--- src/external/bsd/dhcpcd/dist/config.h:1.1.1.2.6.2 Fri Feb 6 02:25:38 2009
+++ src/external/bsd/dhcpcd/dist/config.h Tue Aug 4 20:23:37 2009
@@ -28,7 +28,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "4.0.10"
+#define VERSION "4.0.14"
/*
* By default we don't add a local link route if we got a routeable address.
Index: src/external/bsd/dhcpcd/dist/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/dhcp.c:1.1.1.2.6.2 src/external/bsd/dhcpcd/dist/dhcp.c:1.1.1.2.6.2.2.1
--- src/external/bsd/dhcpcd/dist/dhcp.c:1.1.1.2.6.2 Fri Feb 6 02:25:38 2009
+++ src/external/bsd/dhcpcd/dist/dhcp.c Tue Aug 4 20:23:37 2009
@@ -327,25 +327,27 @@
}
int
-get_option_addr(uint32_t *a, const struct dhcp_message *dhcp, uint8_t option)
+get_option_addr(struct in_addr *a, const struct dhcp_message *dhcp,
+ uint8_t option)
{
const uint8_t *p = get_option_raw(dhcp, option);
if (!p)
return -1;
- memcpy(a, p, sizeof(*a));
+ memcpy(&a->s_addr, p, sizeof(a->s_addr));
return 0;
}
int
get_option_uint32(uint32_t *i, const struct dhcp_message *dhcp, uint8_t option)
{
- uint32_t a;
+ const uint8_t *p = get_option_raw(dhcp, option);
+ uint32_t d;
- if (get_option_addr(&a, dhcp, option) == -1)
+ if (!p)
return -1;
-
- *i = ntohl(a);
+ memcpy(&d, p, sizeof(d));
+ *i = ntohl(d);
return 0;
}
@@ -1231,14 +1233,14 @@
* message but are not necessarily in the options */
addr.s_addr = dhcp->yiaddr;
setvar(&ep, prefix, "ip_address", inet_ntoa(addr));
- if (get_option_addr(&net.s_addr, dhcp, DHO_SUBNETMASK) == -1) {
+ if (get_option_addr(&net, dhcp, DHO_SUBNETMASK) == -1) {
net.s_addr = get_netmask(addr.s_addr);
setvar(&ep, prefix, "subnet_mask", inet_ntoa(net));
}
i = inet_ntocidr(net);
snprintf(cidr, sizeof(cidr), "%d", inet_ntocidr(net));
setvar(&ep, prefix, "subnet_cidr", cidr);
- if (get_option_addr(&brd.s_addr, dhcp, DHO_BROADCAST) == -1) {
+ if (get_option_addr(&brd, dhcp, DHO_BROADCAST) == -1) {
brd.s_addr = addr.s_addr | ~net.s_addr;
setvar(&ep, prefix, "broadcast_address", inet_ntoa(brd));
}
Index: src/external/bsd/dhcpcd/dist/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.c:1.1.1.2.6.2 src/external/bsd/dhcpcd/dist/dhcpcd.c:1.1.1.2.6.2.2.1
--- src/external/bsd/dhcpcd/dist/dhcpcd.c:1.1.1.2.6.2 Fri Feb 6 02:25:38 2009
+++ src/external/bsd/dhcpcd/dist/dhcpcd.c Tue Aug 4 20:23:37 2009
@@ -619,7 +619,7 @@
closefrom(3);
/* Saves calling fflush(stream) in the logger */
setlinebuf(stdout);
- openlog(PACKAGE, LOG_PID, LOG_LOCAL0);
+ openlog(PACKAGE, LOG_PID, LOG_DAEMON);
setlogprefix(PACKAGE ": ");
options = xzalloc(sizeof(*options));
Index: src/external/bsd/dhcpcd/dist/configure.c
diff -u src/external/bsd/dhcpcd/dist/configure.c:1.1.1.2.6.1 src/external/bsd/dhcpcd/dist/configure.c:1.1.1.2.6.1.2.1
--- src/external/bsd/dhcpcd/dist/configure.c:1.1.1.2.6.1 Fri Jan 9 03:13:49 2009
+++ src/external/bsd/dhcpcd/dist/configure.c Tue Aug 4 20:23:37 2009
@@ -357,9 +357,9 @@
if (addr.s_addr == 0)
addr.s_addr = lease->addr.s_addr;
/* Ensure we have all the needed values */
- if (get_option_addr(&net.s_addr, dhcp, DHO_SUBNETMASK) == -1)
+ if (get_option_addr(&net, dhcp, DHO_SUBNETMASK) == -1)
net.s_addr = get_netmask(addr.s_addr);
- if (get_option_addr(&brd.s_addr, dhcp, DHO_BROADCAST) == -1)
+ if (get_option_addr(&brd, dhcp, DHO_BROADCAST) == -1)
brd.s_addr = addr.s_addr | ~net.s_addr;
}
Index: src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in
diff -u src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in:1.1.1.2.6.1 src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in:1.1.1.2.6.1.2.1
--- src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in:1.1.1.2.6.1 Fri Jan 9 03:13:49 2009
+++ src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in Tue Aug 4 20:23:37 2009
@@ -24,6 +24,7 @@
.\"
.Dd August 14, 2008
.Dt DHCPCD.SH 8 SMM
+.Os
.Sh NAME
.Nm dhcpcd-run-hooks
.Nd DHCP client configuration script
Index: src/external/bsd/dhcpcd/dist/dhcpcd.8.in
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.1.1.2.6.1 src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.1.1.2.6.1.2.1
--- src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.1.1.2.6.1 Fri Jan 9 03:13:49 2009
+++ src/external/bsd/dhcpcd/dist/dhcpcd.8.in Tue Aug 4 20:23:37 2009
@@ -24,6 +24,7 @@
.\"
.Dd November 18, 2008
.Dt DHCPCD 8 SMM
+.Os
.Sh NAME
.Nm dhcpcd
.Nd an RFC 2131 compliant DHCP client
@@ -335,7 +336,7 @@
.Ar clientid
of the hardware family and the hardware address.
.El
-.Ss Restriciting behaviour
+.Ss Restricting behaviour
.Nm
will try to do as much as it can by default.
However, there are sometimes situations where you don't want the things to be
Index: src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in:1.1.1.2.6.1 src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in:1.1.1.2.6.1.2.1
--- src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in:1.1.1.2.6.1 Fri Jan 9 03:13:49 2009
+++ src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in Tue Aug 4 20:23:37 2009
@@ -24,6 +24,7 @@
.\"
.Dd November 18, 2008
.Dt DHCPCD.CONF 5 SMM
+.Os
.Sh NAME
.Nm dhcpcd.conf
.Nd dhcpcd configuration file
Index: src/external/bsd/dhcpcd/dist/net.c
diff -u src/external/bsd/dhcpcd/dist/net.c:1.1.1.2.6.1 src/external/bsd/dhcpcd/dist/net.c:1.1.1.2.6.1.2.1
--- src/external/bsd/dhcpcd/dist/net.c:1.1.1.2.6.1 Fri Jan 9 03:13:50 2009
+++ src/external/bsd/dhcpcd/dist/net.c Tue Aug 4 20:23:37 2009
@@ -634,44 +634,42 @@
}
int
-valid_udp_packet(const uint8_t *data)
+valid_udp_packet(const uint8_t *data, size_t data_len)
{
struct udp_dhcp_packet packet;
- uint16_t bytes;
- uint16_t ipsum;
- uint16_t iplen;
- uint16_t udpsum;
- struct in_addr source;
- struct in_addr dest;
- int retval = 0;
+ uint16_t bytes, udpsum;
- memcpy(&packet, data, sizeof(packet));
- bytes = ntohs(packet.ip.ip_len);
- ipsum = packet.ip.ip_sum;
- iplen = packet.ip.ip_len;
- udpsum = packet.udp.uh_sum;
-
- if (0 != checksum(&packet.ip, sizeof(packet.ip))) {
+ if (data_len > sizeof(packet)) {
+ errno = EINVAL;
+ return -1;
+ }
+ memcpy(&packet, data, data_len);
+ if (checksum(&packet.ip, sizeof(packet.ip)) != 0) {
errno = EINVAL;
return -1;
}
- packet.ip.ip_sum = 0;
- memcpy(&source, &packet.ip.ip_src, sizeof(packet.ip.ip_src));
- memcpy(&dest, &packet.ip.ip_dst, sizeof(packet.ip.ip_dst));
- memset(&packet.ip, 0, sizeof(packet.ip));
+ bytes = ntohs(packet.ip.ip_len);
+ if (data_len < bytes) {
+ errno = EINVAL;
+ return -1;
+ }
+ udpsum = packet.udp.uh_sum;
packet.udp.uh_sum = 0;
-
- packet.ip.ip_p = IPPROTO_UDP;
- memcpy(&packet.ip.ip_src, &source, sizeof(packet.ip.ip_src));
- memcpy(&packet.ip.ip_dst, &dest, sizeof(packet.ip.ip_dst));
+ packet.ip.ip_hl = 0;
+ packet.ip.ip_v = 0;
+ packet.ip.ip_tos = 0;
packet.ip.ip_len = packet.udp.uh_ulen;
- if (udpsum && udpsum != checksum(&packet, bytes)) {
+ packet.ip.ip_id = 0;
+ packet.ip.ip_off = 0;
+ packet.ip.ip_ttl = 0;
+ packet.ip.ip_sum = 0;
+ if (udpsum && checksum(&packet, bytes) != udpsum) {
errno = EINVAL;
- retval = -1;
+ return -1;
}
- return retval;
+ return 0;
}
int
Index: src/external/bsd/dhcpcd/dist/signals.c
diff -u src/external/bsd/dhcpcd/dist/signals.c:1.1.1.2.6.1 src/external/bsd/dhcpcd/dist/signals.c:1.1.1.2.6.1.2.1
--- src/external/bsd/dhcpcd/dist/signals.c:1.1.1.2.6.1 Fri Feb 6 02:25:38 2009
+++ src/external/bsd/dhcpcd/dist/signals.c Tue Aug 4 20:23:37 2009
@@ -71,11 +71,11 @@
{
int sig = -1;
char buf[16];
- size_t bytes;
+ ssize_t bytes;
memset(buf, 0, sizeof(buf));
bytes = read(signal_pipe[0], buf, sizeof(buf));
- if (bytes >= sizeof(sig))
+ if (bytes >= 0 && (size_t)bytes >= sizeof(sig))
memcpy(&sig, buf, sizeof(sig));
return sig;
}
Index: src/external/bsd/dhcpcd/dist/dhcp.h
diff -u src/external/bsd/dhcpcd/dist/dhcp.h:1.1.1.2 src/external/bsd/dhcpcd/dist/dhcp.h:1.1.1.2.10.1
--- src/external/bsd/dhcpcd/dist/dhcp.h:1.1.1.2 Fri Sep 19 22:59:58 2008
+++ src/external/bsd/dhcpcd/dist/dhcp.h Tue Aug 4 20:23:37 2009
@@ -160,7 +160,7 @@
int make_option_mask(uint8_t *, char **, int);
void print_options(void);
char *get_option_string(const struct dhcp_message *, uint8_t);
-int get_option_addr(uint32_t *, const struct dhcp_message *, uint8_t);
+int get_option_addr(struct in_addr *, const struct dhcp_message *, uint8_t);
int get_option_uint32(uint32_t *, const struct dhcp_message *, uint8_t);
int get_option_uint16(uint16_t *, const struct dhcp_message *, uint8_t);
int get_option_uint8(uint8_t *, const struct dhcp_message *, uint8_t);
Index: src/external/bsd/dhcpcd/dist/net.h
diff -u src/external/bsd/dhcpcd/dist/net.h:1.1.1.1.8.1 src/external/bsd/dhcpcd/dist/net.h:1.1.1.1.8.1.2.1
--- src/external/bsd/dhcpcd/dist/net.h:1.1.1.1.8.1 Fri Jan 9 03:13:50 2009
+++ src/external/bsd/dhcpcd/dist/net.h Tue Aug 4 20:23:37 2009
@@ -160,7 +160,7 @@
ssize_t make_udp_packet(uint8_t **, const uint8_t *, size_t,
struct in_addr, struct in_addr);
ssize_t get_udp_data(const uint8_t **, const uint8_t *);
-int valid_udp_packet(const uint8_t *);
+int valid_udp_packet(const uint8_t *, size_t);
int open_socket(struct interface *, int);
ssize_t send_packet(const struct interface *, struct in_addr,