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 Sync



details:   https://anonhg.NetBSD.org/src/rev/7b84bc1393d8
branches:  trunk
changeset: 334015:7b84bc1393d8
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Nov 26 13:43:06 2014 +0000

description:
Sync

diffstat:

 external/bsd/dhcpcd/dist/arp.c        |  19 ++++---
 external/bsd/dhcpcd/dist/defs.h       |   4 +-
 external/bsd/dhcpcd/dist/dhcp.c       |  54 ++++++++++++++++++++---
 external/bsd/dhcpcd/dist/dhcp6.c      |   6 +-
 external/bsd/dhcpcd/dist/dhcpcd.8.in  |  30 +++++++-----
 external/bsd/dhcpcd/dist/dhcpcd.c     |  78 ++++++++++++++++++++++------------
 external/bsd/dhcpcd/dist/dhcpcd.h     |   4 +-
 external/bsd/dhcpcd/dist/if-options.c |  22 +++++++++-
 external/bsd/dhcpcd/dist/if-options.h |   3 +-
 external/bsd/dhcpcd/dist/if.c         |  55 ++++++++++++++++--------
 external/bsd/dhcpcd/dist/ipv4.c       |  25 ++++++++--
 external/bsd/dhcpcd/dist/ipv4.h       |   6 ++-
 external/bsd/dhcpcd/dist/ipv6nd.c     |   4 +-
 13 files changed, 218 insertions(+), 92 deletions(-)

diffs (truncated from 752 to 300 lines):

diff -r 538d20973d28 -r 7b84bc1393d8 external/bsd/dhcpcd/dist/arp.c
--- a/external/bsd/dhcpcd/dist/arp.c    Wed Nov 26 10:50:36 2014 +0000
+++ b/external/bsd/dhcpcd/dist/arp.c    Wed Nov 26 13:43:06 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: arp.c,v 1.7 2014/11/14 12:00:54 roy Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.8 2014/11/26 13:43:06 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -127,7 +127,7 @@
        while (!(flags & RAW_EOF)) {
                bytes = if_readrawpacket(ifp, ETHERTYPE_ARP,
                    arp_buffer, sizeof(arp_buffer), &flags);
-               if (bytes == 0 || bytes == -1) {
+               if (bytes == -1) {
                        syslog(LOG_ERR, "%s: arp if_readrawpacket: %m",
                            ifp->name);
                        dhcp_close(ifp);
@@ -217,13 +217,15 @@
 
        if (++astate->claims < ANNOUNCE_NUM)
                syslog(LOG_DEBUG,
-                   "%s: sending ARP announce (%d of %d), "
+                   "%s: ARP announcing %s (%d of %d), "
                    "next in %d.0 seconds",
-                   ifp->name, astate->claims, ANNOUNCE_NUM, ANNOUNCE_WAIT);
+                   ifp->name, inet_ntoa(astate->addr),
+                   astate->claims, ANNOUNCE_NUM, ANNOUNCE_WAIT);
        else
                syslog(LOG_DEBUG,
-                   "%s: sending ARP announce (%d of %d)",
-                   ifp->name, astate->claims, ANNOUNCE_NUM);
+                   "%s: ARP announcing %s (%d of %d)",
+                   ifp->name, inet_ntoa(astate->addr),
+                   astate->claims, ANNOUNCE_NUM);
        if (arp_send(ifp, ARPOP_REQUEST,
                astate->addr.s_addr, astate->addr.s_addr) == -1)
                syslog(LOG_ERR, "send_arp: %m");
@@ -268,8 +270,9 @@
                eloop_timeout_add_tv(ifp->ctx->eloop, &tv, arp_probed, astate);
        }
        syslog(LOG_DEBUG,
-           "%s: sending ARP probe (%d of %d), next in %0.1f seconds",
-           ifp->name, astate->probes ? astate->probes : PROBE_NUM, PROBE_NUM,
+           "%s: ARP probing %s (%d of %d), next in %0.1f seconds",
+           ifp->name, inet_ntoa(astate->addr),
+           astate->probes ? astate->probes : PROBE_NUM, PROBE_NUM,
            timeval_to_double(&tv));
        if (arp_send(ifp, ARPOP_REQUEST, 0, astate->addr.s_addr) == -1)
                syslog(LOG_ERR, "send_arp: %m");
