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.2 with the foll...
details: https://anonhg.NetBSD.org/src/rev/7bb4be5969db
branches: ROY
changeset: 461017:7bb4be5969db
user: roy <roy%NetBSD.org@localhost>
date: Wed Nov 13 10:49:19 2019 +0000
description:
Import dhcpcd-8.1.2 with the following changes:
* hooks: STOPPED is now run on timeout and exit
* BSD: Use IP_REVCIF rather than IN_PKTINFO
* DHCP: When rebinding, ensure we have a DHCP ARP state
* RA: Sort routers when reachability changes
* RA: Apply hoplimit, reachable and retrans timer values to kernel
* RA: Warn if advertised MTU > interface MTU
* dhcpcd: Report SSID connection to when we gain carrier
* DHCP: Fix corruption of address flags when renewing
diffstat:
external/bsd/dhcpcd/dist/src/arp.c | 17 +-
external/bsd/dhcpcd/dist/src/arp.h | 1 +
external/bsd/dhcpcd/dist/src/control.c | 6 +-
external/bsd/dhcpcd/dist/src/defs.h | 2 +-
external/bsd/dhcpcd/dist/src/dhcp.c | 204 +++++++++++---------
external/bsd/dhcpcd/dist/src/dhcp6.c | 79 +++++---
external/bsd/dhcpcd/dist/src/dhcpcd.c | 32 +++-
external/bsd/dhcpcd/dist/src/eloop.c | 27 ++-
external/bsd/dhcpcd/dist/src/eloop.h | 1 +
external/bsd/dhcpcd/dist/src/if-bsd.c | 71 +++++-
external/bsd/dhcpcd/dist/src/if.c | 20 +-
external/bsd/dhcpcd/dist/src/if.h | 3 +
external/bsd/dhcpcd/dist/src/ipv4.c | 25 +-
external/bsd/dhcpcd/dist/src/ipv6nd.c | 323 +++++++++++++++++++-------------
external/bsd/dhcpcd/dist/src/ipv6nd.h | 5 +
external/bsd/dhcpcd/dist/src/script.c | 87 +++++---
16 files changed, 557 insertions(+), 346 deletions(-)
diffs (truncated from 1616 to 300 lines):
diff -r a8ac931965f2 -r 7bb4be5969db external/bsd/dhcpcd/dist/src/arp.c
--- a/external/bsd/dhcpcd/dist/src/arp.c Wed Oct 16 14:53:22 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.c Wed Nov 13 10:49:19 2019 +0000
@@ -206,7 +206,6 @@
return true;
}
-
static void
arp_packet(struct interface *ifp, uint8_t *data, size_t len)
{
@@ -280,9 +279,9 @@
}
static void
-arp_tryfree(struct interface *ifp)
+arp_tryfree(struct iarp_state *state)
{
- struct iarp_state *state = ARP_STATE(ifp);
+ struct interface *ifp = state->ifp;
/* If there are no more ARP states, close the socket. */
if (TAILQ_FIRST(&state->arp_states) == NULL) {
@@ -302,15 +301,14 @@
static void
arp_read(void *arg)
{
- struct interface *ifp = arg;
- struct iarp_state *state;
+ struct iarp_state *state = arg;
+ struct interface *ifp = state->ifp;
uint8_t buf[ARP_LEN];
ssize_t bytes;
/* Some RAW mechanisms are generic file descriptors, not sockets.
* This means we have no kernel call to just get one packet,
* so we have to process the entire buffer. */
- state = ARP_STATE(ifp);
state->bpf_flags &= ~BPF_EOF;
state->bpf_flags |= BPF_READING;
while (!(state->bpf_flags & BPF_EOF)) {
@@ -329,7 +327,7 @@
if (state != NULL) {
state->bpf_flags &= ~BPF_READING;
/* Try and free the state if nothing left to do. */
- arp_tryfree(ifp);
+ arp_tryfree(state);
}
}
@@ -343,7 +341,7 @@
state->bpf_fd = bpf_open(ifp, bpf_arp);
if (state->bpf_fd == -1)
return -1;
- eloop_event_add(ifp->ctx->eloop, state->bpf_fd, arp_read, ifp);
+ eloop_event_add(ifp->ctx->eloop, state->bpf_fd, arp_read, state);
}
return state->bpf_fd;
}
@@ -571,6 +569,7 @@
logerr(__func__);
return NULL;
}
+ state->ifp = ifp;
state->bpf_fd = -1;
state->bpf_flags = 0;
TAILQ_INIT(&state->arp_states);
@@ -618,7 +617,7 @@
if (astate->free_cb)
astate->free_cb(astate);
free(astate);
- arp_tryfree(ifp);
+ arp_tryfree(state);
}
void
diff -r a8ac931965f2 -r 7bb4be5969db external/bsd/dhcpcd/dist/src/arp.h
--- a/external/bsd/dhcpcd/dist/src/arp.h Wed Oct 16 14:53:22 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.h Wed Nov 13 10:49:19 2019 +0000
@@ -78,6 +78,7 @@
TAILQ_HEAD(arp_statehead, arp_state);
struct iarp_state {
+ struct interface *ifp;
int bpf_fd;
unsigned int bpf_flags;
struct arp_statehead arp_states;
diff -r a8ac931965f2 -r 7bb4be5969db external/bsd/dhcpcd/dist/src/control.c
--- a/external/bsd/dhcpcd/dist/src/control.c Wed Oct 16 14:53:22 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/control.c Wed Nov 13 10:49:19 2019 +0000
@@ -274,9 +274,8 @@
if (ctx->control_fd == -1)
return 0;
- eloop_event_delete(ctx->eloop, ctx->control_fd);
- close(ctx->control_fd);
- ctx->control_fd = -1;
+
+ control_close(ctx);
if (unlink(ctx->control_sock) == -1)
retval = -1;
@@ -455,6 +454,7 @@
{
if (ctx->control_fd != -1) {
+ eloop_event_delete(ctx->eloop, ctx->control_fd);
close(ctx->control_fd);
ctx->control_fd = -1;
}
diff -r a8ac931965f2 -r 7bb4be5969db external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h Wed Oct 16 14:53:22 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h Wed Nov 13 10:49:19 2019 +0000
@@ -29,7 +29,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "8.1.1"
+#define VERSION "8.1.2"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
diff -r a8ac931965f2 -r 7bb4be5969db external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c Wed Oct 16 14:53:22 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c Wed Nov 13 10:49:19 2019 +0000
@@ -41,6 +41,10 @@
#include <netinet/udp.h>
#undef __FAVOR_BSD
+#ifdef AF_LINK
+# include <net/if_dl.h>
+#endif
+
#include <assert.h>
#include <ctype.h>
#include <errno.h>
@@ -132,9 +136,7 @@
#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
@@ -1550,7 +1552,10 @@
n = 1;
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n)) == -1)
goto eexit;
-#ifdef IP_RECVPKTINFO
+#ifdef IP_RECVIF
+ if (setsockopt(s, IPPROTO_IP, IP_RECVIF, &n, sizeof(n)) == -1)
+ goto eexit;
+#else
if (setsockopt(s, IPPROTO_IP, IP_RECVPKTINFO, &n, sizeof(n)) == -1)
goto eexit;
#endif
@@ -1647,39 +1652,36 @@
static ssize_t
dhcp_sendudp(struct interface *ifp, struct in_addr *to, void *data, size_t len)
{
- int s;
- struct msghdr msg;
- struct sockaddr_in sin;
- struct iovec iov[1];
+ 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 dhcp_state *state = D_STATE(ifp);
ssize_t r;
-
- 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
-
- 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)
+ int fd;
+
+ fd = state->udp_fd;
+ if (fd == -1) {
+ fd = dhcp_openudp(ifp);
+ if (fd == -1)
return -1;
}
- r = sendmsg(s, &msg, 0);
+ r = sendmsg(fd, &msg, 0);
if (state->udp_fd == -1)
- close(s);
+ close(fd);
return r;
}
@@ -1780,7 +1782,7 @@
* As such we remove it from consideration without actually
* stopping the interface. */
if (r == -1) {
- logerr("%s: if_sendraw", ifp->name);
+ logerr("%s: bpf_send", ifp->name);
switch(errno) {
case ENETDOWN:
case ENETRESET:
@@ -2257,30 +2259,27 @@
ipv4_applyaddr(ifp);
-#ifdef IP_PKTINFO
/* Close the BPF filter as we can now receive DHCP messages
* on a UDP socket. */
- if (state->udp_fd == -1 ||
- (state->old != NULL && state->old->yiaddr != state->new->yiaddr))
- {
- dhcp_close(ifp);
- /* If not in master mode, open an address specific socket. */
- if (ctx->udp_fd == -1) {
- state->udp_fd = dhcp_openudp(ifp);
- if (state->udp_fd == -1) {
- logerr(__func__);
- /* Address sharing without master mode is
- * not supported. It's also possible another
- * DHCP client could be running which is
- * even worse.
- * We still need to work, so re-open BPF. */
- dhcp_openbpf(ifp);
- } else
- eloop_event_add(ctx->eloop,
- state->udp_fd, dhcp_handleifudp, ifp);
- }
+ if (!(state->udp_fd == -1 ||
+ (state->old != NULL && state->old->yiaddr != state->new->yiaddr)))
+ return;
+ dhcp_close(ifp);
+
+ /* If not in master mode, open an address specific socket. */
+ if (ctx->udp_fd != -1)
+ return;
+ state->udp_fd = dhcp_openudp(ifp);
+ if (state->udp_fd == -1) {
+ logerr(__func__);
+ /* Address sharing without master mode is not supported.
+ * It's also possible another DHCP client could be running,
+ * which is even worse.
+ * We still need to work, so re-open BPF. */
+ dhcp_openbpf(ifp);
+ return;
}
-#endif
+ eloop_event_add(ctx->eloop, state->udp_fd, dhcp_handleifudp, ifp);
}
static void
@@ -2609,6 +2608,11 @@
ifp->name, inet_ntoa(state->lease.addr));
#ifdef ARP
+#ifndef KERNEL_RFC5227
+ /* Create the DHCP ARP state so we can defend it. */
+ (void)dhcp_arp_new(ifp, &state->lease.addr);
+#endif
+
/* If the address exists on the interface and no other interface
* is currently using it then announce it to ensure this
* interface gets the reply. */
@@ -3315,7 +3319,7 @@
struct ip *ip = packet;
union pip {
struct ip ip;
- uint16_t w[sizeof(struct ip)];
+ uint16_t w[sizeof(struct ip) / 2];
} pip = {
Home |
Main Index |
Thread Index |
Old Index