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/bd3784ec7059
branches:  trunk
changeset: 931059:bd3784ec7059
user:      roy <roy%NetBSD.org@localhost>
date:      Tue Apr 21 09:55:33 2020 +0000

description:
Sync

diffstat:

 external/bsd/dhcpcd/dist/src/dhcp.c       |   12 ++-
 external/bsd/dhcpcd/dist/src/dhcp6.c      |   67 ++++++++++++-----
 external/bsd/dhcpcd/dist/src/dhcpcd.c     |    1 +
 external/bsd/dhcpcd/dist/src/if-bsd.c     |  110 +++--------------------------
 external/bsd/dhcpcd/dist/src/if-options.c |    8 ++
 external/bsd/dhcpcd/dist/src/ipv6.c       |   27 +++---
 external/bsd/dhcpcd/dist/src/ipv6nd.c     |   13 ++-
 7 files changed, 99 insertions(+), 139 deletions(-)

diffs (truncated from 525 to 300 lines):

diff -r 0d7673d88e82 -r bd3784ec7059 external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c       Tue Apr 21 09:54:16 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c       Tue Apr 21 09:55:33 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 0d7673d88e82 -r bd3784ec7059 external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c      Tue Apr 21 09:54:16 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c      Tue Apr 21 09:55:33 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 0d7673d88e82 -r bd3784ec7059 external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c     Tue Apr 21 09:54:16 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c     Tue Apr 21 09:55:33 2020 +0000
@@ -2274,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 0d7673d88e82 -r bd3784ec7059 external/bsd/dhcpcd/dist/src/if-bsd.c
--- a/external/bsd/dhcpcd/dist/src/if-bsd.c     Tue Apr 21 09:54:16 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/if-bsd.c     Tue Apr 21 09:55:33 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;
-#endif
 #if defined(__FreeBSD__) || defined(__DragonFly__)
+       /* This is a bug - the kernel should work this out. */
        if (ia->addr_flags & IN6_IFF_TENTATIVE)
                ifa.ifra_flags |= IN6_IFF_TENTATIVE;
 #endif
+// #if (defined(__NetBSD__) && __NetBSD_Version__ >= 999005700) ||
+#if    (defined(__OpenBSD__) && OpenBSD >= 201605)
+       if (ia->flags & IPV6_AF_AUTOCONF)
+               ifa.ifra_flags |= IN6_IFF_AUTOCONF;
+#endif
 #ifdef IPV6_MANAGETEMPADDR
        if (ia->flags & IPV6_AF_TEMPORARY)
                ifa.ifra_flags |= IN6_IFF_TEMPORARY;
@@ -1626,7 +1619,6 @@
 
 #ifdef INET6
 #if (defined(IPV6CTL_ACCEPT_RTADV) && !defined(ND6_IFF_ACCEPT_RTADV)) || \
-    defined(IPV6CTL_USETEMPADDR) || defined(IPV6CTL_TEMPVLTIME) || \
     defined(IPV6CTL_FORWARDING)
 #define get_inet6_sysctl(code) inet6_sysctl(code, 0, 0)
 #define set_inet6_sysctl(code, val) inet6_sysctl(code, val, 1)
@@ -1687,8 +1679,7 @@
 #endif
 }
 
-#ifdef IPV6_MANAGETEMPADDR
-#if !defined(IPV6CTL_TEMPVLTIME) && !defined(__OpenBSD__)
+#ifndef IPV6CTL_FORWARDING
 #define get_inet6_sysctlbyname(code) inet6_sysctlbyname(code, 0, 0)
 #define set_inet6_sysctlbyname(code, val) inet6_sysctlbyname(code, val, 1)
 static int
@@ -1708,81 +1699,6 @@
 }
 #endif
 
-#ifdef __OpenBSD__
-int
-ip6_use_tempaddr(const char *ifname)
-{
-       int s, r;
-       struct ifreq ifr;
-
-       s = socket(PF_INET6, SOCK_DGRAM, 0); /* XXX Not efficient */
-       if (s == -1)
-               return -1;
-       strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-       r = ioctl(s, SIOCGIFXFLAGS, &ifr);
-       close(s);
-       if (r == -1)
-               return -1;
-       return ifr.ifr_flags & IFXF_INET6_NOPRIVACY ? 0 : 1;
-}
-
-int
-ip6_temp_preferred_lifetime(__unused const char *ifname)
-{
-
-       return TEMP_PREFERRED_LIFETIME;
-}
-
-int
-ip6_temp_valid_lifetime(__unused const char *ifname)
-{
-
-       return TEMP_VALID_LIFETIME;
-}
-
-#else /* __OpenBSD__ */
-
-int
-ip6_use_tempaddr(__unused const char *ifname)
-{
-       int val;



Home | Main Index | Thread Index | Old Index