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 Import dhcpcd-8.1.2 with the fo...



details:   https://anonhg.NetBSD.org/src/rev/0e4d0675a50e
branches:  trunk
changeset: 461018:0e4d0675a50e
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/eloop.c   |  27 ++++++++-
 external/bsd/dhcpcd/dist/src/eloop.h   |   1 +
 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.h  |   5 +
 external/bsd/dhcpcd/dist/src/script.c  |  87 +++++++++++++++++++--------------
 11 files changed, 124 insertions(+), 70 deletions(-)

diffs (truncated from 469 to 300 lines):

diff -r 1cf59106a802 -r 0e4d0675a50e external/bsd/dhcpcd/dist/src/arp.c
--- a/external/bsd/dhcpcd/dist/src/arp.c        Wed Nov 13 10:13:41 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 1cf59106a802 -r 0e4d0675a50e external/bsd/dhcpcd/dist/src/arp.h
--- a/external/bsd/dhcpcd/dist/src/arp.h        Wed Nov 13 10:13:41 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 1cf59106a802 -r 0e4d0675a50e external/bsd/dhcpcd/dist/src/control.c
--- a/external/bsd/dhcpcd/dist/src/control.c    Wed Nov 13 10:13:41 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 1cf59106a802 -r 0e4d0675a50e external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Wed Nov 13 10:13:41 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 1cf59106a802 -r 0e4d0675a50e external/bsd/dhcpcd/dist/src/eloop.c
--- a/external/bsd/dhcpcd/dist/src/eloop.c      Wed Nov 13 10:13:41 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/eloop.c      Wed Nov 13 10:49:19 2019 +0000
@@ -830,7 +830,8 @@
        return eloop;
 }
 
-void eloop_free(struct eloop *eloop)
+void
+eloop_clear(struct eloop *eloop)
 {
        struct eloop_event *e;
        struct eloop_timeout *t;
@@ -839,6 +840,12 @@
                return;
 
        free(eloop->event_fds);
+       eloop->event_fds = NULL;
+       eloop->events_len = 0;
+       eloop->events_maxfd = -1;
+       eloop->signals = NULL;
+       eloop->signals_len = 0;
+
        while ((e = TAILQ_FIRST(&eloop->events))) {
                TAILQ_REMOVE(&eloop->events, e, next);
                free(e);
@@ -855,11 +862,23 @@
                TAILQ_REMOVE(&eloop->free_timeouts, t, next);
                free(t);
        }
+
+#if defined(HAVE_POLL)
+       free(eloop->fds);
+       eloop->fds = NULL;
+       eloop->fds_len = 0;
+#endif
+}
+
+void
+eloop_free(struct eloop *eloop)
+{
+
 #if defined(HAVE_KQUEUE) || defined(HAVE_EPOLL)
-       close(eloop->poll_fd);
-#elif defined(HAVE_POLL)
-       free(eloop->fds);
+       if (eloop != NULL)
+               close(eloop->poll_fd);
 #endif
+       eloop_clear(eloop);
        free(eloop);
 }
 
diff -r 1cf59106a802 -r 0e4d0675a50e external/bsd/dhcpcd/dist/src/eloop.h
--- a/external/bsd/dhcpcd/dist/src/eloop.h      Wed Nov 13 10:13:41 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/eloop.h      Wed Nov 13 10:49:19 2019 +0000
@@ -105,6 +105,7 @@
 
 struct eloop * eloop_new(void);
 int eloop_requeue(struct eloop *);
+void eloop_clear(struct eloop *);
 void eloop_free(struct eloop *);
 void eloop_exit(struct eloop *, int);
 int eloop_start(struct eloop *, sigset_t *);
diff -r 1cf59106a802 -r 0e4d0675a50e external/bsd/dhcpcd/dist/src/if.c
--- a/external/bsd/dhcpcd/dist/src/if.c Wed Nov 13 10:13:41 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/if.c Wed Nov 13 10:49:19 2019 +0000
@@ -740,9 +740,13 @@
        struct cmsghdr *cm;
        unsigned int ifindex = 0;
        struct interface *ifp;