diff -r 538d20973d28 -r 7b84bc1393d8 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Wed Nov 26 10:50:36 2014 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Wed Nov 26 13:43:06 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.7 2014/11/14 12:00:54 roy Exp $ */
+/* $NetBSD: defs.h,v 1.8 2014/11/26 13:43:06 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "6.6.2"
+#define VERSION                        "6.6.3"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r 538d20973d28 -r 7b84bc1393d8 external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c   Wed Nov 26 10:50:36 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c   Wed Nov 26 13:43:06 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp.c,v 1.23 2014/11/14 12:00:54 roy Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.24 2014/11/26 13:43:06 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -1599,7 +1599,8 @@
        if (dhcp_open(iface) == -1)
                return;
 
-       if (state->added && state->addr.s_addr != INADDR_ANY &&
+       if (state->added && !(state->added & STATE_FAKE) &&
+           state->addr.s_addr != INADDR_ANY &&
            state->new != NULL &&
            (state->new->cookie == htonl(MAGIC_COOKIE) ||
            iface->options->options & DHCPCD_INFORM))
@@ -1967,15 +1968,15 @@
        if (ifo->options & DHCPCD_ARP) {
                if (state->added) {
                        if (astate == NULL) {
-                               /* We don't care about what happens
-                                * to the ARP announcement */
                                astate = arp_new(ifp);
+                               astate->addr = state->addr;
                                astate->announced_cb =
                                    dhcp_arp_announced;
                        }
                        if (astate) {
                                arp_announce(astate);
-                               arp_free_but(astate);
+                               if (!ipv4ll)
+                                       arp_free_but(astate);
                        }
                } else if (!ipv4ll)
                        arp_close(ifp);
@@ -2185,6 +2186,7 @@
                dhcp_auth_reset(&state->auth);
                dhcp_close(ifp);
        }
+
        if (ifp->options->options & DHCPCD_RELEASE) {
                unlink(state->leasefile);
                if (ifp->carrier != LINK_DOWN &&
@@ -2203,6 +2205,7 @@
 #endif
                }
        }
+
        free(state->old);
        state->old = state->new;
        state->new = NULL;
