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 Update to dhcpcd-9.0.2 with the f...



details:   https://anonhg.NetBSD.org/src/rev/56b81ca1da62
branches:  roy
changeset: 931062:56b81ca1da62
user:      roy <roy%NetBSD.org@localhost>
date:      Tue Apr 21 09:54:16 2020 +0000

description:
Update to dhcpcd-9.0.2 with the following changes:
 * Control sockets are not opened in test mode
 * privsep: no longer aborts if protocol not available
 * inet6: Don't regen temporary addresses without a state
 * inet6: Reduce RA log spam
 * dhcp6: Don't log when things consitently fail
 * inet6: Add temporary directive to slaac option [1]
 * Ensure current interface flags persist when setting a flag
 * DHCP via BPF is now aligned correctly
 * CMSG buffers are now aligned correctly
 * hostnames are no longer clobbered when being forced and a RA is recieved

[1] dhcpcd no longer looks at any possible kernel settings when deciding to
manage IPv6 temporary addresses or not. You now instruct dhcpcd to do this
in dhcpcd.conf. Playing whack-a-mole with various kernel knobs wasn't fun
and some OS's have or are removing RA and thus temporary address managemnt
from the kernel so said knobs are no longer there.

diffstat:

 external/bsd/dhcpcd/dist/src/defs.h           |    2 +-
 external/bsd/dhcpcd/dist/src/dhcp.c           |   12 +-
 external/bsd/dhcpcd/dist/src/dhcp6.c          |   67 ++++++++++----
 external/bsd/dhcpcd/dist/src/dhcp6.h          |    3 +
 external/bsd/dhcpcd/dist/src/dhcpcd.c         |    4 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in |   11 +-
 external/bsd/dhcpcd/dist/src/if-bsd.c         |  110 +++----------------------
 external/bsd/dhcpcd/dist/src/if-options.c     |    8 +
 external/bsd/dhcpcd/dist/src/if-options.h     |    1 +
 external/bsd/dhcpcd/dist/src/if.c             |   14 +-
 external/bsd/dhcpcd/dist/src/if.h             |    7 -
 external/bsd/dhcpcd/dist/src/ipv6.c           |   27 +++---
 external/bsd/dhcpcd/dist/src/ipv6nd.c         |   13 ++-
 13 files changed, 119 insertions(+), 160 deletions(-)

diffs (truncated from 656 to 300 lines):

diff -r 91e36d242e44 -r 56b81ca1da62 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Mon Apr 13 15:42:20 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h       Tue Apr 21 09:54:16 2020 +0000
@@ -29,7 +29,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "9.0.1"
+#define VERSION                        "9.0.2"
 
 #ifndef PRIVSEP_USER
 # define PRIVSEP_USER          "_" PACKAGE
diff -r 91e36d242e44 -r 56b81ca1da62 external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c       Mon Apr 13 15:42:20 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c       Tue Apr 21 09:54:16 2020 +0000
@@ -3494,8 +3494,9 @@
                            __func__, ifp->name);
                        return;
                }
-               data += fl;
                len -= fl;
+               /* Move the data to avoid alignment errors. */
+               memmove(data, data + fl, len);
        }
 
        /* Validate filter. */
@@ -3608,15 +3609,18 @@
                .iov_base = buf,
                .iov_len = sizeof(buf),
        };
+       union {
+               struct cmsghdr hdr;
 #ifdef IP_RECVIF
-       unsigned char ctl[CMSG_SPACE(sizeof(struct sockaddr_dl))] = { 0 };
+               uint8_t buf[CMSG_SPACE(sizeof(struct sockaddr_dl))];
 #else
-       unsigned char ctl[CMSG_SPACE(sizeof(struct in_pktinfo))] = { 0 };
+               uint8_t buf[CMSG_SPACE(sizeof(struct in_pktinfo))];
 #endif
+       } cmsgbuf = { .buf = { 0 } };
        struct msghdr msg = {
            .msg_name = &from, .msg_namelen = sizeof(from),
            .msg_iov = &iov, .msg_iovlen = 1,
-           .msg_control = ctl, .msg_controllen = sizeof(ctl),
+           .msg_control = buf, .msg_controllen = sizeof(cmsgbuf.buf),
        };
        int s;
        ssize_t bytes;