-#if defined(INET) && defined(IP_PKTINFO)
+#ifdef INET
+#ifdef IP_RECVIF
+       struct sockaddr_dl sdl;
+#else
        struct in_pktinfo ipi;
 #endif
+#endif
 #ifdef INET6
        struct in6_pktinfo ipi6;
 #else
@@ -753,15 +757,27 @@
             cm;
             cm = (struct cmsghdr *)CMSG_NXTHDR(msg, cm))
        {
-#if defined(INET) && defined(IP_PKTINFO)
+#ifdef INET
                if (cm->cmsg_level == IPPROTO_IP) {
                        switch(cm->cmsg_type) {
+#ifdef IP_RECVIF
+                       case IP_RECVIF:
+                               if (cm->cmsg_len <
+                                   offsetof(struct sockaddr_dl, sdl_index) +
+                                   sizeof(sdl.sdl_index))
+                                       continue;
+                               memcpy(&sdl, CMSG_DATA(cm),
+                                   MIN(sizeof(sdl), cm->cmsg_len));
+                               ifindex = sdl.sdl_index;
+                               break;
+#else
                        case IP_PKTINFO:
                                if (cm->cmsg_len != CMSG_LEN(sizeof(ipi)))
                                        continue;
                                memcpy(&ipi, CMSG_DATA(cm), sizeof(ipi));
                                ifindex = (unsigned int)ipi.ipi_ifindex;
                                break;
+#endif
                        }
                }
 #endif
diff -r 1cf59106a802 -r 0e4d0675a50e external/bsd/dhcpcd/dist/src/if.h
--- a/external/bsd/dhcpcd/dist/src/if.h Wed Nov 13 10:13:41 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/if.h Wed Nov 13 10:49:19 2019 +0000
@@ -65,6 +65,7 @@
 #include "dhcpcd.h"
 #include "ipv4.h"
 #include "ipv6.h"
+#include "ipv6nd.h"
 #include "route.h"
 
 #define EUI64_ADDR_LEN                 8
@@ -195,6 +196,7 @@
 #endif
 
 #ifdef INET6
+void if_disable_rtadv(void);
 void if_setup_inet6(const struct interface *);
 #ifdef IPV6_MANAGETEMPADDR
 int ip6_use_tempaddr(const char *ifname);
@@ -205,6 +207,7 @@
 #endif
 int ip6_forwarding(const char *ifname);
 
+int if_applyra(const struct ra *);
 int if_address6(unsigned char, const struct ipv6_addr *);
 int if_addrflags6(const struct interface *, const struct in6_addr *,
     const char *);
diff -r 1cf59106a802 -r 0e4d0675a50e external/bsd/dhcpcd/dist/src/ipv4.c
--- a/external/bsd/dhcpcd/dist/src/ipv4.c       Wed Nov 13 10:13:41 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/ipv4.c       Wed Nov 13 10:49:19 2019 +0000
@@ -654,7 +654,7 @@
 #endif
                ia->flags = IPV4_AF_NEW;
        } else
-               ia->flags |= ~IPV4_AF_NEW;
+               ia->flags &= ~IPV4_AF_NEW;
 
        ia->mask = *mask;
        ia->brd = *bcast;
@@ -687,7 +687,8 @@
                if (errno != EEXIST)
                        logerr("%s: if_addaddress",
                            __func__);
-               free(ia);
+               if (ia->flags & IPV4_AF_NEW)
+                       free(ia);
                return NULL;
        }
 
@@ -941,7 +942,7 @@
 #endif
        }
 
-       if (cmd == RTM_DELADDR && ia != NULL)
+       if (cmd == RTM_DELADDR)
                free(ia);
 }
 
@@ -951,15 +952,13 @@
        struct ipv4_state *state;
        struct ipv4_addr *ia;
 
-       if (ifp) {
-               state = IPV4_STATE(ifp);
-               if (state) {
-                       while ((ia = TAILQ_FIRST(&state->addrs))) {
-                               TAILQ_REMOVE(&state->addrs, ia, next);



Home | Main Index | Thread Index | Old Index