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/src Update to dhcpcd-9.2.0 with the...
details: https://anonhg.NetBSD.org/src/rev/5161360531e0
branches: trunk
changeset: 1013815:5161360531e0
user: roy <roy%NetBSD.org@localhost>
date: Sun Sep 06 14:54:28 2020 +0000
description:
Update to dhcpcd-9.2.0 with the following changes:
* route: ensure IPv4LL routes come last in priority
* DHCP: fix many issues with extending the last lease
* privsep: don't read control group from config in privsep
* privsep: only the master process responds to signals
* privsep: use a socketpair for stderr/stdin rather than dupping /dev/null
* privsep: right limit stdin/stderr/stdout
* privsep: dumping a lease is now run in a sandbox
* options: check if kernel supports INET or INET6 before enabling default
* options: let clientid override a prior duid
* options: allow -1 to represent infinity for requested lease time
* dhcpcd: fix a crash initing a new interface after route overflow
diffstat:
external/bsd/dhcpcd/dist/src/defs.h | 2 +-
external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in | 10 ++++-
external/bsd/dhcpcd/dist/src/dhcpcd.h | 6 +--
external/bsd/dhcpcd/dist/src/eloop.c | 5 +-
external/bsd/dhcpcd/dist/src/if.c | 47 ++++++++++++++++++++++++++
external/bsd/dhcpcd/dist/src/if.h | 3 +-
external/bsd/dhcpcd/dist/src/ipv4.c | 9 +++-
external/bsd/dhcpcd/dist/src/ipv4.h | 1 +
external/bsd/dhcpcd/dist/src/ipv4ll.c | 5 ++
external/bsd/dhcpcd/dist/src/logerr.h | 2 -
external/bsd/dhcpcd/dist/src/privsep-bpf.c | 14 +-------
external/bsd/dhcpcd/dist/src/privsep-control.c | 25 ++-----------
external/bsd/dhcpcd/dist/src/privsep-inet.c | 17 +--------
external/bsd/dhcpcd/dist/src/privsep-root.c | 31 +++++++++++-----
external/bsd/dhcpcd/dist/src/privsep.h | 1 -
external/bsd/dhcpcd/dist/src/route.c | 8 ++++
external/bsd/dhcpcd/dist/src/route.h | 5 +-
17 files changed, 115 insertions(+), 76 deletions(-)
diffs (truncated from 484 to 300 lines):
diff -r 811e0fcc0bff -r 5161360531e0 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h Sun Sep 06 13:06:03 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h Sun Sep 06 14:54:28 2020 +0000
@@ -29,7 +29,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "9.1.4"
+#define VERSION "9.2.0"
#ifndef PRIVSEP_USER
# define PRIVSEP_USER "_" PACKAGE
diff -r 811e0fcc0bff -r 5161360531e0 external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in Sun Sep 06 13:06:03 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in Sun Sep 06 14:54:28 2020 +0000
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 18, 2020
+.Dd September 2, 2020
.Dt DHCPCD.CONF 5
.Os
.Sh NAME
@@ -448,8 +448,14 @@
This is on by default, but is documented here in the case where it is disabled
globally but needs to be enabled for one interface.
.It Ic leasetime Ar seconds
-Request a leasetime of
+Request a lease time of
.Ar seconds .
+.Ar -1
+represents an infinite lease time.
+By default
+.Nm dhcpcd
+does not request any lease time and leaves it in the hands of the
+DHCP server.
.It Ic link_rcvbuf Ar size
Override the size of the link receive buffer from the kernel default.
While
diff -r 811e0fcc0bff -r 5161360531e0 external/bsd/dhcpcd/dist/src/dhcpcd.h
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.h Sun Sep 06 13:06:03 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.h Sun Sep 06 14:54:28 2020 +0000
@@ -96,7 +96,6 @@
#include "privsep.h"
-#ifdef INET6
/* dhcpcd requires CMSG_SPACE to evaluate to a compile time constant. */
#if defined(__QNX) || \
(defined(__NetBSD_Version__) && __NetBSD_Version__ < 600000000)
@@ -113,16 +112,13 @@
#define CMSG_SPACE(len) (ALIGN(sizeof(struct cmsghdr)) + ALIGN(len))
#endif
-#define IP6BUFLEN (CMSG_SPACE(sizeof(struct in6_pktinfo)) + \
- CMSG_SPACE(sizeof(int)))
-#endif
-
struct passwd;
struct dhcpcd_ctx {
char pidfile[sizeof(PIDFILE) + IF_NAMESIZE + 1];
char vendor[256];
int fork_fd; /* FD for the fork init signal pipe */
+ int stderr_fd; /* FD for logging to stderr */
const char *cffile;
unsigned long long options;
char *logfile;
diff -r 811e0fcc0bff -r 5161360531e0 external/bsd/dhcpcd/dist/src/eloop.c
--- a/external/bsd/dhcpcd/dist/src/eloop.c Sun Sep 06 13:06:03 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/eloop.c Sun Sep 06 14:54:28 2020 +0000
@@ -703,9 +703,10 @@
if (eloop->exitnow)
break;
- if (_eloop_nsig != 0 && eloop->signal_cb != NULL) {
+ if (_eloop_nsig != 0) {
n = _eloop_sig[--_eloop_nsig];
- eloop->signal_cb(n, eloop->signal_cb_ctx);
+ if (eloop->signal_cb != NULL)
+ eloop->signal_cb(n, eloop->signal_cb_ctx);
continue;
}
diff -r 811e0fcc0bff -r 5161360531e0 external/bsd/dhcpcd/dist/src/if.c
--- a/external/bsd/dhcpcd/dist/src/if.c Sun Sep 06 13:06:03 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/if.c Sun Sep 06 14:54:28 2020 +0000
@@ -995,3 +995,50 @@
return -1;
#endif
}
+
+int
+xsocketpair(int domain, int type, int protocol, int fd[2])
+{
+ int s;
+#if !defined(HAVE_SOCK_CLOEXEC) || !defined(HAVE_SOCK_NONBLOCK)
+ int xflags, xtype = type;
+#endif
+
+#ifndef HAVE_SOCK_CLOEXEC
+ if (xtype & SOCK_CLOEXEC)
+ type &= ~SOCK_CLOEXEC;
+#endif
+#ifndef HAVE_SOCK_NONBLOCK
+ if (xtype & SOCK_NONBLOCK)
+ type &= ~SOCK_NONBLOCK;
+#endif
+
+ if ((s = socketpair(domain, type, protocol, fd)) == -1)
+ return -1;
+
+#ifndef HAVE_SOCK_CLOEXEC
+ if ((xtype & SOCK_CLOEXEC) && ((xflags = fcntl(fd[0], F_GETFD)) == -1 ||
+ fcntl(fd[0], F_SETFD, xflags | FD_CLOEXEC) == -1))
+ goto out;
+ if ((xtype & SOCK_CLOEXEC) && ((xflags = fcntl(fd[1], F_GETFD)) == -1 ||
+ fcntl(fd[1], F_SETFD, xflags | FD_CLOEXEC) == -1))
+ goto out;
+#endif
+#ifndef HAVE_SOCK_NONBLOCK
+ if ((xtype & SOCK_NONBLOCK) && ((xflags = fcntl(fd[0], F_GETFL)) == -1 ||
+ fcntl(fd[0], F_SETFL, xflags | O_NONBLOCK) == -1))
+ goto out;
+ if ((xtype & SOCK_NONBLOCK) && ((xflags = fcntl(fd[1], F_GETFL)) == -1 ||
+ fcntl(fd[1], F_SETFL, xflags | O_NONBLOCK) == -1))
+ goto out;
+#endif
+
+ return s;
+
+#if !defined(HAVE_SOCK_CLOEXEC) || !defined(HAVE_SOCK_NONBLOCK)
+out:
+ close(fd[0]);
+ close(fd[1]);
+ return -1;
+#endif
+}
diff -r 811e0fcc0bff -r 5161360531e0 external/bsd/dhcpcd/dist/src/if.h
--- a/external/bsd/dhcpcd/dist/src/if.h Sun Sep 06 13:06:03 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/if.h Sun Sep 06 14:54:28 2020 +0000
@@ -224,6 +224,8 @@
#ifndef SOCK_CXNB
#define SOCK_CXNB SOCK_CLOEXEC | SOCK_NONBLOCK
#endif
+int xsocket(int, int, int);
+int xsocketpair(int, int, int, int[2]);
int if_route(unsigned char, const struct rt *rt);
int if_initrt(struct dhcpcd_ctx *, rb_tree_t *, int);
@@ -259,7 +261,6 @@
int if_machinearch(char *, size_t);
struct interface *if_findifpfromcmsg(struct dhcpcd_ctx *,
struct msghdr *, int *);
-int xsocket(int, int, int);
#ifdef __linux__
int if_linksocket(struct sockaddr_nl *, int, int);
diff -r 811e0fcc0bff -r 5161360531e0 external/bsd/dhcpcd/dist/src/ipv4.c
--- a/external/bsd/dhcpcd/dist/src/ipv4.c Sun Sep 06 13:06:03 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/ipv4.c Sun Sep 06 14:54:28 2020 +0000
@@ -661,8 +661,13 @@
ia->mask = *mask;
ia->brd = *bcast;
#ifdef IP_LIFETIME
- ia->vltime = vltime;
- ia->pltime = pltime;
+ if (ifp->options->options & DHCPCD_LASTLEASE_EXTEND) {
+ /* We don't want the kernel to expire the address. */
+ ia->vltime = ia->pltime = DHCP_INFINITE_LIFETIME;
+ } else {
+ ia->vltime = vltime;
+ ia->pltime = pltime;
+ }
#else
UNUSED(vltime);
UNUSED(pltime);
diff -r 811e0fcc0bff -r 5161360531e0 external/bsd/dhcpcd/dist/src/ipv4.h
--- a/external/bsd/dhcpcd/dist/src/ipv4.h Sun Sep 06 13:06:03 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/ipv4.h Sun Sep 06 14:54:28 2020 +0000
@@ -129,6 +129,7 @@
#define STATE_ADDED 0x01
#define STATE_FAKE 0x02
+#define STATE_EXPIRED 0x04
int ipv4_deladdr(struct ipv4_addr *, int);
struct ipv4_addr *ipv4_addaddr(struct interface *,
diff -r 811e0fcc0bff -r 5161360531e0 external/bsd/dhcpcd/dist/src/ipv4ll.c
--- a/external/bsd/dhcpcd/dist/src/ipv4ll.c Sun Sep 06 13:06:03 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/ipv4ll.c Sun Sep 06 14:54:28 2020 +0000
@@ -111,6 +111,7 @@
in.s_addr = INADDR_ANY;
sa_in_init(&rt->rt_gateway, &in);
sa_in_init(&rt->rt_ifa, &state->addr->addr);
+ rt->rt_dflags |= RTDF_IPV4LL;
return rt_proto_add(routes, rt) ? 1 : 0;
}
@@ -134,6 +135,10 @@
sa_in_init(&rt->rt_netmask, &in);
sa_in_init(&rt->rt_gateway, &in);
sa_in_init(&rt->rt_ifa, &state->addr->addr);
+ rt->rt_dflags |= RTDF_IPV4LL;
+#ifdef HAVE_ROUTE_METRIC
+ rt->rt_metric += 10000;
+#endif
return rt_proto_add(routes, rt) ? 1 : 0;
}
diff -r 811e0fcc0bff -r 5161360531e0 external/bsd/dhcpcd/dist/src/logerr.h
--- a/external/bsd/dhcpcd/dist/src/logerr.h Sun Sep 06 13:06:03 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/logerr.h Sun Sep 06 14:54:28 2020 +0000
@@ -97,8 +97,6 @@
void logsettag(const char *);
#endif
-int loggeterrfd(void);
-int logseterrfd(int);
int logopen(const char *);
void logclose(void);
int logreopen(void);
diff -r 811e0fcc0bff -r 5161360531e0 external/bsd/dhcpcd/dist/src/privsep-bpf.c
--- a/external/bsd/dhcpcd/dist/src/privsep-bpf.c Sun Sep 06 13:06:03 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/privsep-bpf.c Sun Sep 06 14:54:28 2020 +0000
@@ -40,7 +40,6 @@
#include <assert.h>
#include <pwd.h>
#include <errno.h>
-#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -170,17 +169,6 @@
return -1;
}
-static void
-ps_bpf_signal_bpfcb(int sig, void *arg)
-{
- struct dhcpcd_ctx *ctx = arg;
-
- if (sig != SIGTERM)
- return;
-
- eloop_exit(ctx->eloop, EXIT_SUCCESS);
-}
-
ssize_t
ps_bpf_cmd(struct dhcpcd_ctx *ctx, struct ps_msghdr *psm, struct msghdr *msg)
{
@@ -249,7 +237,7 @@
start = ps_dostart(ctx,
&psp->psp_pid, &psp->psp_fd,
ps_bpf_recvmsg, NULL, psp,
- ps_bpf_start_bpf, ps_bpf_signal_bpfcb,
+ ps_bpf_start_bpf, NULL,
PSF_DROPPRIVS);
switch (start) {
case -1:
diff -r 811e0fcc0bff -r 5161360531e0 external/bsd/dhcpcd/dist/src/privsep-control.c
--- a/external/bsd/dhcpcd/dist/src/privsep-control.c Sun Sep 06 13:06:03 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/privsep-control.c Sun Sep 06 14:54:28 2020 +0000
@@ -27,7 +27,6 @@
*/
#include <errno.h>
-#include <signal.h>
#include <stdlib.h>
#include <string.h>
@@ -95,18 +94,6 @@
logerr(__func__);
}
-static void
-ps_ctl_signalcb(int sig, void *arg)
-{
- struct dhcpcd_ctx *ctx = arg;
-
- if (sig != SIGTERM)
- return;
-
- shutdown(ctx->ps_control_fd, SHUT_RDWR);
- eloop_exit(ctx->eloop, EXIT_SUCCESS);
-}
-
ssize_t
ps_ctl_handleargs(struct fd_list *fd, char *data, size_t len)
{
@@ -238,20 +225,18 @@
int data_fd[2], listen_fd[2];
pid_t pid;
- if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CXNB, 0, data_fd) == -1)
- return -1;
- if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CXNB, 0, listen_fd) == -1)
+ if (xsocketpair(AF_UNIX, SOCK_STREAM | SOCK_CXNB, 0, data_fd) == -1 ||
+ xsocketpair(AF_UNIX, SOCK_STREAM | SOCK_CXNB, 0, listen_fd) == -1)
Home |
Main Index |
Thread Index |
Old Index