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 Import dhcpcd-7.1.1 with the fo...



details:   https://anonhg.NetBSD.org/src/rev/7c5eedd187e8
branches:  trunk
changeset: 448715:7c5eedd187e8
user:      roy <roy%NetBSD.org@localhost>
date:      Thu Feb 07 21:34:30 2019 +0000

description:
Import dhcpcd-7.1.1 with the following changes:

* IPv4LL: Fixed build with this disabled
* IPv4LL: Remember last address between carrier resets
* BSD: Fixed initial link infos reported as LINK_STATE_UNKNOWN

diffstat:

 external/bsd/dhcpcd/dist/src/arp.c    |   4 ++--
 external/bsd/dhcpcd/dist/src/arp.h    |   4 ++--
 external/bsd/dhcpcd/dist/src/common.h |   8 ++++++++
 external/bsd/dhcpcd/dist/src/defs.h   |   2 +-
 external/bsd/dhcpcd/dist/src/dhcp.h   |  15 +++------------
 external/bsd/dhcpcd/dist/src/dhcp6.h  |  21 ++++-----------------
 external/bsd/dhcpcd/dist/src/dhcpcd.h |  14 +++++++++-----
 external/bsd/dhcpcd/dist/src/if.c     |  26 ++++++++++++++++++++++----
 external/bsd/dhcpcd/dist/src/ipv4.c   |  13 +++++++++----
 external/bsd/dhcpcd/dist/src/ipv4.h   |   9 ++-------
 external/bsd/dhcpcd/dist/src/ipv4ll.h |   6 ------
 external/bsd/dhcpcd/dist/src/ipv6.c   |  18 ++++++++++++++++--
 external/bsd/dhcpcd/dist/src/ipv6.h   |  16 +++-------------
 external/bsd/dhcpcd/dist/src/ipv6nd.h |  13 ++++---------
 external/bsd/dhcpcd/dist/src/script.c |  19 +++++++++++++++----
 15 files changed, 100 insertions(+), 88 deletions(-)

diffs (truncated from 636 to 300 lines):

diff -r 3972fd266847 -r 7c5eedd187e8 external/bsd/dhcpcd/dist/src/arp.c
--- a/external/bsd/dhcpcd/dist/src/arp.c        Thu Feb 07 21:16:35 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.c        Thu Feb 07 21:34:30 2019 +0000
@@ -400,7 +400,7 @@
 }
 
 void
-arp_announceaddr(struct dhcpcd_ctx *ctx, struct in_addr *ia)
+arp_announceaddr(struct dhcpcd_ctx *ctx, const struct in_addr *ia)
 {
        struct interface *ifp;
        struct ipv4_addr *iaf;
@@ -424,7 +424,7 @@
 }
 
 void
-arp_ifannounceaddr(struct interface *ifp, struct in_addr *ia)
+arp_ifannounceaddr(struct interface *ifp, const struct in_addr *ia)
 {
        struct arp_state *astate;
 
diff -r 3972fd266847 -r 7c5eedd187e8 external/bsd/dhcpcd/dist/src/arp.h
--- a/external/bsd/dhcpcd/dist/src/arp.h        Thu Feb 07 21:16:35 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.h        Thu Feb 07 21:34:30 2019 +0000
@@ -95,8 +95,8 @@
 struct arp_state *arp_new(struct interface *, const struct in_addr *);
 struct arp_state *arp_find(struct interface *, const struct in_addr *);
 void arp_announce(struct arp_state *);
-void arp_announceaddr(struct dhcpcd_ctx *, struct in_addr *);
-void arp_ifannounceaddr(struct interface *, struct in_addr *);
+void arp_announceaddr(struct dhcpcd_ctx *, const struct in_addr *);
+void arp_ifannounceaddr(struct interface *, const struct in_addr *);
 void arp_cancel(struct arp_state *);
 void arp_free(struct arp_state *);
 void arp_free_but(struct arp_state *);
diff -r 3972fd266847 -r 7c5eedd187e8 external/bsd/dhcpcd/dist/src/common.h
--- a/external/bsd/dhcpcd/dist/src/common.h     Thu Feb 07 21:16:35 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/common.h     Thu Feb 07 21:34:30 2019 +0000
@@ -130,6 +130,14 @@
 # endif
 #endif
 
+#ifndef __fallthrough
+# if __GNUC__ >= 7
+#  define __fallthrough __attribute__((fallthrough))
+# else
+#  define __fallthrough
+# endif
+#endif
+
 /*
  * Compile Time Assertion.
  */
diff -r 3972fd266847 -r 7c5eedd187e8 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Thu Feb 07 21:16:35 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h       Thu Feb 07 21:34:30 2019 +0000
@@ -28,7 +28,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "7.1.0"
+#define VERSION                        "7.1.1"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r 3972fd266847 -r 7c5eedd187e8 external/bsd/dhcpcd/dist/src/dhcp.h
--- a/external/bsd/dhcpcd/dist/src/dhcp.h       Thu Feb 07 21:16:35 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.h       Thu Feb 07 21:34:30 2019 +0000
@@ -228,6 +228,7 @@
 #endif
 };
 
