Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/dhcpcd/dist Import dhcpcd-5.6.4 with the follow...
details: https://anonhg.NetBSD.org/src/rev/1003d7486d4a
branches: trunk
changeset: 783113:1003d7486d4a
user: roy <roy%NetBSD.org@localhost>
date: Thu Dec 06 11:11:35 2012 +0000
description:
Import dhcpcd-5.6.4 with the following changes:
* add interface scope to exported IPv6 link local addresses
* DUID feature works again
* If we receive >1 MTU in the RA we use the last one
* Expire RA options separately from the RA
* Merge multiple RA options together except when a single is needed
* Some memory leaks plugged
* Don't overwrite invalid memory when DNSSL options begin with a NULL
* Ensure we have a large enough buffer for an escaped DNSSL option from RA
diffstat:
external/bsd/dhcpcd/dist/bind.c | 6 +-
external/bsd/dhcpcd/dist/common.c | 24 +-
external/bsd/dhcpcd/dist/config.h | 1 +
external/bsd/dhcpcd/dist/defs.h | 2 +-
external/bsd/dhcpcd/dist/dhcp.h | 1 +
external/bsd/dhcpcd/dist/dhcpcd.c | 44 +++-
external/bsd/dhcpcd/dist/dhcpcd.h | 10 +-
external/bsd/dhcpcd/dist/duid.c | 73 ++++---
external/bsd/dhcpcd/dist/eloop.c | 11 +-
external/bsd/dhcpcd/dist/eloop.h | 1 +
external/bsd/dhcpcd/dist/if-bsd.c | 4 +-
external/bsd/dhcpcd/dist/ipv6.c | 60 ++++-
external/bsd/dhcpcd/dist/ipv6.h | 1 +
external/bsd/dhcpcd/dist/ipv6rs.c | 350 ++++++++++++++++++++++++++++++-------
external/bsd/dhcpcd/dist/ipv6rs.h | 8 +
15 files changed, 447 insertions(+), 149 deletions(-)
diffs (truncated from 1256 to 300 lines):
diff -r e29bf7b13738 -r 1003d7486d4a external/bsd/dhcpcd/dist/bind.c
--- a/external/bsd/dhcpcd/dist/bind.c Thu Dec 06 10:32:44 2012 +0000
+++ b/external/bsd/dhcpcd/dist/bind.c Thu Dec 06 11:11:35 2012 +0000
@@ -90,8 +90,7 @@
dup2(fd, STDIN_FILENO);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
- if (fd > STDERR_FILENO)
- close(fd);
+ close(fd);
}
break;
default:
@@ -223,6 +222,9 @@
add_timeout_sec(lease->renewaltime, start_renew, iface);
add_timeout_sec(lease->rebindtime, start_rebind, iface);
add_timeout_sec(lease->leasetime, start_expire, iface);
+ syslog(LOG_DEBUG,
+ "%s: renew in %u seconds, rebind in %u seconds",
+ iface->name, lease->renewaltime, lease->rebindtime);
}
ifo->options &= ~ DHCPCD_CSR_WARNED;
configure(iface);
diff -r e29bf7b13738 -r 1003d7486d4a external/bsd/dhcpcd/dist/common.c
--- a/external/bsd/dhcpcd/dist/common.c Thu Dec 06 10:32:44 2012 +0000
+++ b/external/bsd/dhcpcd/dist/common.c Thu Dec 06 11:11:35 2012 +0000
@@ -251,6 +251,7 @@
return 0;
}
+#ifndef xmalloc
void *
xmalloc(size_t s)
{
@@ -262,16 +263,9 @@
exit (EXIT_FAILURE);
/* NOTREACHED */
}
+#endif
-void *
-xzalloc(size_t s)
-{
- void *value = xmalloc(s);
-
- memset(value, 0, s);
- return value;
-}
-
+#ifndef xrealloc
void *
xrealloc(void *ptr, size_t s)
{
@@ -283,7 +277,9 @@
exit(EXIT_FAILURE);
/* NOTREACHED */
}
+#endif
+#ifndef xstrdup
char *
xstrdup(const char *str)
{
@@ -299,3 +295,13 @@
exit(EXIT_FAILURE);
/* NOTREACHED */
}
+#endif
+
+void *
+xzalloc(size_t s)
+{
+ void *value = xmalloc(s);
+
+ memset(value, 0, s);
+ return value;
+}
diff -r e29bf7b13738 -r 1003d7486d4a external/bsd/dhcpcd/dist/config.h
--- a/external/bsd/dhcpcd/dist/config.h Thu Dec 06 10:32:44 2012 +0000
+++ b/external/bsd/dhcpcd/dist/config.h Thu Dec 06 11:11:35 2012 +0000
@@ -4,3 +4,4 @@
#define LIBEXECDIR "/libexec"
#define DBDIR "/var/db"
#define RUNDIR "/var/run"
+#include <spawn.h>
diff -r e29bf7b13738 -r 1003d7486d4a external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h Thu Dec 06 10:32:44 2012 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h Thu Dec 06 11:11:35 2012 +0000
@@ -28,7 +28,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "5.6.2"
+#define VERSION "5.6.4"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
diff -r e29bf7b13738 -r 1003d7486d4a external/bsd/dhcpcd/dist/dhcp.h
--- a/external/bsd/dhcpcd/dist/dhcp.h Thu Dec 06 10:32:44 2012 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.h Thu Dec 06 11:11:35 2012 +0000
@@ -189,6 +189,7 @@
struct rt *get_option_routes(const struct dhcp_message *, const char *,
unsigned long long *);
ssize_t decode_rfc3397(char *, ssize_t, int, const uint8_t *);
+ssize_t print_string(char *, ssize_t, int, const uint8_t *);
ssize_t configure_env(char **, const char *, const struct dhcp_message *,
const struct if_options *);
diff -r e29bf7b13738 -r 1003d7486d4a external/bsd/dhcpcd/dist/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/dhcpcd.c Thu Dec 06 10:32:44 2012 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.c Thu Dec 06 11:11:35 2012 +0000
@@ -97,6 +97,7 @@
static char *cffile;
static char *pidfile;
static int linkfd = -1, ipv6rsfd = -1, ipv6nsfd = -1;
+static uint8_t *packet;
struct dhcp_op {
uint8_t value;
@@ -188,6 +189,7 @@
for (i = 0; i < ifdc; i++)
free(ifdv[i]);
free(ifdv);
+ free(packet);
#endif
if (linkfd != -1)
@@ -530,9 +532,13 @@
close_sockets(iface);
/* If we constantly get NAKS then we should slowly back off */
add_timeout_sec(state->nakoff, start_interface, iface);
- state->nakoff *= 2;
- if (state->nakoff > NAKOFF_MAX)
- state->nakoff = NAKOFF_MAX;
+ if (state->nakoff == 0)
+ state->nakoff = 1;
+ else {
+ state->nakoff *= 2;
+ if (state->nakoff > NAKOFF_MAX)
+ state->nakoff = NAKOFF_MAX;
+ }
return;
}
@@ -561,7 +567,7 @@
}
/* No NAK, so reset the backoff */
- state->nakoff = 1;
+ state->nakoff = 0;
if ((type == 0 || type == DHCP_OFFER) &&
state->state == DHS_DISCOVER)
@@ -656,7 +662,6 @@
handle_dhcp_packet(void *arg)
{
struct interface *iface = arg;
- uint8_t *packet;
struct dhcp_message *dhcp = NULL;
const uint8_t *pp;
ssize_t bytes;
@@ -666,7 +671,8 @@
/* We loop through until our buffer is empty.
* The benefit is that if we get >1 DHCP packet in our buffer and
* the first one fails for any reason, we can use the next. */
- packet = xmalloc(udp_dhcp_len);
+ if (packet == NULL)
+ packet = xmalloc(udp_dhcp_len);
for(;;) {
bytes = get_raw_packet(iface, ETHERTYPE_IP,
packet, udp_dhcp_len, &partialcsum);
@@ -735,6 +741,7 @@
break;
}
free(packet);
+ packet = NULL;
free(dhcp);
}
@@ -771,7 +778,7 @@
struct if_state *ifs = iface->state;
struct if_options *ifo = ifs->options;
uint8_t *duid;
- size_t len = 0, ifl;
+ size_t len, ifl;
/* Do any platform specific configuration */
if_conf(iface);
@@ -816,11 +823,13 @@
iface->clientid = xmalloc(ifo->clientid[0] + 1);
memcpy(iface->clientid, ifo->clientid, ifo->clientid[0] + 1);
} else if (ifo->options & DHCPCD_CLIENTID) {
+ len = 0;
if (ifo->options & DHCPCD_DUID) {
duid = xmalloc(DUID_LEN);
if ((len = get_duid(duid, iface)) == 0)
syslog(LOG_ERR, "get_duid: %m");
- }
+ } else
+ duid = NULL;
if (len > 0) {
iface->clientid = xmalloc(len + 6);
iface->clientid[0] = len + 5;
@@ -835,6 +844,7 @@
ifl = htonl(iface->index);
memcpy(iface->clientid + 2, &ifl, 4);
}
+ memcpy(iface->clientid + 6, duid, len);
} else if (len == 0) {
len = iface->hwlen + 1;
iface->clientid = xmalloc(len + 1);
@@ -843,6 +853,7 @@
memcpy(iface->clientid + 2, iface->hwaddr,
iface->hwlen);
}
+ free(duid);
}
if (ifo->options & DHCPCD_CLIENTID)
syslog(LOG_DEBUG, "%s: using ClientID %s", iface->name,
@@ -1002,9 +1013,13 @@
start_renew(void *arg)
{
struct interface *iface = arg;
+ struct dhcp_lease *lease = &iface->state->lease;
syslog(LOG_INFO, "%s: renewing lease of %s",
- iface->name, inet_ntoa(iface->state->lease.addr));
+ iface->name, inet_ntoa(lease->addr));
+ syslog(LOG_DEBUG, "%s: rebind in %u seconds, expire in %u seconds",
+ iface->name, lease->rebindtime - lease->renewaltime,
+ lease->leasetime - lease->renewaltime);
iface->state->state = DHS_RENEW;
iface->state->xid = dhcp_xid(iface);
send_renew(iface);
@@ -1014,9 +1029,12 @@
start_rebind(void *arg)
{
struct interface *iface = arg;
+ struct dhcp_lease *lease = &iface->state->lease;
syslog(LOG_ERR, "%s: failed to renew, attempting to rebind",
iface->name);
+ syslog(LOG_DEBUG, "%s: expire in %u seconds",
+ iface->name, lease->leasetime - lease->rebindtime);
iface->state->state = DHS_REBIND;
delete_timeout(send_renew, iface);
iface->state->lease.server.s_addr = 0;
@@ -1257,7 +1275,7 @@
ifs->state = DHS_INIT;
ifs->reason = "PREINIT";
- ifs->nakoff = 1;
+ ifs->nakoff = 0;
configure_interface(iface, argc, argv);
if (!(options & DHCPCD_TEST))
run_script(iface);
@@ -1365,7 +1383,7 @@
ifp->name,
hwaddr_ntoa(ifp->hwaddr, ifp->hwlen));
ifp->state->interval = 0;
- ifp->state->nakoff = 1;
+ ifp->state->nakoff = 0;
start_interface(ifp);
}
}
@@ -1981,6 +1999,10 @@
syslog(LOG_INFO, "version " VERSION " starting");
+#ifdef DEBUG_MEMORY
+ eloop_init();
+#endif
+
if ((signal_fd = signal_init()) == -1)
exit(EXIT_FAILURE);
if (signal_setup() == -1)
diff -r e29bf7b13738 -r 1003d7486d4a external/bsd/dhcpcd/dist/dhcpcd.h
--- a/external/bsd/dhcpcd/dist/dhcpcd.h Thu Dec 06 10:32:44 2012 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.h Thu Dec 06 11:11:35 2012 +0000
@@ -60,6 +60,11 @@
#define LINK_UNKNOWN 0
#define LINK_DOWN -1
+#define IF_DATA_DHCP 0
+#define IF_DATA_IPV6RS 1
+#define IF_DATA_DHCP6 2
+#define IF_DATA_MAX 3
+
struct if_state {
enum DHS state;
char profile[PROFILE_LEN];
@@ -85,6 +90,7 @@
struct interface {
char name[IF_NAMESIZE];
struct if_state *state;
+ void *if_data[IF_DATA_MAX];
unsigned int index;
int flags;
@@ -111,10 +117,6 @@
Home |
Main Index |
Thread Index |
Old Index