@@ -2785,7 +2788,7 @@
        while (!(flags & RAW_EOF)) {
                bytes = (size_t)if_readrawpacket(ifp, ETHERTYPE_IP,
                    ifp->ctx->packet, udp_dhcp_len, &flags);
-               if (bytes == 0 || (ssize_t)bytes == -1) {
+               if ((ssize_t)bytes == -1) {
                        syslog(LOG_ERR, "%s: dhcp if_readrawpacket: %m",
                            ifp->name);
                        dhcp_close(ifp);
@@ -2793,7 +2796,7 @@
                        break;
                }
                if (valid_udp_packet(ifp->ctx->packet, bytes,
-                       &from, flags & RAW_PARTIALCSUM) == -1)
+                   &from, flags & RAW_PARTIALCSUM) == -1)
                {
                        syslog(LOG_ERR, "%s: invalid UDP packet from %s",
                            ifp->name, inet_ntoa(from));
@@ -3129,6 +3132,24 @@
        if (state->offer) {
                get_lease(ifp->ctx, &state->lease, state->offer);
                state->lease.frominfo = 1;
+               if (state->new == NULL &&
+                   ipv4_iffindaddr(ifp, &state->lease.addr, &state->lease.net))
+               {
+                       /* We still have the IP address from the last lease.
+                        * Fake add the address and routes from it so the lease
+                        * can be cleaned up. */
+                       state->new = malloc(sizeof(*state->new));
+                       if (state->new) {
+                               memcpy(state->new, state->offer,
+                                   sizeof(*state->new));
+                               state->addr = state->lease.addr;
+                               state->net = state->lease.net;
+                               state->added |= STATE_ADDED | STATE_FAKE;
+                               ipv4_sortinterfaces(ifp->ctx);
+                               ipv4_buildroutes(ifp->ctx);
+                       } else
+                               syslog(LOG_ERR, "%s: %m", __func__);
+               }
                if (state->offer->cookie == 0) {
                        if (state->offer->yiaddr == state->addr.s_addr) {
                                free(state->offer);
@@ -3148,6 +3169,22 @@
                                free(state->offer);
                                state->offer = NULL;
                                state->lease.addr.s_addr = 0;
+                               /* Technically we should discard the lease
+                                * as it's expired, just as DHCPv6 addresses
+                                * would be by the kernel.
+                                * However, this may violate POLA so
+                                * we currently leave it be.
+                                * If we get a totally different lease from
+                                * the DHCP server we'll drop it anyway, as
+                                * we will on any other event which would
+                                * trigger a lease drop.
+                                * This should only happen if dhcpcd stops
+                                * running and the lease expires before
+                                * dhcpcd starts again. */
+#if 0
+                               if (state->new)
+                                       dhcp_drop(ifp, "EXPIRE");
+#endif
                        } else {
                                l = (uint32_t)(now.tv_sec - st.st_mtime);
                                state->lease.leasetime -= l;
@@ -3171,7 +3208,8 @@
        if (state->offer == NULL || state->offer->cookie == 0) {
                /* If we don't have an address yet, enter the reboot
                 * state to ensure at least fallback in short order. */
-               if (state->addr.s_addr == INADDR_ANY)
+               if (state->addr.s_addr == INADDR_ANY ||
+                   state->added & STATE_FAKE)
                        state->state = DHS_REBOOT;
                dhcp_discover(ifp);
        } else
diff -r 538d20973d28 -r 7b84bc1393d8 external/bsd/dhcpcd/dist/dhcp6.c
--- a/external/bsd/dhcpcd/dist/dhcp6.c  Wed Nov 26 10:50:36 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp6.c  Wed Nov 26 13:43:06 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp6.c,v 1.6 2014/11/07 20:51:02 roy Exp $");
+ __RCSID("$NetBSD: dhcp6.c,v 1.7 2014/11/26 13:43:06 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -2554,7 +2554,7 @@
        ctx = dhcpcd_ctx->ipv6;
        ctx->rcvhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
        bytes = recvmsg(ctx->dhcp_fd, &ctx->rcvhdr, 0);
-       if (bytes == -1 || bytes == 0) {
+       if (bytes == -1) {
                syslog(LOG_ERR, "recvmsg: %m");
                close(ctx->dhcp_fd);
                eloop_event_delete(dhcpcd_ctx->eloop, ctx->dhcp_fd, 0);
@@ -2565,7 +2565,7 @@
        ctx->sfrom = inet_ntop(AF_INET6, &ctx->from.sin6_addr,
            ctx->ntopbuf, sizeof(ctx->ntopbuf));
        if (len < sizeof(struct dhcp6_message)) {
-               syslog(LOG_ERR, "DHCPv6 RA packet too short from %s",
+               syslog(LOG_ERR, "DHCPv6 packet too short from %s",
                    ctx->sfrom);
                return;
        }
diff -r 538d20973d28 -r 7b84bc1393d8 external/bsd/dhcpcd/dist/dhcpcd.8.in
--- a/external/bsd/dhcpcd/dist/dhcpcd.8.in      Wed Nov 26 10:50:36 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.8.in      Wed Nov 26 13:43:06 2014 +0000
@@ -1,4 +1,4 @@
-.\"     $NetBSD: dhcpcd.8.in,v 1.36 2014/11/07 20:51:02 roy Exp $
+.\"     $NetBSD: dhcpcd.8.in,v 1.37 2014/11/26 13:43:06 roy Exp $
 .\" Copyright (c) 2006-2014 Roy Marples
 .\" All rights reserved
 .\"
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd September 30, 2014
+.Dd November 18, 2014
 .Dt DHCPCD 8
 .Os
 .Sh NAME
@@ -102,6 +102,16 @@
 changes when the lease beings to expire or the DHCP server sends message
 to renew early.
 .Pp
+If any interface reports a working carrier then
+.Nm
+will try and obtain a lease before forking to the background,
+otherwise it will fork right away.
+This behaviour can be modified with the
+.Fl b , Fl Fl background
+and
+.Fl w , Fl Fl waitip
+options.
+.Pp
 .Nm
 is also an implementation of the BOOTP client specified in
 .Li RFC 951 .
@@ -143,8 +153,11 @@
 .Nm
 only works with those interfaces, otherwise
 .Nm
-discovers available Ethernet interfaces.
-This is called Master mode and this behaviour can be forced with the
+discovers available Ethernet interfaces that can be configured.
+When
+.Nm
+is operating on more than one interface,
+it is called Master mode. and this behaviour can be forced with the
 .Fl M , Fl Fl master
 option so that an individual interface can start
 .Nm
@@ -152,15 +165,6 @@
 The
 .Nm dhcpcd-ui
 project expects dhcpcd to be running this way.
-If any interface reports a working carrier then
-.Nm
-will try and obtain a lease before forking to the background,
-otherwise it will fork right away.
-This behaviour can be modified with the
-.Fl b , Fl Fl background
-and
-.Fl w , Fl Fl waitip
-options.
 .Pp
 If a single interface is given then
 .Nm
diff -r 538d20973d28 -r 7b84bc1393d8 external/bsd/dhcpcd/dist/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/dhcpcd.c Wed Nov 26 10:50:36 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.c Wed Nov 26 13:43:06 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcpcd.c,v 1.17 2014/11/14 12:00:54 roy Exp $");
+ __RCSID("$NetBSD: dhcpcd.c,v 1.18 2014/11/26 13:43:06 roy Exp $");



Home | Main Index | Thread Index | Old Index