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.1.1 with the foll...
details: https://anonhg.NetBSD.org/src/rev/ba1fcad9134b
branches: roy
changeset: 455420:ba1fcad9134b
user: roy <roy%NetBSD.org@localhost>
date: Wed Oct 16 14:53:22 2019 +0000
description:
Import dhcpcd-8.1.1 with the following changes:
* IPv6: Fix a potential crash when learning interface addresses.
* DHCP: Fix fallout from dhcpcd-8.1.0 for checksum calculation.
diffstat:
external/bsd/dhcpcd/dist/src/defs.h | 6 +-
external/bsd/dhcpcd/dist/src/dhcp.c | 146 ++++++++++++-----------------
external/bsd/dhcpcd/dist/src/dhcp.h | 2 -
external/bsd/dhcpcd/dist/src/dhcp6.c | 120 +++++++++--------------
external/bsd/dhcpcd/dist/src/dhcp6.h | 2 -
external/bsd/dhcpcd/dist/src/dhcpcd.c | 26 -----
external/bsd/dhcpcd/dist/src/dhcpcd.h | 7 -
external/bsd/dhcpcd/dist/src/if-options.h | 2 +-
external/bsd/dhcpcd/dist/src/ipv6.c | 4 -
external/bsd/dhcpcd/dist/src/ipv6nd.c | 150 ++++++++++++------------------
external/bsd/dhcpcd/dist/src/ipv6nd.h | 2 -
11 files changed, 169 insertions(+), 298 deletions(-)
diffs (truncated from 794 to 300 lines):
diff -r e6497c01ad11 -r ba1fcad9134b external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h Wed Oct 16 14:50:27 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h Wed Oct 16 14:53:22 2019 +0000
@@ -29,11 +29,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "8.1.0"
-
-#ifndef DHCPCD_USER
-# define DHCPCD_USER "_dhcpcd"
-#endif
+#define VERSION "8.1.1"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
diff -r e6497c01ad11 -r ba1fcad9134b external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c Wed Oct 16 14:50:27 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c Wed Oct 16 14:53:22 2019 +0000
@@ -67,7 +67,6 @@
#include "ipv4.h"
#include "ipv4ll.h"
#include "logerr.h"
-#include "privsep.h"
#include "sa.h"
#include "script.h"
@@ -1649,43 +1648,39 @@
dhcp_sendudp(struct interface *ifp, struct in_addr *to, void *data, size_t len)
{
int s;
- struct sockaddr_in sin = {
- .sin_family = AF_INET,
- .sin_addr = *to,
- .sin_port = htons(BOOTPS),
-#ifdef HAVE_SA_LEN
- .sin_len = sizeof(sin),
-#endif
- };
- struct iovec iov[] = {
- { .iov_base = data, .iov_len = len }
- };
- struct msghdr msg = {
- .msg_name = (void *)&sin,
- .msg_namelen = sizeof(sin),
- .msg_iov = iov,
- .msg_iovlen = 1,
- };
+ struct msghdr msg;
+ struct sockaddr_in sin;
+ struct iovec iov[1];
struct dhcp_state *state = D_STATE(ifp);
ssize_t r;
-#ifdef PRIVSEP
- if (ifp->ctx->options & DHCPCD_PRIVSEP)
- return privsep_sendmsg(ifp->ctx, PS_BOOTP, &msg);
- else
+ iov[0].iov_base = data;
+ iov[0].iov_len = len;
+
+ memset(&sin, 0, sizeof(sin));
+ sin.sin_family = AF_INET;
+ sin.sin_addr = *to;
+ sin.sin_port = htons(BOOTPS);
+#ifdef HAVE_SA_LEN
+ sin.sin_len = sizeof(sin);
#endif
- {
- s = state->udp_fd;
- if (s == -1) {
- s = dhcp_openudp(ifp);
- if (s == -1)
- return -1;
- }
- r = sendmsg(s, &msg, 0);
- if (state->udp_fd == -1)
- close(s);
- return r;
+
+ memset(&msg, 0, sizeof(msg));
+ msg.msg_name = (void *)&sin;
+ msg.msg_namelen = sizeof(sin);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 1;
+
+ s = state->udp_fd;
+ if (s == -1) {
+ s = dhcp_openudp(ifp);
+ if (s == -1)
+ return -1;
}
+ r = sendmsg(s, &msg, 0);
+ if (state->udp_fd == -1)
+ close(s);
+ return r;
}
static void
@@ -3455,40 +3450,6 @@
state->bpf_flags &= ~BPF_READING;
}
-void
-dhcp_recvmsg(struct dhcpcd_ctx *ctx, struct msghdr *msg)
-{
-#ifdef IP_PKTINFO
- struct sockaddr_in *from = (struct sockaddr_in *)msg->msg_name;
- struct iovec *iov = &msg->msg_iov[0];
- char sfrom[INET_ADDRSTRLEN];
- struct interface *ifp;
- const struct dhcp_state *state;
-
- inet_ntop(AF_INET, &from->sin_addr, sfrom, sizeof(sfrom));
-
- ifp = if_findifpfromcmsg(ctx, msg, NULL);
- if (ifp == NULL) {
- logerr(__func__);
- return;
- }
- state = D_CSTATE(ifp);
- if (state == NULL) {
- logdebugx("%s: received BOOTP for inactive interface",
- ifp->name);
- return;
- }
-
- if (state->bpf_fd != -1) {
- /* Avoid a duplicate read if BPF is open for the interface. */
- return;
- }
-
- dhcp_handlebootp(ifp, (struct bootp *)iov->iov_base, iov->iov_len,
- &from->sin_addr);
-#endif
-}
-
static void
dhcp_readudp(struct dhcpcd_ctx *ctx, struct interface *ifp)
{
@@ -3501,6 +3462,7 @@
};
#ifdef IP_PKTINFO
unsigned char ctl[CMSG_SPACE(sizeof(struct in_pktinfo))] = { 0 };
+ char sfrom[INET_ADDRSTRLEN];
#endif
struct msghdr msg = {
.msg_name = &from, .msg_namelen = sizeof(from),
@@ -3524,8 +3486,31 @@
return;
}
- iov.iov_len = (size_t)bytes;
- dhcp_recvmsg(ctx, &msg);
+#ifdef IP_PKTINFO
+ inet_ntop(AF_INET, &from.sin_addr, sfrom, sizeof(sfrom));
+
+ if (ifp == NULL) {
+ ifp = if_findifpfromcmsg(ctx, &msg, NULL);
+ if (ifp == NULL) {
+ logerr(__func__);
+ return;
+ }
+ state = D_CSTATE(ifp);
+ if (state == NULL) {
+ logdebugx("%s: received BOOTP for inactive interface",
+ ifp->name);
+ return;
+ }
+ }
+
+ if (state->bpf_fd != -1) {
+ /* Avoid a duplicate read if BPF is open for the interface. */
+ return;
+ }
+
+ dhcp_handlebootp(ifp, (struct bootp *)(void *)buf, (size_t)bytes,
+ &from.sin_addr);
+#endif
}
static void
@@ -3547,18 +3532,6 @@
}
#endif
-int
-dhcp_open(struct dhcpcd_ctx *ctx)
-{
-
- if (ctx->udp_fd != -1 || (ctx->udp_fd = dhcp_openudp(NULL)) == -1)
- return ctx->udp_fd;
-
- if (!(ctx->options & DHCPCD_PRIVSEP))
- eloop_event_add(ctx->eloop, ctx->udp_fd, dhcp_handleudp, ctx);
- return ctx->udp_fd;
-}
-
static int
dhcp_openbpf(struct interface *ifp)
{
@@ -3767,13 +3740,16 @@
* ICMP port unreachable message back to the DHCP server.
* Only do this in master mode so we don't swallow messages
* for dhcpcd running on another interface. */
- if (!(ctx->options & DHCPCD_PRIVSEP) && ctx->options & DHCPCD_MASTER) {
- if (dhcp_open(ctx) == -1) {
+ if (ctx->udp_fd == -1 && ctx->options & DHCPCD_MASTER) {
+ ctx->udp_fd = dhcp_openudp(NULL);
+ if (ctx->udp_fd == -1) {
/* Don't log an error if some other process
* is handling this. */
if (errno != EADDRINUSE)
- logerr("%s: dhcp_open", __func__);
- }
+ logerr("%s: dhcp_openudp", __func__);
+ } else
+ eloop_event_add(ctx->eloop,
+ ctx->udp_fd, dhcp_handleudp, ctx);
}
if (dhcp_init(ifp) == -1) {
diff -r e6497c01ad11 -r ba1fcad9134b external/bsd/dhcpcd/dist/src/dhcp.h
--- a/external/bsd/dhcpcd/dist/src/dhcp.h Wed Oct 16 14:50:27 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.h Wed Oct 16 14:53:22 2019 +0000
@@ -253,8 +253,6 @@
ssize_t print_rfc3361(FILE *, const uint8_t *, size_t);
ssize_t print_rfc3442(FILE *, const uint8_t *, size_t);
-int dhcp_open(struct dhcpcd_ctx *);
-void dhcp_recvmsg(struct dhcpcd_ctx *, struct msghdr *);
void dhcp_printoptions(const struct dhcpcd_ctx *,
const struct dhcp_opt *, size_t);
uint16_t dhcp_get_mtu(const struct interface *);
diff -r e6497c01ad11 -r ba1fcad9134b external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c Wed Oct 16 14:50:27 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c Wed Oct 16 14:53:22 2019 +0000
@@ -56,7 +56,6 @@
#include "if-options.h"
#include "ipv6nd.h"
#include "logerr.h"
-#include "privsep.h"
#include "script.h"
#ifdef HAVE_SYS_BITOPS_H
@@ -1322,28 +1321,21 @@
memcpy(CMSG_DATA(cm), &pi, sizeof(pi));
}
-#ifdef PRIVSEP
- if (ifp->ctx->options & DHCPCD_PRIVSEP)
- privsep_sendmsg(ifp->ctx, PS_DHCP6, &msg);
- else
-#endif
- {
- 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, &msg, 0) == -1) {
- logerr("%s: %s: sendmsg", __func__, ifp->name);
- /* Allow DHCPv6 to continue .... the errors
- * would be rate limited by the protocol.
- * Generally the error is ENOBUFS when struggling to
- * associate with an access point. */
- }
+ 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, &msg, 0) == -1) {
+ logerr("%s: %s: sendmsg", __func__, ifp->name);
+ /* Allow DHCPv6 to continue .... the errors
+ * would be rate limited by the protocol.
+ * Generally the error is ENOBUFS when struggling to
+ * associate with an access point. */
}
state->RTC++;
@@ -3472,11 +3464,24 @@
dhcp6_bind(ifp, op, sfrom);
}
-void
-dhcp6_recvmsg(struct dhcpcd_ctx *ctx, struct msghdr *msg, struct ipv6_addr *ia)
+static void
+dhcp6_recv(struct dhcpcd_ctx *ctx, struct ipv6_addr *ia)
{
- struct sockaddr_in6 *from = msg->msg_name;
- size_t len = msg->msg_iov[0].iov_len;
Home |
Main Index |
Thread Index |
Old Index