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-7.0.2 with the follow...
details: https://anonhg.NetBSD.org/src/rev/47a3c576f112
branches: trunk
changeset: 321603:47a3c576f112
user: roy <roy%NetBSD.org@localhost>
date: Tue Mar 27 06:14:39 2018 +0000
description:
Import dhcpcd-7.0.2 with the following changes:
* Added support for setproctitle(3)
* Kernel RA is no longer disabled when IPv6 is disabled in dhcpcd
* DHCPv6 PD is no longer stopped if no Routers are found
* If the DHCP leased address is deleted, enter the reboot state
* DHCPv6 unicast is no longer performed when not in master mode
* dhcpcd will now detect netlink/route socket overflows ad re-sync
diffstat:
external/bsd/dhcpcd/dist/configure | 21 +
external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in | 15 +-
external/bsd/dhcpcd/dist/src/arp.c | 32 +-
external/bsd/dhcpcd/dist/src/common.h | 2 +-
external/bsd/dhcpcd/dist/src/defs.h | 2 +-
external/bsd/dhcpcd/dist/src/dhcp.h | 2 +-
external/bsd/dhcpcd/dist/src/dhcp6.c | 79 +++---
external/bsd/dhcpcd/dist/src/dhcp6.h | 2 +-
external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in | 6 +-
external/bsd/dhcpcd/dist/src/dhcpcd.h | 1 +
external/bsd/dhcpcd/dist/src/if-bsd.c | 217 ++++++++----------
external/bsd/dhcpcd/dist/src/if-linux.c | 52 +--
external/bsd/dhcpcd/dist/src/if-sun.c | 10 +-
external/bsd/dhcpcd/dist/src/if.c | 34 ++-
external/bsd/dhcpcd/dist/src/if.h | 4 +-
external/bsd/dhcpcd/dist/src/ipv4.c | 71 +++++-
external/bsd/dhcpcd/dist/src/ipv4.h | 7 +-
external/bsd/dhcpcd/dist/src/ipv6.c | 62 +++-
external/bsd/dhcpcd/dist/src/ipv6.h | 8 +-
external/bsd/dhcpcd/dist/src/ipv6nd.c | 72 +++---
external/bsd/dhcpcd/dist/src/ipv6nd.h | 2 +-
21 files changed, 407 insertions(+), 294 deletions(-)
diffs (truncated from 1390 to 300 lines):
diff -r d22798b35a96 -r 47a3c576f112 external/bsd/dhcpcd/dist/configure
--- a/external/bsd/dhcpcd/dist/configure Mon Mar 26 21:43:30 2018 +0000
+++ b/external/bsd/dhcpcd/dist/configure Tue Mar 27 06:14:39 2018 +0000
@@ -799,6 +799,27 @@
fi
fi
+if [ -z "$SETPROCTITLE" ]; then
+ printf "Testing for setproctitle ... "
+ cat << EOF >_setproctitle.c
+#include <stdlib.h>
+int main(void) {
+ setproctitle("foo");
+ return 0;
+}
+EOF
+ if $XCC _setproctitle.c -o _setproctitle 2>&3; then
+ SETPROCTITLE=yes
+ else
+ SETPROCTITLE=no
+ fi
+ echo "$SETPROCTITLE"
+ rm -f _setproctitle.c _setproctitle
+fi
+if [ "$SETPROCTITLE" = yes ]; then
+ echo "#define HAVE_SETPROCTITLE" >>$CONFIG_H
+fi
+
if [ -z "$STRTOI" ]; then
printf "Testing for strtoi ... "
cat <<EOF >_strtoi.c
diff -r d22798b35a96 -r 47a3c576f112 external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in
--- a/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in Mon Mar 26 21:43:30 2018 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in Tue Mar 27 06:14:39 2018 +0000
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd November 3, 2017
+.Dd February 20, 2018
.Dt DHCPCD-RUN-HOOKS 8
.Os
.Sh NAME
@@ -47,6 +47,19 @@
A test hook is also supplied that simply echos the dhcp variables to the
console from DISCOVER message.
.Pp
+The hooks scripts are loaded into the current shell rather than executed
+in their own process.
+This allows each hook script, such as
+.Pa @SYSCONFDIR@/dhcpcd.enter-hook
+to customise environment variables or provide alternative functions to hooks
+further down the chain.
+As such, using the shell builtins
+.Ic exit ,
+.Ic exec
+or similar will cause
+.Nm
+to exit at that point.
+.Pp
Each time
.Nm
is invoked,
diff -r d22798b35a96 -r 47a3c576f112 external/bsd/dhcpcd/dist/src/arp.c
--- a/external/bsd/dhcpcd/dist/src/arp.c Mon Mar 26 21:43:30 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.c Tue Mar 27 06:14:39 2018 +0000
@@ -561,28 +561,28 @@
void
arp_handleifa(int cmd, struct ipv4_addr *addr)
{
-#ifdef IN_IFF_DUPLICATED
struct iarp_state *state;
struct arp_state *astate, *asn;
- /* If the address is deleted, the ARP state should be freed by the
- * state owner, such as DHCP or IPv4LL. */
- if (cmd != RTM_NEWADDR || (state = ARP_STATE(addr->iface)) == NULL)
+ state = ARP_STATE(addr->iface);
+ if (state == NULL)
return;
TAILQ_FOREACH_SAFE(astate, &state->arp_states, next, asn) {
- if (astate->addr.s_addr == addr->addr.s_addr) {
- if (addr->addr_flags & IN_IFF_DUPLICATED) {
- if (astate->conflicted_cb)
- astate->conflicted_cb(astate, NULL);
- } else if (!(addr->addr_flags & IN_IFF_NOTUSEABLE)) {
- if (astate->probed_cb)
- astate->probed_cb(astate);
- }
+ if (astate->addr.s_addr != addr->addr.s_addr)
+ continue;
+ if (cmd == RTM_DELADDR)
+ arp_free(astate);
+#ifdef IN_IFF_DUPLICATED
+ if (cmd != RTM_NEWADDR)
+ continue;
+ if (addr->addr_flags & IN_IFF_DUPLICATED) {
+ if (astate->conflicted_cb)
+ astate->conflicted_cb(astate, NULL);
+ } else if (!(addr->addr_flags & IN_IFF_NOTUSEABLE)) {
+ if (astate->probed_cb)
+ astate->probed_cb(astate);
}
+#endif
}
-#else
- UNUSED(cmd);
- UNUSED(addr);
-#endif
}
diff -r d22798b35a96 -r 47a3c576f112 external/bsd/dhcpcd/dist/src/common.h
--- a/external/bsd/dhcpcd/dist/src/common.h Mon Mar 26 21:43:30 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/common.h Tue Mar 27 06:14:39 2018 +0000
@@ -141,7 +141,7 @@
# define __CTASSERT99(x, a, b) __CTASSERT0(x, __CONCAT(__ctassert,a), \
__CONCAT(_,b))
# endif
-# define __CTASSERT0(x, y, z) __CTASSERT1(x, y, z)
+# define __CTASSERT0(x, y, z) __CTASSERT1(x, y, z)
# define __CTASSERT1(x, y, z) typedef char y ## z[/*CONSTCOND*/(x) ? 1 : -1] __unused
#endif
diff -r d22798b35a96 -r 47a3c576f112 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h Mon Mar 26 21:43:30 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h Tue Mar 27 06:14:39 2018 +0000
@@ -28,7 +28,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "7.0.1"
+#define VERSION "7.0.2"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
diff -r d22798b35a96 -r 47a3c576f112 external/bsd/dhcpcd/dist/src/dhcp.h
--- a/external/bsd/dhcpcd/dist/src/dhcp.h Mon Mar 26 21:43:30 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.h Tue Mar 27 06:14:39 2018 +0000
@@ -254,7 +254,7 @@
ssize_t dhcp_env(char **, const char *, const struct bootp *, size_t,
const struct interface *);
-void dhcp_handleifa(int, struct ipv4_addr *);
+void dhcp_handleifa(int, struct ipv4_addr *, pid_t pid);
void dhcp_drop(struct interface *, const char *);
void dhcp_start(struct interface *);
void dhcp_abort(struct interface *);
diff -r d22798b35a96 -r 47a3c576f112 external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c Mon Mar 26 21:43:30 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c Tue Mar 27 06:14:39 2018 +0000
@@ -777,6 +777,15 @@
return -1;
}
+ /* In non master mode we listen and send from fixed addresses.
+ * We should try and match an address we have to unicast to,
+ * but for now this is the safest policy. */
+ if (unicast != NULL && !(ifp->ctx->options & DHCPCD_MASTER)) {
+ logdebugx("%s: ignoring unicast option as not master",
+ ifp->name);
+ unicast = NULL;
+ }
+
#ifdef AUTH
auth_len = 0;
if (ifo->auth.options & DHCPCD_AUTH_SEND) {
@@ -1092,6 +1101,8 @@
uint8_t neg;
const char *broad_uni;
const struct in6_addr alldhcp = IN6ADDR_LINKLOCAL_ALLDHCP_INIT;
+ struct ipv6_addr *lla;
+ int s;
if (!callback && ifp->carrier == LINK_DOWN)
return 0;
@@ -1104,12 +1115,13 @@
#endif
state = D6_STATE(ifp);
+ lla = ipv6_linklocal(ifp);
/* We need to ensure we have sufficient scope to unicast the address */
/* XXX FIXME: We should check any added addresses we have like from
* a Router Advertisement */
if (IN6_IS_ADDR_UNSPECIFIED(&state->unicast) ||
(state->state == DH6S_REQUEST &&
- (!IN6_IS_ADDR_LINKLOCAL(&state->unicast) || !ipv6_linklocal(ifp))))
+ (!IN6_IS_ADDR_LINKLOCAL(&state->unicast) || lla == NULL)))
{
dst.sin6_addr = alldhcp;
broad_uni = "broadcasting";
@@ -1251,7 +1263,16 @@
ctx->sndhdr.msg_controllen = 0;
}
- if (sendmsg(ctx->dhcp6_fd, &ctx->sndhdr, 0) == -1) {
+ if (ctx->dhcp6_fd != -1)
+ s = ctx->dhcp6_fd;
+ else if (lla != NULL && lla->dhcp6_fd != -1)
+ s = lla->dhcp6_fd;
+ else {
+ logerrx("%s: no socket to send from", ifp->name);
+ return -1;
+ }
+
+ if (sendmsg(s, &ctx->sndhdr, 0) == -1) {
logerr("%s: %s: sendmsg", __func__, ifp->name);
/* Allow DHCPv6 to continue .... the errors
* would be rate limited by the protocol.
@@ -3551,19 +3572,16 @@
if (ia != NULL) {
memcpy(&sa.sin6_addr, &ia->addr, sizeof(sa.sin6_addr));
sa.sin6_scope_id = ia->iface->index;
- } else if (!(ctx->options & DHCPCD_MASTER))
- /* This socket is only used for sending. */
- return s;
+ }
if (bind(s, (struct sockaddr *)&sa, sizeof(sa)) == -1)
goto errexit;
- if (ia == NULL) {
- n = 1;
- if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO,
- &n, sizeof(n)) == -1)
- goto errexit;
- } else {
+ n = 1;
+ if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &n, sizeof(n)) == -1)
+ goto errexit;
+
+ if (ia != NULL) {
ia->dhcp6_fd = s;
eloop_event_add(ctx->eloop, s, dhcp6_recvaddr, ia);
}
@@ -3577,18 +3595,6 @@
return -1;
}
-static int
-dhcp6_open(struct dhcpcd_ctx *ctx)
-{
-
- /* Open an unbound socket to send from. */
- ctx->dhcp6_fd = dhcp6_listen(ctx, NULL);
- if (ctx->dhcp6_fd != -1 && (ctx->options & DHCPCD_MASTER))
- eloop_event_add(ctx->eloop, ctx->dhcp6_fd, dhcp6_recvctx, ctx);
-
- return ctx->dhcp6_fd;
-}
-
#ifndef SMALL
static void
dhcp6_activateinterfaces(struct interface *ifp)
@@ -3623,13 +3629,18 @@
dhcp6_start1(void *arg)
{
struct interface *ifp = arg;
+ struct dhcpcd_ctx *ctx = ifp->ctx;
struct if_options *ifo = ifp->options;
struct dhcp6_state *state;
size_t i;
const struct dhcp_compat *dhc;
- if (ifp->ctx->dhcp6_fd == -1 && dhcp6_open(ifp->ctx) == -1)
- return;
+ if (ctx->dhcp6_fd == -1 && ctx->options & DHCPCD_MASTER) {
+ ctx->dhcp6_fd = dhcp6_listen(ctx, NULL);
+ if (ctx->dhcp6_fd == -1)
+ return;
+ eloop_event_add(ctx->eloop, ctx->dhcp6_fd, dhcp6_recvctx, ctx);
+ }
state = D6_STATE(ifp);
/* If no DHCPv6 options are configured,
@@ -3858,22 +3869,20 @@
void
dhcp6_dropnondelegates(struct interface *ifp)
{
+
#ifndef SMALL
- struct dhcp6_state *state;
- struct ipv6_addr *ia;
-
- if ((state = D6_STATE(ifp)) == NULL)
+ if (dhcp6_hasprefixdelegation(ifp))
return;
- TAILQ_FOREACH(ia, &state->addrs, next) {
- if (ia->flags & (IPV6_AF_DELEGATED | IPV6_AF_DELEGATEDPFX))
- return;
- }
#endif
+ if (D6_CSTATE(ifp) == NULL)
+ return;
+
+ loginfox("%s: dropping DHCPv6 due to no valid routers", ifp->name);
dhcp6_drop(ifp, "EXPIRE6");
}
void
-dhcp6_handleifa(int cmd, struct ipv6_addr *ia)
Home |
Main Index |
Thread Index |
Old Index