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-7.2.0 with the foll...
details: https://anonhg.NetBSD.org/src/rev/1dcb467e8383
branches: ROY
changeset: 455218:1dcb467e8383
user: roy <roy%NetBSD.org@localhost>
date: Wed Apr 17 23:33:08 2019 +0000
description:
Import dhcpcd-7.2.0 with the following changes:
* BSD: PF_LINK sockets now closed when no longer needed
* BSD: Fix detecting interface for scoped routes
* script: Allow "" to mean /dev/null
* script: Add static routers and routes to env
* DHCP: outbound interface is no longer dictated with IP_PKTINFO
* DHCP: BPF sockets now closed when no longer needed
* DHCPv6: Allow nooption dhcp6_unicast to work
* DHCPv6: Don't spam syslog if we always get the same error
* route: Log pid which deleted routes of interest
This release fixes PR bin/53705.
diffstat:
external/bsd/dhcpcd/dist/src/arp.c | 15 +-
external/bsd/dhcpcd/dist/src/arp.h | 1 -
external/bsd/dhcpcd/dist/src/common.c | 48 -----
external/bsd/dhcpcd/dist/src/common.h | 2 -
external/bsd/dhcpcd/dist/src/defs.h | 2 +-
external/bsd/dhcpcd/dist/src/dhcp.c | 283 +++++++++++++++++++----------
external/bsd/dhcpcd/dist/src/dhcp.h | 1 +
external/bsd/dhcpcd/dist/src/dhcp6.c | 230 +++++++++++------------
external/bsd/dhcpcd/dist/src/dhcp6.h | 2 +-
external/bsd/dhcpcd/dist/src/dhcpcd.8.in | 2 +-
external/bsd/dhcpcd/dist/src/dhcpcd.c | 12 +-
external/bsd/dhcpcd/dist/src/dhcpcd.h | 13 -
external/bsd/dhcpcd/dist/src/duid.c | 1 +
external/bsd/dhcpcd/dist/src/if-bsd.c | 81 +++++--
external/bsd/dhcpcd/dist/src/if-options.c | 141 ++++++-------
external/bsd/dhcpcd/dist/src/if.c | 125 +++++++++++--
external/bsd/dhcpcd/dist/src/if.h | 9 +
external/bsd/dhcpcd/dist/src/ipv4.c | 10 +-
external/bsd/dhcpcd/dist/src/ipv4ll.c | 2 +
external/bsd/dhcpcd/dist/src/ipv6.c | 47 ++--
external/bsd/dhcpcd/dist/src/ipv6nd.c | 194 +++++++++-----------
external/bsd/dhcpcd/dist/src/route.c | 9 +-
external/bsd/dhcpcd/dist/src/route.h | 2 +-
external/bsd/dhcpcd/dist/src/script.c | 10 +-
24 files changed, 672 insertions(+), 570 deletions(-)
diffs (truncated from 2690 to 300 lines):
diff -r 297605e7f2ea -r 1dcb467e8383 external/bsd/dhcpcd/dist/src/arp.c
--- a/external/bsd/dhcpcd/dist/src/arp.c Thu Feb 07 21:34:30 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.c Wed Apr 17 23:33:08 2019 +0000
@@ -175,17 +175,18 @@
}
}
-void
+static void
arp_close(struct interface *ifp)
{
struct iarp_state *state;
- if ((state = ARP_STATE(ifp)) != NULL && state->bpf_fd != -1) {
- eloop_event_delete(ifp->ctx->eloop, state->bpf_fd);
- bpf_close(ifp, state->bpf_fd);
- state->bpf_fd = -1;
- state->bpf_flags |= BPF_EOF;
- }
+ if ((state = ARP_STATE(ifp)) == NULL || state->bpf_fd == -1)
+ return;
+
+ eloop_event_delete(ifp->ctx->eloop, state->bpf_fd);
+ bpf_close(ifp, state->bpf_fd);
+ state->bpf_fd = -1;
+ state->bpf_flags |= BPF_EOF;
}
static void
diff -r 297605e7f2ea -r 1dcb467e8383 external/bsd/dhcpcd/dist/src/arp.h
--- a/external/bsd/dhcpcd/dist/src/arp.h Thu Feb 07 21:34:30 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.h Wed Apr 17 23:33:08 2019 +0000
@@ -90,7 +90,6 @@
int arp_open(struct interface *);
ssize_t arp_request(const struct interface *, in_addr_t, in_addr_t);
void arp_probe(struct arp_state *);
-void arp_close(struct interface *);
void arp_report_conflicted(const struct arp_state *, const struct arp_msg *);
struct arp_state *arp_new(struct interface *, const struct in_addr *);
struct arp_state *arp_find(struct interface *, const struct in_addr *);
diff -r 297605e7f2ea -r 1dcb467e8383 external/bsd/dhcpcd/dist/src/common.c
--- a/external/bsd/dhcpcd/dist/src/common.c Thu Feb 07 21:34:30 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/common.c Wed Apr 17 23:33:08 2019 +0000
@@ -200,51 +200,3 @@
fclose(fp);
return len;
}
-
-ssize_t
-recvmsg_realloc(int fd, struct msghdr *msg, int flags)
-{
- struct iovec *iov;
- ssize_t slen;
- size_t len;
- void *n;
-
- assert(msg != NULL);
- assert(msg->msg_iov != NULL && msg->msg_iovlen > 0);
- assert((flags & (MSG_PEEK | MSG_TRUNC)) == 0);
-
- /* Assume we are reallocing the last iovec. */
- iov = &msg->msg_iov[msg->msg_iovlen - 1];
-
- for (;;) {
- /* Passing MSG_TRUNC should return the actual size needed. */
- slen = recvmsg(fd, msg, flags | MSG_PEEK | MSG_TRUNC);
- if (slen == -1)
- return -1;
- if (!(msg->msg_flags & MSG_TRUNC))
- break;
-
- len = (size_t)slen;
-
- /* Some kernels return the size of the receive buffer
- * on truncation, not the actual size needed.
- * So grow the buffer and try again. */
- if (iov->iov_len == len)
- len++;
- else if (iov->iov_len > len)
- break;
- len = roundup(len, IOVEC_BUFSIZ);
- if ((n = realloc(iov->iov_base, len)) == NULL)
- return -1;
- iov->iov_base = n;
- iov->iov_len = len;
- }
-
- slen = recvmsg(fd, msg, flags);
- if (slen != -1 && msg->msg_flags & MSG_TRUNC) {
- /* This should not be possible ... */
- errno = ENOBUFS;
- return -1;
- }
- return slen;
-}
diff -r 297605e7f2ea -r 1dcb467e8383 external/bsd/dhcpcd/dist/src/common.h
--- a/external/bsd/dhcpcd/dist/src/common.h Thu Feb 07 21:34:30 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/common.h Wed Apr 17 23:33:08 2019 +0000
@@ -181,6 +181,4 @@
const char *hwaddr_ntoa(const void *, size_t, char *, size_t);
size_t hwaddr_aton(uint8_t *, const char *);
size_t read_hwaddr_aton(uint8_t **, const char *);
-
-ssize_t recvmsg_realloc(int, struct msghdr *, int);
#endif
diff -r 297605e7f2ea -r 1dcb467e8383 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h Thu Feb 07 21:34:30 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h Wed Apr 17 23:33:08 2019 +0000
@@ -28,7 +28,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "7.1.1"
+#define VERSION "7.2.0"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
diff -r 297605e7f2ea -r 1dcb467e8383 external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c Thu Feb 07 21:34:30 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c Wed Apr 17 23:33:08 2019 +0000
@@ -86,9 +86,9 @@
#define IPDEFTTL 64 /* RFC1340 */
#endif
-/* NetBSD-7 has an incomplete IP_PKTINFO implementation. */
-#if defined(__NetBSD_Version__) && __NetBSD_Version__ < 800000000
-#undef IP_PKTINFO
+/* Support older systems with different defines */
+#if !defined(IP_RECVPKTINFO) && defined(IP_PKTINFO)
+#define IP_RECVPKTINFO IP_PKTINFO
#endif
/* Assert the correct structure size for on wire */
@@ -129,6 +129,9 @@
#endif
static void dhcp_handledhcp(struct interface *, struct bootp *, size_t,
const struct in_addr *);
+#ifdef IP_PKTINFO
+static void dhcp_handleifudp(void *);
+#endif
static int dhcp_initstate(struct interface *);
void
@@ -447,7 +450,7 @@
memcpy(&gateway.s_addr, p, 4);
p += 4;
- /* A host route is normally set by having the
+ /* An on-link host route is normally set by having the
* gateway match the destination or assigned address */
if (gateway.s_addr == dest.s_addr ||
(gateway.s_addr == bootp->yiaddr ||
@@ -455,17 +458,14 @@
{
gateway.s_addr = INADDR_ANY;
netmask.s_addr = INADDR_BROADCAST;
+ }
+ if (netmask.s_addr == INADDR_BROADCAST)
rt->rt_flags = RTF_HOST;
- }
sa_in_init(&rt->rt_dest, &dest);
sa_in_init(&rt->rt_netmask, &netmask);
sa_in_init(&rt->rt_gateway, &gateway);
- /* If CIDR is 32 then it's a host route. */
- if (cidr == 32)
- rt->rt_flags = RTF_HOST;
-
TAILQ_INSERT_TAIL(routes, rt, rt_next);
n++;
}
@@ -638,7 +638,7 @@
if ((rt = rt_new(ifp)) == NULL)
return -1;
- /* A host route is normally set by having the
+ /* A on-link host route is normally set by having the
* gateway match the destination or assigned address */
if (gateway.s_addr == dest.s_addr ||
(gateway.s_addr == bootp->yiaddr ||
@@ -646,12 +646,15 @@
{
gateway.s_addr = INADDR_ANY;
netmask.s_addr = INADDR_BROADCAST;
- rt->rt_flags = RTF_HOST;
} else
netmask.s_addr = route_netmask(dest.s_addr);
+ if (netmask.s_addr == INADDR_BROADCAST)
+ rt->rt_flags = RTF_HOST;
+
sa_in_init(&rt->rt_dest, &dest);
sa_in_init(&rt->rt_netmask, &netmask);
sa_in_init(&rt->rt_gateway, &gateway);
+
TAILQ_INSERT_TAIL(routes, rt, rt_next);
n++;
}
@@ -1587,6 +1590,11 @@
state->bpf_fd = -1;
state->bpf_flags |= BPF_EOF;
}
+ if (state->udp_fd != -1) {
+ eloop_event_delete(ifp->ctx->eloop, state->udp_fd);
+ close(state->udp_fd);
+ state->udp_fd = -1;
+ }
state->interval = 0;
}
@@ -1604,11 +1612,15 @@
n = 1;
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n)) == -1)
goto eexit;
+#ifdef IP_RECVPKTINFO
+ if (setsockopt(s, IPPROTO_IP, IP_RECVPKTINFO, &n, sizeof(n)) == -1)
+ goto eexit;
+#endif
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_port = htons(BOOTPC);
if (ifp) {
- struct dhcp_state *state = D_STATE(ifp);
+ const struct dhcp_state *state = D_CSTATE(ifp);
if (state->addr)
sin.sin_addr.s_addr = state->addr->addr.s_addr;
@@ -1699,12 +1711,8 @@
struct msghdr msg;
struct sockaddr_in sin;
struct iovec iov[1];
+ struct dhcp_state *state = D_STATE(ifp);
ssize_t r;
-#ifdef IP_PKTINFO
- uint8_t cmsg[CMSG_SPACE(sizeof(struct in_pktinfo))];
- struct cmsghdr *cm;
- struct in_pktinfo ipi;
-#endif
iov[0].iov_base = data;
iov[0].iov_len = len;
@@ -1723,29 +1731,15 @@
msg.msg_iov = iov;
msg.msg_iovlen = 1;
-#ifdef IP_PKTINFO
- /* Set the outbound interface */
- msg.msg_control = cmsg;
- msg.msg_controllen = sizeof(cmsg);
-
- memset(&ipi, 0, sizeof(ipi));
- ipi.ipi_ifindex = ifp->index;
- cm = CMSG_FIRSTHDR(&msg);
- if (cm == NULL) {
- errno = ESRCH;
- return -1;
+ s = state->udp_fd;
+ if (s == -1) {
+ s = dhcp_openudp(ifp);
+ if (s == -1)
+ return -1;
}
- cm->cmsg_level = IPPROTO_IP;
- cm->cmsg_type = IP_PKTINFO;
- cm->cmsg_len = CMSG_LEN(sizeof(ipi));
- memcpy(CMSG_DATA(cm), &ipi, sizeof(ipi));
-#endif
-
- s = dhcp_openudp(ifp);
- if (s == -1)
- return -1;
r = sendmsg(s, &msg, 0);
- close(s);
+ if (state->udp_fd == -1)
+ close(s);
return r;
}
@@ -1803,7 +1797,7 @@
else
to.s_addr = INADDR_ANY;
- /* If unicasting, try and void sending by BPF so we don't
+ /* If unicasting, try and avoid sending by BPF so we don't
* use a L2 broadcast. */
if (to.s_addr != INADDR_ANY && to.s_addr != INADDR_BROADCAST) {
if (dhcp_sendudp(ifp, &to, bootp, len) != -1)
@@ -2068,11 +2062,6 @@
return;
}
arp_free(astate);
-#ifdef KERNEL_RFC5227
- /* As arping is finished, close the ARP socket.
- * The kernel will handle ACD from here. */
- arp_close(ifp);
-#endif
dhcpcd_startinterface(ifp);
return;
}
@@ -2150,11 +2139,6 @@
Home |
Main Index |
Thread Index |
Old Index