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 Import dhcpcd-7.0.0-rc4 with the foll...



details:   https://anonhg.NetBSD.org/src/rev/5bb3b9388f38
branches:  ROY
changeset: 455204:5bb3b9388f38
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Dec 06 10:33:29 2017 +0000

description:
Import dhcpcd-7.0.0-rc4 with the following changes:
  *  Don't flush prefix routes/routers if kernel does not support RA
  *  dhcp: improve errors around UDP checksum failure
  *  dhcp: announce existing addresses before rebooting
  *  bpf: rework loop so that we can close/reopen fd inside and abort
  *  ipv6nd: don't handle NA/RA for non active interfaces
  *  dhcp6: listen on all addresses in non master mode
  *  dhcpcd-run-hooks: set protocol in dhcpcd, don't guess
  *  Ensure that xid is unique across all interfaces
  *  dhcp6: redirect message to interface which uses the xid
  *  bsd: strip scope from LL addresses when detecting their addition
  *  ipv6nd: fix address lifetime overflow on carrier up
  *  dhcp6: fix confirmation of lease on carrier up

diffstat:

 external/bsd/dhcpcd/dist/README.md                   |    4 +-
 external/bsd/dhcpcd/dist/hooks/01-test               |    3 +-
 external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in |    4 +-
 external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in   |   17 +-
 external/bsd/dhcpcd/dist/src/arp.c                   |   98 ++-
 external/bsd/dhcpcd/dist/src/arp.h                   |    4 +-
 external/bsd/dhcpcd/dist/src/bpf.c                   |    5 +-
 external/bsd/dhcpcd/dist/src/bpf.h                   |    7 +-
 external/bsd/dhcpcd/dist/src/defs.h                  |    2 +-
 external/bsd/dhcpcd/dist/src/dhcp.c                  |  213 +++++---
 external/bsd/dhcpcd/dist/src/dhcp.h                  |    1 +
 external/bsd/dhcpcd/dist/src/dhcp6.c                 |  459 +++++++++++-------
 external/bsd/dhcpcd/dist/src/dhcpcd.c                |   68 +-
 external/bsd/dhcpcd/dist/src/eloop.c                 |    4 +-
 external/bsd/dhcpcd/dist/src/if-bsd.c                |   49 +-
 external/bsd/dhcpcd/dist/src/ipv4.c                  |    5 +-
 external/bsd/dhcpcd/dist/src/ipv6.c                  |   37 +-
 external/bsd/dhcpcd/dist/src/ipv6.h                  |    2 +-
 external/bsd/dhcpcd/dist/src/ipv6nd.c                |   32 +-
 external/bsd/dhcpcd/dist/src/route.h                 |    9 +-
 external/bsd/dhcpcd/dist/src/script.c                |   75 +-
 21 files changed, 625 insertions(+), 473 deletions(-)

diffs (truncated from 1998 to 300 lines):

diff -r 22a900346d5b -r 5bb3b9388f38 external/bsd/dhcpcd/dist/README.md
--- a/external/bsd/dhcpcd/dist/README.md        Sat Oct 07 14:05:36 2017 +0000
+++ b/external/bsd/dhcpcd/dist/README.md        Wed Dec 06 10:33:29 2017 +0000
@@ -72,7 +72,9 @@
 # A ServerID is required by RFC2131.
 require dhcp_server_identifier
 
