Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/ROY]: src/external/bsd/dhcpcd/dist/src Import dhcpcd-8.0.3 With the foll...
details: https://anonhg.NetBSD.org/src/rev/63776f21efa0
branches: ROY
changeset: 455226:63776f21efa0
user: roy <roy%NetBSD.org@localhost>
date: Wed Aug 21 17:10:29 2019 +0000
description:
Import dhcpcd-8.0.3 With the following changes:
* DHCP: Work with IP headers with options
* script: Assert that env string are correctly terminated
* script: Terminate env strings with no value
* script: Don't attempt to use an invalid env string
* route: Fix NULL deference error when using static routes
* ARP: Respect IFF_NOARP
* DHCP: Allow full DHCP support for PtP interfaces, but not by default
* control: sends correct buffer to listeners
dhcpcd-ui now correctly reports SSD association and all the addresses obtained (regression from dhcpcd-7)
diffstat:
external/bsd/dhcpcd/dist/src/bpf.c | 15 ++
external/bsd/dhcpcd/dist/src/control.c | 152 +++++++++++++++++-----------
external/bsd/dhcpcd/dist/src/control.h | 15 ++-
external/bsd/dhcpcd/dist/src/defs.h | 2 +-
external/bsd/dhcpcd/dist/src/dhcp-common.c | 59 ++++++----
external/bsd/dhcpcd/dist/src/dhcp.c | 79 ++++++--------
external/bsd/dhcpcd/dist/src/dhcpcd.c | 9 +-
external/bsd/dhcpcd/dist/src/duid.c | 10 +-
external/bsd/dhcpcd/dist/src/if-bsd.c | 37 ++++---
external/bsd/dhcpcd/dist/src/if-options.c | 4 +-
external/bsd/dhcpcd/dist/src/if-options.h | 2 +-
external/bsd/dhcpcd/dist/src/if.c | 29 ++++-
external/bsd/dhcpcd/dist/src/ipv4.c | 19 ++-
external/bsd/dhcpcd/dist/src/ipv6.h | 10 +-
external/bsd/dhcpcd/dist/src/route.c | 27 ++++-
external/bsd/dhcpcd/dist/src/route.h | 1 +
external/bsd/dhcpcd/dist/src/sa.c | 4 +-
external/bsd/dhcpcd/dist/src/script.c | 45 +++++---
18 files changed, 312 insertions(+), 207 deletions(-)
diffs (truncated from 1140 to 300 lines):
diff -r f3d440123d19 -r 63776f21efa0 external/bsd/dhcpcd/dist/src/bpf.c
--- a/external/bsd/dhcpcd/dist/src/bpf.c Tue Jul 30 10:23:02 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/bpf.c Wed Aug 21 17:10:29 2019 +0000
@@ -558,6 +558,15 @@
#define BPF_M_UDP 3
#define BPF_M_UDPLEN 4
+#ifdef ARPHRD_NONE
+static const struct bpf_insn bpf_bootp_none[] = {
+ /* Set the frame header length to zero. */
+ BPF_STMT(BPF_LD + BPF_IMM, 0),
+ BPF_STMT(BPF_ST, BPF_M_FHLEN),
+};
+#define BPF_BOOTP_NONE_LEN __arraycount(bpf_bootp_none)
+#endif
+
static const struct bpf_insn bpf_bootp_ether[] = {
/* Make sure this is an IP packet. */
BPF_STMT(BPF_LD + BPF_H + BPF_ABS,
@@ -665,6 +674,12 @@
bp = bpf;
/* Check frame header. */
switch(ifp->family) {
+#ifdef ARPHRD_NONE
+ case ARPHRD_NONE:
+ memcpy(bp, bpf_bootp_none, sizeof(bpf_bootp_none));
+ bp += BPF_BOOTP_NONE_LEN;
+ break;
+#endif
case ARPHRD_ETHER:
memcpy(bp, bpf_bootp_ether, sizeof(bpf_bootp_ether));
bp += BPF_BOOTP_ETHER_LEN;
diff -r f3d440123d19 -r 63776f21efa0 external/bsd/dhcpcd/dist/src/control.c
--- a/external/bsd/dhcpcd/dist/src/control.c Tue Jul 30 10:23:02 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/control.c Wed Aug 21 17:10:29 2019 +0000
@@ -53,41 +53,26 @@
#endif
static void
-control_queue_purge(struct dhcpcd_ctx *ctx, char *data)
-{
- int found;
- struct fd_list *fp;
- struct fd_data *fpd;
-
- /* If no other fd queue has the same data, free it */
- found = 0;
- TAILQ_FOREACH(fp, &ctx->control_fds, next) {
- TAILQ_FOREACH(fpd, &fp->queue, next) {
- if (fpd->data == data) {
- found = 1;
- break;
- }
- }
- }
- if (!found)
- free(data);
-}
-
-static void
control_queue_free(struct fd_list *fd)
{
struct fd_data *fdp;
while ((fdp = TAILQ_FIRST(&fd->queue))) {
TAILQ_REMOVE(&fd->queue, fdp, next);
- if (fdp->freeit)
- control_queue_purge(fd->ctx, fdp->data);
+ if (fdp->data_size != 0)
+ free(fdp->data);
free(fdp);
}
+ fd->queue_len = 0;
+
+#ifdef CTL_FREE_LIST
while ((fdp = TAILQ_FIRST(&fd->free_queue))) {
TAILQ_REMOVE(&fd->free_queue, fdp, next);
+ if (fdp->data_size != 0)
+ free(fdp->data);
free(fdp);
}
+#endif
}
static void
@@ -161,29 +146,33 @@
len = sizeof(run);
if ((fd = accept(lfd, (struct sockaddr *)&run, &len)) == -1)
- return;
+ goto error;
if ((flags = fcntl(fd, F_GETFD, 0)) == -1 ||
fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)
- {
- close(fd);
- return;
- }
+ goto error;
if ((flags = fcntl(fd, F_GETFL, 0)) == -1 ||
fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1)
- {
- close(fd);
- return;
- }
+ goto error;
+
l = malloc(sizeof(*l));
- if (l) {
- l->ctx = ctx;
- l->fd = fd;
- l->flags = fd_flags;
- TAILQ_INIT(&l->queue);
- TAILQ_INIT(&l->free_queue);
- TAILQ_INSERT_TAIL(&ctx->control_fds, l, next);
- eloop_event_add(ctx->eloop, l->fd, control_handle_data, l);
- } else
+ if (l == NULL)
+ goto error;
+
+ l->ctx = ctx;
+ l->fd = fd;
+ l->flags = fd_flags;
+ TAILQ_INIT(&l->queue);
+ l->queue_len = 0;
+#ifdef CTL_FREE_LIST
+ TAILQ_INIT(&l->free_queue);
+#endif
+ TAILQ_INSERT_TAIL(&ctx->control_fds, l, next);
+ eloop_event_add(ctx->eloop, l->fd, control_handle_data, l);
+ return;
+
+error:
+ logerr(__func__);
+ if (fd != -1)
close(fd);
}
@@ -374,40 +363,85 @@
}
TAILQ_REMOVE(&fd->queue, data, next);
- if (data->freeit)
- control_queue_purge(fd->ctx, data->data);
- data->data = NULL; /* safety */
- data->data_len = 0;
+ fd->queue_len--;
+#ifdef CTL_FREE_LIST
TAILQ_INSERT_TAIL(&fd->free_queue, data, next);
+#else
+ if (data->data_size != 0)
+ free(data->data);
+ free(data);
+#endif
if (TAILQ_FIRST(&fd->queue) == NULL)
eloop_event_remove_writecb(fd->ctx->eloop, fd->fd);
}
int
-control_queue(struct fd_list *fd, char *data, size_t data_len, uint8_t fit)
+control_queue(struct fd_list *fd, void *data, size_t data_len, bool fit)
{
struct fd_data *d;
- size_t n;
+
+#ifdef CTL_FREE_LIST
+ struct fd_data *df;
- d = TAILQ_FIRST(&fd->free_queue);
- if (d) {
+ d = NULL;
+ TAILQ_FOREACH(df, &fd->free_queue, next) {
+ if (!fit) {
+ if (df->data_size == 0) {
+ d = df;
+ break;
+ }
+ continue;
+ }
+ if (d == NULL || d->data_size < df->data_size) {
+ d = df;
+ if (d->data_size <= data_len)
+ break;
+ }
+ }
+ if (d != NULL)
TAILQ_REMOVE(&fd->free_queue, d, next);
- } else {
- n = 0;
- TAILQ_FOREACH(d, &fd->queue, next) {
- if (++n == CONTROL_QUEUE_MAX) {
- errno = ENOBUFS;
- return -1;
- }
+ else
+#endif
+ {
+ if (fd->queue_len == CONTROL_QUEUE_MAX) {
+ errno = ENOBUFS;
+ return -1;
}
- d = malloc(sizeof(*d));
+ fd->queue_len++;
+ d = calloc(1, sizeof(*d));
if (d == NULL)
return -1;
}
- d->data = data;
+
+ if (!fit) {
+#ifdef CTL_FREE_LIST
+ if (d->data_size != 0) {
+ free(d->data);
+ d->data_size = 0;
+ }
+#endif
+ d->data = data;
+ d->data_len = data_len;
+ goto queue;
+ }
+
+ if (d->data_size == 0)
+ d->data = NULL;
+ if (d->data_size < data_len) {
+ void *nbuf = realloc(d->data, data_len);
+ if (nbuf == NULL) {
+ free(d->data);
+ free(d);
+ return -1;
+ }
+ d->data = nbuf;
+ d->data_size = data_len;
+ }
+ memcpy(d->data, data, data_len);
d->data_len = data_len;
- d->freeit = fit;
+
+queue:
TAILQ_INSERT_TAIL(&fd->queue, d, next);
eloop_event_add_w(fd->ctx->eloop, fd->fd, control_writeone, fd);
return 0;
diff -r f3d440123d19 -r 63776f21efa0 external/bsd/dhcpcd/dist/src/control.h
--- a/external/bsd/dhcpcd/dist/src/control.h Tue Jul 30 10:23:02 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/control.h Wed Aug 21 17:10:29 2019 +0000
@@ -31,14 +31,20 @@
#include "dhcpcd.h"
+#if !defined(CTL_FREE_LIST)
+#define CTL_FREE_LIST 1
+#elif CTL_FREE_LIST == 0
+#undef CTL_FREE_LIST
+#endif
+
/* Limit queue size per fd */
#define CONTROL_QUEUE_MAX 100
struct fd_data {
TAILQ_ENTRY(fd_data) next;
- char *data;
+ void *data;
+ size_t data_size;
size_t data_len;
- uint8_t freeit;
};
TAILQ_HEAD(fd_data_head, fd_data);
@@ -48,7 +54,10 @@
int fd;
unsigned int flags;
struct fd_data_head queue;
+ size_t queue_len;
+#ifdef CTL_FREE_LIST
struct fd_data_head free_queue;
+#endif
};
TAILQ_HEAD(fd_list_head, fd_list);
@@ -59,7 +68,7 @@
int control_stop(struct dhcpcd_ctx *);
int control_open(const char *);
ssize_t control_send(struct dhcpcd_ctx *, int, char * const *);
-int control_queue(struct fd_list *fd, char *data, size_t data_len, uint8_t fit);
+int control_queue(struct fd_list *, void *, size_t, bool);
void control_close(struct dhcpcd_ctx *ctx);
#endif
diff -r f3d440123d19 -r 63776f21efa0 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h Tue Jul 30 10:23:02 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h Wed Aug 21 17:10:29 2019 +0000
@@ -29,7 +29,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "8.0.2"
+#define VERSION "8.0.3"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
diff -r f3d440123d19 -r 63776f21efa0 external/bsd/dhcpcd/dist/src/dhcp-common.c
Home |
Main Index |
Thread Index |
Old Index