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.0.4 with the foll...



details:   https://anonhg.NetBSD.org/src/rev/5de7dd5e9d32
branches:  ROY
changeset: 455227:5de7dd5e9d32
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Sep 04 13:27:50 2019 +0000

description:
Import dhcpcd-8.0.4 with the following changes:

 * BSD: Fixed router reachability tests
 * inet6: If router unreachable, just solicit a new one
 * inet6: Fon't install a default route if only lladdresses
 * inet6: Stop listening to NA messages
 * BSD: Listen to RTM_MISS messages
 * DHCP: Fix in_cksum for Big Endian
 * DHCP{,6}: Don't log an error if the lease file is truncated

diffstat:

 external/bsd/dhcpcd/dist/src/control.c        |    3 +
 external/bsd/dhcpcd/dist/src/defs.h           |    2 +-
 external/bsd/dhcpcd/dist/src/dhcp-common.c    |    2 +
 external/bsd/dhcpcd/dist/src/dhcp.c           |   39 ++-
 external/bsd/dhcpcd/dist/src/dhcp6.c          |   40 ++--
 external/bsd/dhcpcd/dist/src/dhcpcd.8.in      |   25 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.c         |    7 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in |    8 +-
 external/bsd/dhcpcd/dist/src/if-bsd.c         |   60 ++++--
 external/bsd/dhcpcd/dist/src/if-options.h     |    2 +-
 external/bsd/dhcpcd/dist/src/if.c             |    7 +
 external/bsd/dhcpcd/dist/src/if.h             |    1 +
 external/bsd/dhcpcd/dist/src/ipv4.h           |    3 +-
 external/bsd/dhcpcd/dist/src/ipv6.c           |   76 ++++++++-
 external/bsd/dhcpcd/dist/src/ipv6.h           |    7 +-
 external/bsd/dhcpcd/dist/src/ipv6nd.c         |  219 +++++++++----------------
 external/bsd/dhcpcd/dist/src/ipv6nd.h         |   15 +-
 external/bsd/dhcpcd/dist/src/route.c          |    2 +
 external/bsd/dhcpcd/dist/src/route.h          |    1 +
 19 files changed, 283 insertions(+), 236 deletions(-)

diffs (truncated from 1245 to 300 lines):

diff -r 63776f21efa0 -r 5de7dd5e9d32 external/bsd/dhcpcd/dist/src/control.c
--- a/external/bsd/dhcpcd/dist/src/control.c    Wed Aug 21 17:10:29 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/control.c    Wed Sep 04 13:27:50 2019 +0000
@@ -381,6 +381,9 @@
 {
        struct fd_data *d;
 
+       if (data_len == 0)
+               return 0;
+
 #ifdef CTL_FREE_LIST
        struct fd_data *df;
 
diff -r 63776f21efa0 -r 5de7dd5e9d32 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Wed Aug 21 17:10:29 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h       Wed Sep 04 13:27:50 2019 +0000
@@ -29,7 +29,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "8.0.3"
+#define VERSION                        "8.0.4"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r 63776f21efa0 -r 5de7dd5e9d32 external/bsd/dhcpcd/dist/src/dhcp-common.c
--- a/external/bsd/dhcpcd/dist/src/dhcp-common.c        Wed Aug 21 17:10:29 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp-common.c        Wed Sep 04 13:27:50 2019 +0000
@@ -961,6 +961,8 @@
        }
 
        sz = (size_t)st.st_size;