-# Generate Stable Private IPv6 Addresses instead of hardware based ones
+# Generate SLAAC address using the Hardware Address of the interface
+#slaac hwaddr
+# OR generate Stable Private IPv6 Addresses based from the DUID
 slaac private
 ```
 
diff -r 22a900346d5b -r 5bb3b9388f38 external/bsd/dhcpcd/dist/hooks/01-test
--- a/external/bsd/dhcpcd/dist/hooks/01-test    Sat Oct 07 14:05:36 2017 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/01-test    Wed Dec 06 10:33:29 2017 +0000
@@ -1,7 +1,8 @@
 # Echo the interface flags, reason and message options
 
 if [ "$reason" = "TEST" ]; then
-       set | grep "^\(interface\|pid\|reason\|profile\|skip_hooks\)=" | sort
+       set | grep \
+           "^\(interface\|pid\|reason\|protocol\|profile\|skip_hooks\)=" | sort
        set | grep "^if\(carrier\|flags\|mtu\|wireless\|ssid\)=" | sort
        set | grep "^\(new_\|old_\|nd[0-9]*_\)" | sort
        exit 0
diff -r 22a900346d5b -r 5bb3b9388f38 external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in
--- a/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in      Sat Oct 07 14:05:36 2017 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in      Wed Dec 06 10:33:29 2017 +0000
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd January 23, 2017
+.Dd November 3, 2017
 .Dt DHCPCD-RUN-HOOKS 8
 .Os
 .Sh NAME
@@ -139,6 +139,8 @@
 .Bl -tag -width xnew_delegated_dhcp6_prefix
 .It Ev $interface
 the name of the interface.
+.It Ev $protocol
+the protocol that triggered the event.
 .It Ev $reason
 as described above.
 .It Ev $pid
diff -r 22a900346d5b -r 5bb3b9388f38 external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in
--- a/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in        Sat Oct 07 14:05:36 2017 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in        Wed Dec 06 10:33:29 2017 +0000
@@ -2,22 +2,7 @@
 # dhcpcd client configuration script 
 
 # Handy variables and functions for our hooks to use
-case "$reason" in
-       PREINIT|CARRIER|NOCARRIER|DEPARTED|STOPPED|DUMP|TEST)
-               ifsuffix=;; #unset
-       ROUTERADVERT)
-               ifsuffix=".ra";;
-       INFORM6|BOUND6|RENEW6|REBIND6|REBOOT6|EXPIRE6|RELEASE6|STOP6)
-               ifsuffix=".dhcp6";;
-       IPV4LL)
-               ifsuffix=".ipv4ll";;
-       INFORM|BOUND|RENEW|REBIND|REBOOT|EXPIRE|RELEASE|STOP)
-               ifsuffix=".dhcp";;
-       *)
-               ifsuffix=;; #unset
-esac
-ifname="$interface$ifsuffix"
-
+ifname="$interface${protocol+.}$protocol"
 from=from
 signature_base="# Generated by dhcpcd"
 signature="$signature_base $from $ifname"
diff -r 22a900346d5b -r 5bb3b9388f38 external/bsd/dhcpcd/dist/src/arp.c
--- a/external/bsd/dhcpcd/dist/src/arp.c        Sat Oct 07 14:05:36 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.c        Wed Dec 06 10:33:29 2017 +0000
@@ -98,7 +98,7 @@
        APPEND(&tip, sizeof(tip));
 
        state = ARP_CSTATE(ifp);
-       return bpf_send(ifp, state->fd, ETHERTYPE_ARP, arp_buffer, len);
+       return bpf_send(ifp, state->bpf_fd, ETHERTYPE_ARP, arp_buffer, len);
 
 eexit:
        errno = ENOBUFS;
@@ -177,10 +177,31 @@
 {
        struct iarp_state *state;
 
-       if ((state = ARP_STATE(ifp)) != NULL && state->fd != -1) {
-               eloop_event_delete(ifp->ctx->eloop, state->fd);
-               bpf_close(ifp, state->fd);
-               state->fd = -1;
+       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;
+       }
+}
+
+static void
+arp_tryfree(struct interface *ifp)
+{
+       struct iarp_state *state = ARP_STATE(ifp);
+
+       /* If there are no more ARP states, close the socket. */
+       if (TAILQ_FIRST(&state->arp_states) == NULL) {
+               arp_close(ifp);
+               if (state->bpf_flags & BPF_READING)
+                       state->bpf_flags |= BPF_EOF;
+               else {
+                       free(state);
+                       ifp->if_data[IF_DATA_ARP] = NULL;
+               }
+       } else {
+               if (bpf_arp(ifp, state->bpf_fd) == -1)
+                       logerr(__func__);
        }
 }
 
@@ -188,28 +209,34 @@
 arp_read(void *arg)
 {
        struct interface *ifp = arg;
-       const struct iarp_state *state;
+       struct iarp_state *state;
        uint8_t buf[ARP_LEN];
-       int flags;
        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_CSTATE(ifp);
-       flags = 0;
-       while (!(flags & BPF_EOF)) {
-               bytes = bpf_read(ifp, state->fd, buf, sizeof(buf), &flags);
+       state = ARP_STATE(ifp);
+       state->bpf_flags &= ~BPF_EOF;
+       state->bpf_flags |= BPF_READING;
+       while (!(state->bpf_flags & BPF_EOF)) {
+               bytes = bpf_read(ifp, state->bpf_fd, buf, sizeof(buf),
+                                &state->bpf_flags);
                if (bytes == -1) {
                        logerr("%s: %s", __func__, ifp->name);
                        arp_close(ifp);
-                       return;
+                       break;
                }
                arp_packet(ifp, buf, (size_t)bytes);
                /* Check we still have a state after processing. */
-               if ((state = ARP_CSTATE(ifp)) == NULL || state->fd == -1)
+               if ((state = ARP_STATE(ifp)) == NULL)
                        break;
        }
+       if (state != NULL) {
+               state->bpf_flags &= ~BPF_READING;
+               /* Try and free the state if nothing left to do. */
+               arp_tryfree(ifp);
+       }
 }
 
 int
@@ -218,15 +245,15 @@
        struct iarp_state *state;
 
        state = ARP_STATE(ifp);
-       if (state->fd == -1) {
-               state->fd = bpf_open(ifp, bpf_arp);
-               if (state->fd == -1) {
+       if (state->bpf_fd == -1) {
+               state->bpf_fd = bpf_open(ifp, bpf_arp);
+               if (state->bpf_fd == -1) {
                        logerr("%s: %s", __func__, ifp->name);
                        return -1;
                }
-               eloop_event_add(ifp->ctx->eloop, state->fd, arp_read, ifp);
+               eloop_event_add(ifp->ctx->eloop, state->bpf_fd, arp_read, ifp);
        }
-       return state->fd;
+       return state->bpf_fd;
 }
 
 static void
@@ -273,7 +300,7 @@
        } else {
                const struct iarp_state *state = ARP_CSTATE(astate->iface);
 
-               if (bpf_arp(astate->iface, state->fd) == -1)
+               if (bpf_arp(astate->iface, state->bpf_fd) == -1)
                        logerr(__func__);
        }
        astate->probes = 0;
@@ -373,10 +400,16 @@
 arp_announceaddr(struct dhcpcd_ctx *ctx, struct in_addr *ia)
 {
        struct interface *ifp;
+       struct ipv4_addr *iaf;
        struct arp_state *astate;
 
        TAILQ_FOREACH(ifp, ctx->ifaces, next) {
-               if (ipv4_iffindaddr(ifp, ia, NULL))
+               iaf = ipv4_iffindaddr(ifp, ia, NULL);
+#ifdef IN_IFF_NOTUSEABLE
+               if (iaf && !(iaf->addr_flags & IN_IFF_NOTUSEABLE))
+#else
+               if (iaf)
+#endif
                        break;
        }
        if (ifp == NULL)
@@ -388,6 +421,16 @@
 }
 
 void
+arp_ifannounceaddr(struct interface *ifp, struct in_addr *ia)
+{
+       struct arp_state *astate;
+
+       astate = arp_new(ifp, ia);
+       if (astate != NULL)
+               arp_announce(astate);
+}
+
+void
 arp_report_conflicted(const struct arp_state *astate,
     const struct arp_msg *amsg)
 {
@@ -435,7 +478,8 @@
                        logerr(__func__);
                        return NULL;
                }
-               state->fd = -1;
+               state->bpf_fd = -1;
+               state->bpf_flags = 0;
                TAILQ_INIT(&state->arp_states);
        } else {
                if (addr && (astate = arp_find(ifp, addr)))
@@ -452,7 +496,7 @@
        state = ARP_STATE(ifp);
        TAILQ_INSERT_TAIL(&state->arp_states, astate, next);
 
-       if (bpf_arp(ifp, state->fd) == -1)
+       if (bpf_arp(ifp, state->bpf_fd) == -1)
                logerr(__func__); /* try and continue */
 
        return astate;
@@ -481,15 +525,7 @@
        if (astate->free_cb)
                astate->free_cb(astate);
        free(astate);
-
-       /* If there are no more ARP states, close the socket. */
-       if (TAILQ_FIRST(&state->arp_states) == NULL) {
-               arp_close(ifp);
-               free(state);
-               ifp->if_data[IF_DATA_ARP] = NULL;
-       } else
-               if (bpf_arp(ifp, state->fd) == -1)
-                       logerr(__func__);
+       arp_tryfree(ifp);
 }
 
 static void
diff -r 22a900346d5b -r 5bb3b9388f38 external/bsd/dhcpcd/dist/src/arp.h
--- a/external/bsd/dhcpcd/dist/src/arp.h        Sat Oct 07 14:05:36 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.h        Wed Dec 06 10:33:29 2017 +0000
@@ -76,7 +76,8 @@
 TAILQ_HEAD(arp_statehead, arp_state);
 
 struct iarp_state {
-       int fd;
+       int bpf_fd;
+       unsigned int bpf_flags;
        struct arp_statehead arp_states;
 };
 
@@ -95,6 +96,7 @@
 struct arp_state *arp_find(struct interface *, const struct in_addr *);
 void arp_announce(struct arp_state *);
 void arp_announceaddr(struct dhcpcd_ctx *, struct in_addr *);
+void arp_ifannounceaddr(struct interface *, struct in_addr *);
 void arp_cancel(struct arp_state *);
 void arp_free(struct arp_state *);
 void arp_free_but(struct arp_state *);
diff -r 22a900346d5b -r 5bb3b9388f38 external/bsd/dhcpcd/dist/src/bpf.c
--- a/external/bsd/dhcpcd/dist/src/bpf.c        Sat Oct 07 14:05:36 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/bpf.c        Wed Dec 06 10:33:29 2017 +0000
@@ -194,7 +194,8 @@
 /* BPF requires that we read the entire buffer.
  * So we pass the buffer in the API so we can loop on >1 packet. */
 ssize_t
-bpf_read(struct interface *ifp, int fd, void *data, size_t len, int *flags)
+bpf_read(struct interface *ifp, int fd, void *data, size_t len,
+    unsigned int *flags)
 {
        ssize_t fl = (ssize_t)bpf_frame_header_len(ifp);



Home | Main Index | Thread Index | Old Index