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 Sync



details:   https://anonhg.NetBSD.org/src/rev/621c66eda572
branches:  trunk
changeset: 965186:621c66eda572
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Sep 04 13:28:56 2019 +0000

description:
Sync

diffstat:

 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/if-bsd.c    |   60 +++++--
 external/bsd/dhcpcd/dist/src/ipv6.c      |   76 +++++++++-
 external/bsd/dhcpcd/dist/src/ipv6.h      |    7 +-
 external/bsd/dhcpcd/dist/src/ipv6nd.c    |  219 +++++++++++-------------------
 8 files changed, 253 insertions(+), 220 deletions(-)

diffs (truncated from 1041 to 300 lines):

diff -r 523e441c0206 -r 621c66eda572 external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c       Wed Sep 04 13:27:50 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c       Wed Sep 04 13:28:56 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 523e441c0206 -r 621c66eda572 external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c      Wed Sep 04 13:27:50 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c      Wed Sep 04 13:28:56 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 523e441c0206 -r 621c66eda572 external/bsd/dhcpcd/dist/src/dhcpcd.8.in
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.8.in  Wed Sep 04 13:27:50 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.8.in  Wed Sep 04 13:28:56 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
 directly requested.
-.It Fl W, Fl Fl whitelist Ar address Ns Op /cidr
+.It Fl W , Fl Fl whitelist Ar address Ns Op /cidr
 Only accept packets from
 .Ar address Ns Op /cidr .
-.Fl X, Fl Fl blacklist
+.Fl X , Fl Fl blacklist
 is ignored if
-.Fl W, Fl Fl whitelist
+.Fl W , Fl Fl whitelist
 is set.
-.It Fl X, Fl Fl blacklist Ar address Ns Op Ar /cidr
+.It Fl X , Fl Fl blacklist Ar address Ns Op Ar /cidr
 Ignore all packets from
 .Ar address Ns Op Ar /cidr .
 .It Fl Z , Fl Fl denyinterfaces Ar pattern
@@ -771,6 +771,7 @@
 .It Pa @SCRIPT@
 Bourne shell script that is run to configure or de-configure an interface.
 .It Pa @LIBDIR@/dhcpcd/dev
+Linux
 .Pa /dev
 management modules.
 .It Pa @HOOKDIR@
@@ -818,7 +819,7 @@
 .Xr dhcpcd-run-hooks 8 ,
 .Xr resolvconf 8
 .Sh STANDARDS
-RFC\ 951, RFC\ 1534, RFC\ 2104, RFC\ 2131, RFC\ 2132, RFC\ 2563, RFC\ 2855, 
+RFC\ 951, RFC\ 1534, RFC\ 2104, RFC\ 2131, RFC\ 2132, RFC\ 2563, RFC\ 2855,
 RFC\ 3004, RFC\ 3118, RFC\ 3203, RFC\ 3315, RFC\ 3361, RFC\ 3633, RFC\ 3396,
 RFC\ 3397, RFC\ 3442, RFC\ 3495, RFC\ 3925, RFC\ 3927, RFC\ 4039, RFC\ 4075,
 RFC\ 4242, RFC\ 4361, RFC\ 4390, RFC\ 4702, RFC\ 4074, RFC\ 4861, RFC\ 4833,
diff -r 523e441c0206 -r 621c66eda572 external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c     Wed Sep 04 13:27:50 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c     Wed Sep 04 13:28:56 2019 +0000
@@ -950,12 +950,7 @@



Home | Main Index | Thread Index | Old Index