+#ifdef INET
 #define D_STATE(ifp)                                                          \
        ((struct dhcp_state *)(ifp)->if_data[IF_DATA_DHCP])
 #define D_CSTATE(ifp)                                                         \
@@ -243,7 +244,6 @@
 #include "dhcpcd.h"
 #include "if-options.h"
 
-#ifdef INET
 char *decode_rfc3361(const uint8_t *, size_t);
 ssize_t decode_rfc3442(char *, size_t, const uint8_t *p, size_t);
 
@@ -266,15 +266,6 @@
 void dhcp_close(struct interface *);
 void dhcp_free(struct interface *);
 int dhcp_dump(struct interface *);
-#else
-#define dhcp_start(a) {}
-#define dhcp_abort(a) {}
-#define dhcp_renew(a) {}
-#define dhcp_reboot(a, b) (b = b)
-#define dhcp_reboot_newopts(a, b) (b = b)
-#define dhcp_close(a) {}
-#define dhcp_free(a) {}
-#define dhcp_dump(a) (-1)
-#endif
+#endif /* INET */
 
-#endif
+#endif /* DHCP_H */
diff -r 3972fd266847 -r 7c5eedd187e8 external/bsd/dhcpcd/dist/src/dhcp6.h
--- a/external/bsd/dhcpcd/dist/src/dhcp6.h      Thu Feb 07 21:16:35 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.h      Thu Feb 07 21:34:30 2019 +0000
@@ -55,6 +55,8 @@
 #define DHCP6_RECONFIGURE_REQ  18
 #define DHCP6_RECONFIGURE_REPLY        19
 
+#ifdef DHCP6
+
 #define D6_OPTION_CLIENTID             1
 #define D6_OPTION_SERVERID             2
 #define D6_OPTION_IA_NA                        3
@@ -216,7 +218,6 @@
        (D6_CSTATE((ifp)) &&                                                   \
        D6_CSTATE((ifp))->reason && dhcp6_dadcompleted((ifp)))
 
-#ifdef DHCP6
 void dhcp6_printoptions(const struct dhcpcd_ctx *,
     const struct dhcp_opt *, size_t);
 const struct ipv6_addr *dhcp6_iffindaddr(const struct interface *ifp,
@@ -236,20 +237,6 @@
 void dhcp6_drop(struct interface *, const char *);
 void dhcp6_dropnondelegates(struct interface *ifp);
 int dhcp6_dump(struct interface *);
-#else
-#define dhcp6_printoptions(a, b, c) {}
-#define dhcp6_iffindaddr(a, b, c) (NULL)
-#define dhcp6_findaddr(a, b, c) (NULL)
-#define dhcp6_find_delegates(a) {}
-#define dhcp6_start(a, b) (0)
-#define dhcp6_reboot(a) {}
-#define dhcp6_renew(a) {}
-#define dhcp6_env(a, b, c, d, e) (0)
-#define dhcp6_free(a) {}
-#define dhcp6_dadcompleted(a) (0)
-#define dhcp6_drop(a, b) {}
-#define dhcp6_dropnondelegates(a) {}
-#define dhcp6_dump(a) (-1)
-#endif
+#endif /* DHCP6 */
 
-#endif
+#endif /* DHCP6_H */
diff -r 3972fd266847 -r 7c5eedd187e8 external/bsd/dhcpcd/dist/src/dhcpcd.h
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.h     Thu Feb 07 21:16:35 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.h     Thu Feb 07 21:34:30 2019 +0000
@@ -49,9 +49,10 @@
 #define IF_ACTIVE      1
 #define IF_ACTIVE_USER 2
 
-#define LINK_UP                1
-#define LINK_UNKNOWN   0
-#define LINK_DOWN      -1
+#define        LINK_UP         1
+#define        LINK_UNKNOWN    0
+#define        LINK_DOWN       -1
+#define        LINK_DOWN_IFFUP -2
 
 #define IF_DATA_IPV4   0
 #define IF_DATA_ARP    1
@@ -84,8 +85,9 @@
        unsigned short vlanid;
        unsigned int metric;
        int carrier;
-       int wireless;
-       uint8_t ssid[IF_SSIDLEN + 1]; /* NULL terminated */
+       bool media_valid;
+       bool wireless;
+       uint8_t ssid[IF_SSIDLEN];
        unsigned int ssid_len;
 
        char profile[PROFILE_LEN];
@@ -198,8 +200,10 @@
 
        struct dhcp_opt *nd_opts;
        size_t nd_opts_len;
+#ifdef DHCP6
        struct dhcp_opt *dhcp6_opts;
        size_t dhcp6_opts_len;
+#endif
 
 #ifndef __linux__
        int ra_global;
diff -r 3972fd266847 -r 7c5eedd187e8 external/bsd/dhcpcd/dist/src/if.c
--- a/external/bsd/dhcpcd/dist/src/if.c Thu Feb 07 21:16:35 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/if.c Thu Feb 07 21:34:30 2019 +0000
@@ -78,12 +78,20 @@
 
        if (ifp == NULL)
                return;
+#ifdef IPV4LL
        ipv4ll_free(ifp);
+#endif
+#ifdef INET
        dhcp_free(ifp);
        ipv4_free(ifp);
+#endif
+#ifdef DHCP6
        dhcp6_free(ifp);
+#endif
+#ifdef INET6
        ipv6nd_free(ifp);
        ipv6_free(ifp);
+#endif
        rt_freeif(ifp);
        free_options(ifp->ctx, ifp->options);
        free(ifp);
@@ -147,9 +155,13 @@
        strlcpy(ifmr.ifm_name, ifp->name, sizeof(ifmr.ifm_name));
        if (ioctl(ifp->ctx->pf_inet_fd, SIOCGIFMEDIA, &ifmr) != -1 &&
            ifmr.ifm_status & IFM_AVALID)
+       {
+               ifp->media_valid = true;
                r = (ifmr.ifm_status & IFM_ACTIVE) ? LINK_UP : LINK_DOWN;
-       else
+       } else {
+               ifp->media_valid = false;
                r = ifr.ifr_flags & IFF_RUNNING ? LINK_UP : LINK_UNKNOWN;
+       }
 #else
        r = ifr.ifr_flags & IFF_RUNNING ? LINK_UP : LINK_DOWN;
 #endif
@@ -462,7 +474,7 @@
                        case IFT_PPP: /* FALLTHROUGH */
 #endif
 #ifdef IFT_PROPVIRTUAL
-                       case IFT_PROPVIRTUAL: /* FALLTHROUGH */
+                       case IFT_PROPVIRTUAL:
 #endif
 #if defined(IFT_BRIDGE) || defined(IFT_PPP) || defined(IFT_PROPVIRTUAL)
                                /* Don't allow unless explicit */
@@ -476,6 +488,7 @@
                                            ifp->name);
                                        active = IF_INACTIVE;
                                }