+       if (sz == 0)
+               goto out;
        if ((buf = malloc(sz)) == NULL)
                goto out;
        if ((len = read(fd, buf, sz)) == -1) {
diff -r 63776f21efa0 -r 5de7dd5e9d32 external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c       Wed Aug 21 17:10:29 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c       Wed Sep 04 13:27:50 2019 +0000
@@ -1176,11 +1176,8 @@
        bytes = dhcp_read_lease_fd(fd, (void **)&lease);
        if (fd_opened)
                close(fd);
-       if (bytes == 0) {
-               free(lease);
-               logerr("%s: dhcp_read_lease_fd", __func__);
+       if (bytes == 0)
                return 0;
-       }
 
        /* Ensure the packet is at lease BOOTP sized
         * with a vendor area of 4 octets
@@ -1584,7 +1581,7 @@
 }
 
 static uint16_t
-in_cksum(void *data, size_t len, uint32_t *isum)
+in_cksum(const void *data, size_t len, uint32_t *isum)
 {
        const uint16_t *word = data;
        uint32_t sum = isum != NULL ? *isum : 0;
@@ -1593,7 +1590,7 @@
                sum += *word++;
 
        if (len == 1)
-               sum += *(const uint8_t *)word;
+               sum += htons((uint16_t)(*(const uint8_t *)word << 8));
 
        if (isum != NULL)
                *isum = sum;
@@ -2237,7 +2234,7 @@
        ipv4_applyaddr(ifp);
 
 #ifdef IP_PKTINFO
-       /* Close the BPF filter as we can now receive the DHCP renew messages
+       /* 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))
@@ -2246,9 +2243,15 @@
                /* 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)
+                       if (state->udp_fd == -1) {
                                logerr(__func__);
-                       else
+                               /* 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);
                }
@@ -3293,7 +3296,8 @@
        pseudo_ip.ip_len = udp->uh_ulen;
        csum = 0;
        in_cksum(&pseudo_ip, sizeof(pseudo_ip), &csum);
-       if (in_cksum(udp, ntohs(udp->uh_ulen), &csum) != uh_sum) {
+       csum = in_cksum(udp, ntohs(udp->uh_ulen), &csum);
+       if (csum != uh_sum) {
                errno = EINVAL;
                return -1;
        }
@@ -3662,6 +3666,7 @@
 dhcp_start1(void *arg)
 {
        struct interface *ifp = arg;
+       struct dhcpcd_ctx *ctx = ifp->ctx;
        struct if_options *ifo = ifp->options;
        struct dhcp_state *state;
        struct stat st;
@@ -3672,17 +3677,19 @@
                return;
 
        /* Listen on *.*.*.*:bootpc so that the kernel never sends an
-        * ICMP port unreachable message back to the DHCP server */
-       if (ifp->ctx->udp_fd == -1) {
-               ifp->ctx->udp_fd = dhcp_openudp(NULL);
-               if (ifp->ctx->udp_fd == -1) {
+        * ICMP port unreachable message back to the DHCP server.
+        * Only do this in master mode so we don't swallow messages
+        * for dhcpcd running on another interface. */
+       if (ctx->udp_fd == -1 && ctx->options & DHCPCD_MASTER) {
+               ctx->udp_fd = dhcp_openudp(NULL);
+               if (ctx->udp_fd == -1) {
                        /* Don't log an error if some other process
                         * is handling this. */
                        if (errno != EADDRINUSE)
                                logerr("%s: dhcp_openudp", __func__);
                } else
-                       eloop_event_add(ifp->ctx->eloop,
-                           ifp->ctx->udp_fd, dhcp_handleudp, ifp->ctx);
+                       eloop_event_add(ctx->eloop,
+                           ctx->udp_fd, dhcp_handleudp, ctx);
        }
 
        if (dhcp_init(ifp) == -1) {
diff -r 63776f21efa0 -r 5de7dd5e9d32 external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c      Wed Aug 21 17:10:29 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c      Wed Sep 04 13:27:50 2019 +0000
@@ -2488,22 +2488,22 @@
        struct dhcp6_state *state;
        struct stat st;
        int fd;
-       struct dhcp6_message *lease;
        time_t now;
        int retval;
-       bool fd_opened;
+       bool read_stdin, fd_opened;
 #ifdef AUTH
        uint8_t *o;
        uint16_t ol;
 #endif
 
        state = D6_STATE(ifp);
-       if (state->leasefile[0] == '\0') {
+       read_stdin = state->leasefile[0] == '\0';
+       if (read_stdin) {
                logdebugx("reading standard input");
                fd = fileno(stdin);
                fd_opened = false;
        } else {
-               logdebugx("%s: reading lease `%s'", ifp->name, state->leasefile);
+               logdebugx("%s: reading lease `%s'", ifp->name,state->leasefile);
                fd = open(state->leasefile, O_RDONLY);
                if (fd != -1 && fstat(fd, &st) == -1) {
                        close(fd);
@@ -2514,18 +2514,18 @@
        if (fd == -1)
                return -1;
        retval = -1;
-       lease = NULL;
        free(state->new);
-       state->new_len = dhcp_read_lease_fd(fd, (void **)&lease);
-       state->new = lease;
+       state->new_len = dhcp_read_lease_fd(fd, (void **)&state->new);
        if (fd_opened)
                close(fd);
-       if (state->new_len == 0)
+
+       if (ifp->ctx->options & DHCPCD_DUMPLEASE || read_stdin)
+               return 0;
+
+       if (state->new_len == 0) {
+               retval = 0;
                goto ex;
-
-       if (ifp->ctx->options & DHCPCD_DUMPLEASE ||
-           state->leasefile[0] == '\0')
-               return 0;
+       }
 
        /* If not validating IA's and if they have expired,
         * skip to the auth check. */
@@ -2546,14 +2546,12 @@
                goto ex;
 
        if (state->expire != ND6_INFINITE_LIFETIME &&
-           state->leasefile[0] != '\0')
+           (time_t)state->expire < now - st.st_mtime &&
+           !(ifp->options->options & DHCPCD_LASTLEASE_EXTEND))
        {
-               if ((time_t)state->expire < now - st.st_mtime &&
-                   !(ifp->options->options & DHCPCD_LASTLEASE_EXTEND)) {
-                       logdebugx("%s: discarding expired lease", ifp->name);
-                       retval = 0;
-                       goto ex;
-               }
+               logdebugx("%s: discarding expired lease", ifp->name);
+               retval = 0;
+               goto ex;
        }
 
 auth:
@@ -2586,12 +2584,10 @@
 
 ex:
        dhcp6_freedrop_addrs(ifp, 0, NULL);
+       unlink(state->leasefile);
        free(state->new);
        state->new = NULL;
        state->new_len = 0;
-       if (!(ifp->ctx->options & DHCPCD_DUMPLEASE) &&
-           state->leasefile[0] != '\0')
-               unlink(state->leasefile);
        return retval;
 }
 
diff -r 63776f21efa0 -r 5de7dd5e9d32 external/bsd/dhcpcd/dist/src/dhcpcd.8.in
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.8.in  Wed Aug 21 17:10:29 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.8.in  Wed Sep 04 13:27:50 2019 +0000
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd July 25, 2019
+.Dd August 28, 2019
 .Dt DHCPCD 8
 .Os
 .Sh NAME
@@ -71,7 +71,7 @@
 .Fl k , Fl Fl release
 .Op interface
 .Nm
-.Fl U, Fl Fl dumplease
+.Fl U , Fl Fl dumplease
 .Ar interface
 .Nm
 .Fl Fl version
@@ -260,7 +260,7 @@
 (link local address + time) is generated,
 otherwise DUID-LL is generated (link local address).
 This, plus the IAID will be used as the
-.Fl I, Fl Fl clientid .
+.Fl I , Fl Fl clientid .
 The DUID generated will be held in
 .Pa @DBDIR@/duid
 and should not be copied to other hosts.
@@ -470,7 +470,7 @@
 .Nm
 is not processing IPv6RA messages and the need for DHCPv6 Information Request
 exists.
-.It Fl S, Fl Fl static Ar value
+.It Fl S , Fl Fl static Ar value
 Configures a static DHCP
 .Ar value .
 If you set
@@ -660,7 +660,7 @@
 .Nm
 on the command line, only warnings and errors will be displayed.
 The messages are still logged though.
-.It Fl T, Fl Fl test
+.It Fl T , Fl Fl test
 On receipt of DHCP messages just call
 .Pa @SCRIPT@
 with the reason of TEST which echos the DHCP variables found in the message
@@ -673,7 +673,7 @@
 To test INFORM the interface needs to be configured with the desired address
 before starting
 .Nm .
-.It Fl U, Fl Fl dumplease Ar interface
+.It Fl U , Fl Fl dumplease Ar interface
 Dumps the last lease for the
 .Ar interface
 to stdout.
@@ -683,20 +683,20 @@
 or
 .Fl 6
 flags to specify an address family.
-.It Fl V, Fl Fl variables
+.It Fl V , Fl Fl variables
 Display a list of option codes, the associated variable and encoding for use in
 .Xr dhcpcd-run-hooks 8 .
 Variables are prefixed with new_ and old_ unless the option number is -.
 Variables without an option are part of the DHCP message and cannot be



Home | Main Index | Thread Index | Old Index