diff -r 91e36d242e44 -r 56b81ca1da62 external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c      Mon Apr 13 15:42:20 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c      Tue Apr 21 09:54:16 2020 +0000
@@ -1585,6 +1585,7 @@
 {
        struct interface *ifp;
        struct dhcp6_state *state;
+       int llevel;
 
        ifp = arg;
        state = D6_STATE(ifp);
@@ -1592,7 +1593,11 @@
        if (state->reason == NULL || strcmp(state->reason, "TIMEOUT6") != 0)
                dhcp6_delete_delegates(ifp);
 #endif
-       loginfox("%s: soliciting a DHCPv6 lease", ifp->name);
+       if (state->new == NULL && !state->failed)
+               llevel = LOG_INFO;
+       else
+               llevel = LOG_DEBUG;
+       logmessage(llevel, "%s: soliciting a DHCPv6 lease", ifp->name);
        state->state = DH6S_DISCOVER;
        state->RTC = 0;
        state->IMD = SOL_MAX_DELAY;
@@ -1616,11 +1621,15 @@
 {
        struct interface *ifp;
        struct dhcp6_state *state;
+       int llevel;
 
        ifp = arg;
        state = D6_STATE(ifp);
-       if (state->new == NULL || ifp->options->options & DHCPCD_DEBUG)
-               loginfox("%s: requesting DHCPv6 information", ifp->name);
+       if (state->new == NULL && !state->failed)
+               llevel = LOG_INFO;
+       else
+               llevel = LOG_DEBUG;
+       logmessage(llevel, "%s: requesting DHCPv6 information", ifp->name);
        state->state = DH6S_INFORM;
        state->RTC = 0;
        state->IMD = INF_MAX_DELAY;
@@ -1677,6 +1686,8 @@
 {
        struct dhcp6_state *state = D6_STATE(ifp);
 
+       state->failed = true;
+
        /* RFC3315 18.1.2 says that prior addresses SHOULD be used on failure.
         * RFC2131 3.2.3 says that MAY chose to use the prior address.
         * Because dhcpcd was written first for RFC2131, we have the LASTLEASE
@@ -1711,33 +1722,43 @@
        }
 }
 
+static int
+dhcp6_failloglevel(struct interface *ifp)
+{
+       const struct dhcp6_state *state = D6_CSTATE(ifp);
+
+       return state->failed ? LOG_DEBUG : LOG_ERR;
+}
+
 static void
 dhcp6_failconfirm(void *arg)
 {
-       struct interface *ifp;
-
-       ifp = arg;
-       logerrx("%s: failed to confirm prior address", ifp->name);
+       struct interface *ifp = arg;
+       int llevel = dhcp6_failloglevel(ifp);
+
+       logmessage(llevel, "%s: failed to confirm prior DHCPv6 address",
+           ifp->name);
        dhcp6_fail(ifp);
 }
 
 static void
 dhcp6_failrequest(void *arg)
 {
-       struct interface *ifp;
-
-       ifp = arg;
-       logerrx("%s: failed to request address", ifp->name);
+       struct interface *ifp = arg;
+       int llevel = dhcp6_failloglevel(ifp);
+
+       logmessage(llevel, "%s: failed to request DHCPv6 address", ifp->name);
        dhcp6_fail(ifp);
 }
 
 static void
 dhcp6_failinform(void *arg)
 {
-       struct interface *ifp;
-
-       ifp = arg;
-       logerrx("%s: failed to request information", ifp->name);
+       struct interface *ifp = arg;
+       int llevel = dhcp6_failloglevel(ifp);
+
+       logmessage(llevel, "%s: failed to request DHCPv6 information",
+           ifp->name);
        dhcp6_fail(ifp);
 }
 
@@ -1745,10 +1766,9 @@
 static void
 dhcp6_failrebind(void *arg)
 {
-       struct interface *ifp;
-
-       ifp = arg;
-       logerrx("%s: failed to rebind prior delegation", ifp->name);
+       struct interface *ifp = arg;
+
+       logerrx("%s: failed to rebind prior DHCPv6 delegation", ifp->name);
        dhcp6_fail(ifp);
 }
 
@@ -3124,6 +3144,7 @@
                        state->state = DH6S_INFORMED;
                else
                        state->state = DH6S_BOUND;
+               state->failed = false;
 
                if (state->renew && state->renew != ND6_INFINITE_LIFETIME)
                        eloop_timeout_add_sec(ifp->ctx->eloop,
@@ -3621,11 +3642,14 @@
                .iov_base = buf,
                .iov_len = sizeof(buf),
        };
-       unsigned char ctl[CMSG_SPACE(sizeof(struct in6_pktinfo))] = { 0 };
+       union {
+               struct cmsghdr hdr;
+               uint8_t buf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
+       } cmsgbuf = { .buf = { 0 } };
        struct msghdr msg = {
            .msg_name = &from, .msg_namelen = sizeof(from),
            .msg_iov = &iov, .msg_iovlen = 1,
-           .msg_control = ctl, .msg_controllen = sizeof(ctl),
+           .msg_control = cmsgbuf.buf, .msg_controllen = sizeof(cmsgbuf.buf),
        };
        int s;
        ssize_t bytes;
@@ -3857,6 +3881,7 @@
 gogogo:
        state->state = init_state;
        state->lerror = 0;
+       state->failed = false;
        dhcp_set_leasefile(state->leasefile, sizeof(state->leasefile),
            AF_INET6, ifp);
        if (ipv6_linklocal(ifp) == NULL) {
diff -r 91e36d242e44 -r 56b81ca1da62 external/bsd/dhcpcd/dist/src/dhcp6.h
--- a/external/bsd/dhcpcd/dist/src/dhcp6.h      Mon Apr 13 15:42:20 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.h      Tue Apr 21 09:54:16 2020 +0000
@@ -211,7 +211,10 @@
        const char *reason;
        uint16_t lerror; /* Last error received from DHCPv6 reply. */
        bool has_no_binding;
+       bool failed; /* Entered the failed state - used to rate limit log. */
+#ifdef AUTH
        struct authstate auth;
+#endif
 };
 
 #define D6_STATE(ifp)                                                         \
diff -r 91e36d242e44 -r 56b81ca1da62 external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c     Mon Apr 13 15:42:20 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c     Tue Apr 21 09:54:16 2020 +0000
@@ -2207,7 +2207,8 @@
                goto run_loop;
 #endif
 
-       if (control_start(&ctx,
+       if (!(ctx.options & DHCPCD_TEST) &&
+           control_start(&ctx,
            ctx.options & DHCPCD_MASTER ? NULL : argv[optind]) == -1)
        {
                logerr("%s: control_start", __func__);
@@ -2273,6 +2274,7 @@
                        loglevel = ctx.options & DHCPCD_INACTIVE ?
                            LOG_DEBUG : LOG_ERR;
                        logmessage(loglevel, "no valid interfaces found");
+                       dhcpcd_daemonise(&ctx);
                } else
                        goto exit_failure;
                if (!(ctx.options & DHCPCD_LINK)) {
diff -r 91e36d242e44 -r 56b81ca1da62 external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in     Mon Apr 13 15:42:20 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in     Tue Apr 21 09:54:16 2020 +0000
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd February 19, 2020
+.Dd April 19, 2020
 .Dt DHCPCD.CONF 5
 .Os
 .Sh NAME
@@ -442,7 +442,7 @@
 RDNSS option and a valid prefix or no DHCPv6 instruction.
 Set this option so to make
 .Nm dhcpcd
-always fork on an RA.
+always fork on a RA.
 .It Ic ipv6rs
 Enables IPv6 Router Advertisement solicitation.
 This is on by default, but is documented here in the case where it is disabled
@@ -626,11 +626,14 @@
 .It Ic ssid Ar ssid
 Subsequent options are only parsed for this wireless
 .Ar ssid .
-.It Ic slaac Op Ar hwaddr | Ar private
+.It Ic slaac Ar hwaddr | Ar private Op Ar temp | Ar temporary
 Selects the interface identifier used for SLAAC generated IPv6 addresses.
 If
 .Ar private
-is used, an RFC 7217 address is generated.
+is used, a RFC 7217 address is generated.
+The
+.Ar temporary
+directive will create a temporary address for the prefix as well.
 .It Ic static Ar value
 Configures a static
 .Ar value .
diff -r 91e36d242e44 -r 56b81ca1da62 external/bsd/dhcpcd/dist/src/if-bsd.c
--- a/external/bsd/dhcpcd/dist/src/if-bsd.c     Mon Apr 13 15:42:20 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/if-bsd.c     Tue Apr 21 09:54:16 2020 +0000
@@ -1015,28 +1015,21 @@
 int
 if_address6(unsigned char cmd, const struct ipv6_addr *ia)
 {
-       struct in6_aliasreq ifa;
+       struct in6_aliasreq ifa = { .ifra_flags = 0 };
        struct in6_addr mask;
        struct dhcpcd_ctx *ctx = ia->iface->ctx;
 
-       memset(&ifa, 0, sizeof(ifa));
        strlcpy(ifa.ifra_name, ia->iface->name, sizeof(ifa.ifra_name));
-       /*
-        * We should not set IN6_IFF_TENTATIVE as the kernel should be
-        * able to work out if it's a new address or not.
-        *
-        * We should set IN6_IFF_AUTOCONF, but the kernel won't let us.
-        * This is probably a safety measure, but still it's not entirely right
-        * either.
-        */
-#if 0
-       if (ia->autoconf)
-               ifa.ifra_flags |= IN6_IFF_AUTOCONF;



Home | Main Index | Thread Index | Old Index