+                               __fallthrough; /* Appease gcc-7 */
                                /* FALLTHROUGH */
 #endif
 #ifdef IFT_L2VLAN
@@ -584,7 +597,7 @@
                 * we can work them out. */
                ifp->metric = 200 + ifp->index;
                if (if_getssid(ifp) != -1) {
-                       ifp->wireless = 1;
+                       ifp->wireless = true;
                        ifp->metric += 100;
                }
 #endif
@@ -726,19 +739,24 @@
                return -1;
        if (si->carrier < ti->carrier)
                return 1;
-
+#ifdef INET
        if (D_STATE_RUNNING(si) && !D_STATE_RUNNING(ti))
                return -1;
        if (!D_STATE_RUNNING(si) && D_STATE_RUNNING(ti))
                return 1;
+#endif
+#ifdef INET6
        if (RS_STATE_RUNNING(si) && !RS_STATE_RUNNING(ti))
                return -1;
        if (!RS_STATE_RUNNING(si) && RS_STATE_RUNNING(ti))
                return 1;
+#endif
+#ifdef DHCP6
        if (D6_STATE_RUNNING(si) && !D6_STATE_RUNNING(ti))
                return -1;
        if (!D6_STATE_RUNNING(si) && D6_STATE_RUNNING(ti))
                return 1;
+#endif
 
 #ifdef INET
        /* Special attention needed here due to states and IPv4LL. */
diff -r 3972fd266847 -r 7c5eedd187e8 external/bsd/dhcpcd/dist/src/ipv4.c
--- a/external/bsd/dhcpcd/dist/src/ipv4.c       Thu Feb 07 21:16:35 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/ipv4.c       Thu Feb 07 21:34:30 2019 +0000
@@ -200,8 +200,10 @@
 {
        const struct dhcp_state *dstate;
 
+#ifdef IPV4LL
        if (IPV4LL_STATE_RUNNING(ifp))
                return 1;
+#endif
 
        dstate = D_CSTATE(ifp);
        return (dstate &&
@@ -425,20 +427,25 @@
 inet_getroutes(struct dhcpcd_ctx *ctx, struct rt_head *routes)
 {
        struct interface *ifp;
+#ifdef IPV4LL
        struct rt def;
        bool have_default;
+#endif
 
        TAILQ_FOREACH(ifp, ctx->ifaces, next) {



Home | Main Index | Thread Index | Old Index