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 Sync
details: https://anonhg.NetBSD.org/src/rev/0483ace29e11
branches: trunk
changeset: 342757:0483ace29e11
user: roy <roy%NetBSD.org@localhost>
date: Thu Jan 07 20:09:43 2016 +0000
description:
Sync
diffstat:
external/bsd/dhcpcd/dist/arp.c | 12 +-
external/bsd/dhcpcd/dist/bpf-filter.h | 10 +-
external/bsd/dhcpcd/dist/common.c | 8 +-
external/bsd/dhcpcd/dist/defs.h | 4 +-
external/bsd/dhcpcd/dist/dhcp-common.c | 99 ++++++-----
external/bsd/dhcpcd/dist/dhcp.c | 56 +++++-
external/bsd/dhcpcd/dist/dhcp.h | 3 +-
external/bsd/dhcpcd/dist/dhcp6.c | 35 ++-
external/bsd/dhcpcd/dist/dhcp6.h | 3 +-
external/bsd/dhcpcd/dist/dhcpcd-definitions.conf | 10 +-
external/bsd/dhcpcd/dist/dhcpcd-embedded.c | 8 +-
external/bsd/dhcpcd/dist/dhcpcd.8.in | 39 +++-
external/bsd/dhcpcd/dist/dhcpcd.c | 199 ++++++++++++++--------
external/bsd/dhcpcd/dist/dhcpcd.conf | 6 +-
external/bsd/dhcpcd/dist/dhcpcd.h | 14 +-
external/bsd/dhcpcd/dist/duid.c | 4 +-
external/bsd/dhcpcd/dist/if-bsd.c | 102 ++++++++--
external/bsd/dhcpcd/dist/if-options.c | 16 +-
external/bsd/dhcpcd/dist/if-options.h | 10 +-
external/bsd/dhcpcd/dist/if.c | 79 +++++---
external/bsd/dhcpcd/dist/if.h | 5 +-
external/bsd/dhcpcd/dist/ipv4.c | 14 +-
external/bsd/dhcpcd/dist/ipv6.c | 12 +-
external/bsd/dhcpcd/dist/ipv6.h | 10 +-
external/bsd/dhcpcd/dist/ipv6nd.c | 5 +-
25 files changed, 473 insertions(+), 290 deletions(-)
diffs (truncated from 1996 to 300 lines):
diff -r ea3ec33c0a1b -r 0483ace29e11 external/bsd/dhcpcd/dist/arp.c
--- a/external/bsd/dhcpcd/dist/arp.c Thu Jan 07 20:06:44 2016 +0000
+++ b/external/bsd/dhcpcd/dist/arp.c Thu Jan 07 20:09:43 2016 +0000
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: arp.c,v 1.15 2015/11/30 16:33:00 roy Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.16 2016/01/07 20:09:43 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -99,7 +99,8 @@
}
void
-arp_report_conflicted(const struct arp_state *astate, const struct arp_msg *amsg)
+arp_report_conflicted(const struct arp_state *astate,
+ const struct arp_msg *amsg)
{
if (amsg != NULL) {
@@ -149,15 +150,18 @@
/* Families must match */
if (ar.ar_hrd != htons(ifp->family))
continue;
+#if 0
+ /* These checks are enforced in the BPF filter. */
/* Protocol must be IP. */
if (ar.ar_pro != htons(ETHERTYPE_IP))
continue;
- if (ar.ar_pln != sizeof(arm.sip.s_addr))
- continue;
/* Only these types are recognised */
if (ar.ar_op != htons(ARPOP_REPLY) &&
ar.ar_op != htons(ARPOP_REQUEST))
continue;
+#endif
+ if (ar.ar_pln != sizeof(arm.sip.s_addr))
+ continue;
/* Get pointers to the hardware addreses */
hw_s = arp_buffer + sizeof(ar);
diff -r ea3ec33c0a1b -r 0483ace29e11 external/bsd/dhcpcd/dist/bpf-filter.h
--- a/external/bsd/dhcpcd/dist/bpf-filter.h Thu Jan 07 20:06:44 2016 +0000
+++ b/external/bsd/dhcpcd/dist/bpf-filter.h Thu Jan 07 20:09:43 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bpf-filter.h,v 1.9 2014/11/07 20:51:02 roy Exp $ */
+/* $NetBSD: bpf-filter.h,v 1.10 2016/01/07 20:09:43 roy Exp $ */
/*
* dhcpcd - DHCP client daemon
@@ -36,13 +36,15 @@
#ifndef BPF_SKIPTYPE
/* Make sure this is an ARP packet... */
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 12),
- BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_ARP, 0, 3),
+ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_ARP, 0, 6),
#endif
+ /* Make sure this is for IP ... */
+ BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 16 + BPF_ETHCOOK),
+ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 4),
/* Make sure this is an ARP REQUEST... */
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 20 + BPF_ETHCOOK),
- BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ARPOP_REQUEST, 2, 0),
+ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ARPOP_REQUEST, 1, 0),
/* or ARP REPLY... */
- BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 20 + BPF_ETHCOOK),
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ARPOP_REPLY, 0, 1),
/* If we passed all the tests, ask for the whole packet. */
BPF_STMT(BPF_RET + BPF_K, BPF_WHOLEPACKET),
diff -r ea3ec33c0a1b -r 0483ace29e11 external/bsd/dhcpcd/dist/common.c
--- a/external/bsd/dhcpcd/dist/common.c Thu Jan 07 20:06:44 2016 +0000
+++ b/external/bsd/dhcpcd/dist/common.c Thu Jan 07 20:09:43 2016 +0000
@@ -1,9 +1,9 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: common.c,v 1.17 2015/12/03 21:04:59 christos Exp $");
+ __RCSID("$NetBSD: common.c,v 1.18 2016/01/07 20:09:43 roy Exp $");
/*
* dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2015 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2016 Roy Marples <roy%marples.name@localhost>
* All rights reserved
* Redistribution and use in source and binary forms, with or without
@@ -116,6 +116,10 @@
char fmt_cpy[1024];
#endif
+ /* If we're printing the pidfile, don't do anything. */
+ if (ctx != NULL && ctx->options & DHCPCD_PRINT_PIDFILE)
+ return;
+
serrno = errno;
va_start(va, fmt);
diff -r ea3ec33c0a1b -r 0483ace29e11 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h Thu Jan 07 20:06:44 2016 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h Thu Jan 07 20:09:43 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.22 2015/11/30 16:33:00 roy Exp $ */
+/* $NetBSD: defs.h,v 1.23 2016/01/07 20:09:43 roy Exp $ */
/*
* dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "6.9.4"
+#define VERSION "6.10.0"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
diff -r ea3ec33c0a1b -r 0483ace29e11 external/bsd/dhcpcd/dist/dhcp-common.c
--- a/external/bsd/dhcpcd/dist/dhcp-common.c Thu Jan 07 20:06:44 2016 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp-common.c Thu Jan 07 20:09:43 2016 +0000
@@ -1,9 +1,9 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp-common.c,v 1.11 2015/11/30 16:33:00 roy Exp $");
+ __RCSID("$NetBSD: dhcp-common.c,v 1.12 2016/01/07 20:09:43 roy Exp $");
/*
* dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2015 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2016 Roy Marples <roy%marples.name@localhost>
* All rights reserved
* Redistribution and use in source and binary forms, with or without
@@ -64,7 +64,7 @@
return NULL;
buf[buf_len - 1] = '\0';
} else
- strlcpy(buf, ifo->hostname, sizeof(buf));
+ strlcpy(buf, ifo->hostname, buf_len);
/* Deny sending of these local hostnames */
if (strcmp(buf, "(none)") == 0 ||
@@ -582,48 +582,43 @@
return (ssize_t)bytes;
}
-#define ADDRSZ 4
#define ADDR6SZ 16
static ssize_t
dhcp_optlen(const struct dhcp_opt *opt, size_t dl)
{
size_t sz;
- if (opt->type == 0 ||
- opt->type & (STRING | BINHEX | RFC3442))
- {
- if (opt->len) {
- if ((size_t)opt->len > dl)
- return -1;
- return (ssize_t)opt->len;
- }
- return (ssize_t)dl;
- }
-
- if ((opt->type & (ADDRIPV4 | ARRAY)) == (ADDRIPV4 | ARRAY)) {
- if (dl < ADDRSZ)
- return -1;
- return (ssize_t)(dl - (dl % ADDRSZ));
- }
-
- if ((opt->type & (ADDRIPV6 | ARRAY)) == (ADDRIPV6 | ARRAY)) {
- if (dl < ADDR6SZ)
- return -1;
- return (ssize_t)(dl - (dl % ADDR6SZ));
- }
-
- if (opt->type & (UINT32 | ADDRIPV4))
+ if (opt->type & ADDRIPV6)
+ sz = ADDR6SZ;
+ else if (opt->type & (UINT32 | ADDRIPV4))
sz = sizeof(uint32_t);
else if (opt->type & UINT16)
sz = sizeof(uint16_t);
else if (opt->type & (UINT8 | BITFLAG))
sz = sizeof(uint8_t);
- else if (opt->type & ADDRIPV6)
- sz = ADDR6SZ;
- else
- /* If we don't know the size, assume it's valid */
+ else if (opt->type & FLAG)
+ return 0;
+ else {
+ /* All other types are variable length */
+ if (opt->len) {
+ if ((size_t)opt->len > dl) {
+ errno = EOVERFLOW;
+ return -1;
+ }
+ return (ssize_t)opt->len;
+ }
return (ssize_t)dl;
- return dl < sz ? -1 : (ssize_t)sz;
+ }
+ if (dl < sz) {
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+ /* Trim any extra data.
+ * Maybe we need a settng to reject DHCP options with extra data? */
+ if (opt->type & ARRAY)
+ return (ssize_t)(dl - (dl % sz));
+ return (ssize_t)sz;
}
static ssize_t
@@ -838,7 +833,7 @@
}
static size_t
-dhcp_envoption1(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
+dhcp_envoption1(char **env, const char *prefix,
const struct dhcp_opt *opt, int vname, const uint8_t *od, size_t ol,
const char *ifname)
{
@@ -846,8 +841,11 @@
size_t e;
char *v, *val;
- if (opt->len && opt->len < ol)
- ol = opt->len;
+ /* Ensure a valid length */
+ ol = (size_t)dhcp_optlen(opt, ol);
+ if ((ssize_t)ol == -1)
+ return 0;
+
len = print_option(NULL, 0, opt, od, ol, ifname);
if (len < 0)
return 0;
@@ -861,10 +859,8 @@
if (env == NULL)
return e;
v = val = *env = malloc(e);
- if (v == NULL) {
- logger(ctx, LOG_ERR, "%s: %m", __func__);
+ if (v == NULL)
return 0;
- }
if (vname)
v += snprintf(val, e, "%s_%s=", prefix, opt->var);
else
@@ -892,10 +888,14 @@
/* If no embedded or encapsulated options, it's easy */
if (opt->embopts_len == 0 && opt->encopts_len == 0) {
- if (!(opt->type & RESERVED) &&
- dhcp_envoption1(ctx, env == NULL ? NULL : &env[0],
- prefix, opt, 1, od, ol, ifname))
- return 1;
+ if (!(opt->type & RESERVED)) {
+ if (dhcp_envoption1(env == NULL ? NULL : &env[0],
+ prefix, opt, 1, od, ol, ifname))
+ return 1;
+ else
+ logger(ctx, LOG_ERR, "%s: %s %d: %m",
+ ifname, __func__, opt->option);
+ }
return 0;
}
@@ -931,8 +931,8 @@
if (eo == -1) {
if (env == NULL)
logger(ctx, LOG_ERR,
- "%s: %s: malformed embedded option"
- " %d:%d/%zu",
+ "%s: %s %d.%d/%zu: "
+ "malformed embedded option",
ifname, __func__, opt->option,
eopt->option, i);
goto out;
@@ -946,7 +946,7 @@
if (env == NULL &&
(ol != 0 || !(eopt->type & OPTIONAL)))
logger(ctx, LOG_ERR,
- "%s: %s: missing embedded option %d:%d/%zu",
+ "%s: %s %d.%d/%zu: missing embedded option",
ifname, __func__, opt->option,
eopt->option, i);
goto out;
@@ -956,9 +956,14 @@
* This avoids new_fqdn_fqdn which would be silly. */
if (!(eopt->type & RESERVED)) {
ov = strcmp(opt->var, eopt->var);
- if (dhcp_envoption1(ctx, env == NULL ? NULL : &env[n],
+ if (dhcp_envoption1(env == NULL ? NULL : &env[n],
pfx, eopt, ov, od, (size_t)eo, ifname))
n++;
+ else if (env == NULL)
+ logger(ctx, LOG_ERR,
+ "%s: %s %d.%d/%zu: %m",
+ ifname, __func__,
+ opt->option, eopt->option, i);
}
od += (size_t)eo;
Home |
Main Index |
Thread Index |
Old Index