Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src/external/bsd/dhcpcd Apply patch (requested by roy in tick...



details:   https://anonhg.NetBSD.org/src/rev/4e2ecc494069
branches:  netbsd-6
changeset: 775355:4e2ecc494069
user:      riz <riz%NetBSD.org@localhost>
date:      Wed Oct 17 21:48:27 2012 +0000

description:
Apply patch (requested by roy in ticket #585):

Update dhcpcd to version 5.6.2.

diffstat:

 external/bsd/dhcpcd/dist/bind.c                      |    1 +
 external/bsd/dhcpcd/dist/common.h                    |    5 +
 external/bsd/dhcpcd/dist/configure.c                 |   81 +-
 external/bsd/dhcpcd/dist/defs.h                      |    2 +-
 external/bsd/dhcpcd/dist/dhcp.c                      |   24 +-
 external/bsd/dhcpcd/dist/dhcp.h                      |    5 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/01-test        |    2 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/10-mtu         |   15 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf |   16 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname    |   25 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf    |    8 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ypbind      |    8 +-
 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in       |    9 +-
 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in         |   18 +-
 external/bsd/dhcpcd/dist/dhcpcd.8.in                 |  320 ++++++-----
 external/bsd/dhcpcd/dist/dhcpcd.c                    |  117 ++-
 external/bsd/dhcpcd/dist/dhcpcd.conf.5.in            |   36 +-
 external/bsd/dhcpcd/dist/dhcpcd.h                    |   30 +-
 external/bsd/dhcpcd/dist/if-bsd.c                    |  209 ++++++-
 external/bsd/dhcpcd/dist/if-options.c                |   39 +-
 external/bsd/dhcpcd/dist/if-options.h                |   71 +-
 external/bsd/dhcpcd/dist/ipv6.c                      |  455 +++++++++++++++++
 external/bsd/dhcpcd/dist/ipv6.h                      |   76 ++
 external/bsd/dhcpcd/dist/ipv6ns.c                    |  360 +++++++++++++
 external/bsd/dhcpcd/dist/ipv6ns.h                    |   42 +
 external/bsd/dhcpcd/dist/ipv6rs.c                    |  501 ++++++++++++------
 external/bsd/dhcpcd/dist/ipv6rs.h                    |   46 +-
 external/bsd/dhcpcd/dist/net.c                       |  103 +--
 external/bsd/dhcpcd/dist/net.h                       |   38 +-
 external/bsd/dhcpcd/dist/platform-bsd.c              |   51 +-
 external/bsd/dhcpcd/dist/platform.h                  |    4 +-
 external/bsd/dhcpcd/sbin/dhcpcd/Makefile             |   18 +-
 32 files changed, 2106 insertions(+), 629 deletions(-)

diffs (truncated from 4338 to 300 lines):

diff -r dee4f7bc6e75 -r 4e2ecc494069 external/bsd/dhcpcd/dist/bind.c
--- a/external/bsd/dhcpcd/dist/bind.c   Wed Oct 17 21:39:17 2012 +0000
+++ b/external/bsd/dhcpcd/dist/bind.c   Wed Oct 17 21:48:27 2012 +0000
@@ -109,6 +109,7 @@
                writepid(pidfd, pid);
                close(pidfd);
                pidfd = -1;
+               options |= DHCPCD_FORKED;
                exit(EXIT_SUCCESS);
        }
        options |= DHCPCD_DAEMONISED;
diff -r dee4f7bc6e75 -r 4e2ecc494069 external/bsd/dhcpcd/dist/common.h
--- a/external/bsd/dhcpcd/dist/common.h Wed Oct 17 21:39:17 2012 +0000
+++ b/external/bsd/dhcpcd/dist/common.h Wed Oct 17 21:48:27 2012 +0000
@@ -37,6 +37,11 @@
 #define UNCONST(a)             ((void *)(unsigned long)(const void *)(a))
 
 #define timeval_to_double(tv) ((tv)->tv_sec * 1.0 + (tv)->tv_usec * 1.0e-6)
+#define ms_to_tv(tv, ms)                                               \
+       do {                                                            \
+               (tv)->tv_sec = (ms / 1000);                             \
+               (tv)->tv_usec = ((ms % 1000) * 1000);                   \
+       } while (0 /* CONSTCOND */);
 #define timernorm(tvp)                                                 \
        do {                                                            \
                while ((tvp)->tv_usec >= 1000000) {                     \
diff -r dee4f7bc6e75 -r 4e2ecc494069 external/bsd/dhcpcd/dist/configure.c
--- a/external/bsd/dhcpcd/dist/configure.c      Wed Oct 17 21:39:17 2012 +0000
+++ b/external/bsd/dhcpcd/dist/configure.c      Wed Oct 17 21:48:27 2012 +0000
@@ -52,16 +52,6 @@
 
 #define DEFAULT_PATH   "PATH=/usr/bin:/usr/sbin:/bin:/sbin"
 
-/* Some systems have route metrics */
-#ifndef HAVE_ROUTE_METRIC
-# ifdef __linux__
-#  define HAVE_ROUTE_METRIC 1
-# endif
-# ifndef HAVE_ROUTE_METRIC
-#  define HAVE_ROUTE_METRIC 0
-# endif
-#endif
-
 static struct rt *routes;
 
 static int
@@ -172,7 +162,12 @@
        int dhcp, ra;
 
        dhcp = ra = 0;
-       if (strcmp(reason, "ROUTERADVERT") == 0)
+       if (strcmp(reason, "TEST") == 0) {
+               if (ipv6rs_has_ra(iface))
+                       ra = 1;
+               else
+                       dhcp = 1;
+       } else if (strcmp(reason, "ROUTERADVERT") == 0)
                ra = 1;
        else
                dhcp = 1;
@@ -221,7 +216,10 @@
                e--;
        }
        *--p = '\0';
-       if ((dhcp && iface->state->new) || (ra && iface->ras)) {
+       if (strcmp(reason, "TEST") == 0) {
+               env[8] = strdup("if_up=false");
+               env[9] = strdup("if_down=false");
+       } else if ((dhcp && iface->state->new) || (ra && ipv6rs_has_ra(iface))){
                env[8] = strdup("if_up=true");
                env[9] = strdup("if_down=false");
        } else {
@@ -307,7 +305,6 @@
        struct iovec iov[2];
        int retval;
 
-       retval = 0;
        make_env(iface, reason, &env);
        elen = arraytostr((const char *const *)env, &s);
        iov[0].iov_base = &elen;
@@ -329,7 +326,7 @@
        int retval = 0;
        if (send_interface1(fd, iface, iface->state->reason) == -1)
                retval = -1;
-       if (iface->ras) {
+       if (ipv6rs_has_ra(iface)) {
                if (send_interface1(fd, iface, "ROUTERADVERT") == -1)
                        retval = -1;
        }
@@ -435,9 +432,10 @@
 }
 
 static void
-desc_route(const char *cmd, const struct rt *rt, const char *ifname)
+desc_route(const char *cmd, const struct rt *rt)
 {
        char addr[sizeof("000.000.000.000") + 1];
+       const char *ifname = rt->iface->name;
 
        strlcpy(addr, inet_ntoa(rt->dest), sizeof(addr));
        if (rt->gate.s_addr == INADDR_ANY)
@@ -465,7 +463,7 @@
        f = find_route(routes, rt, &l, NULL);
        if (f == NULL)
                return 0;
-       desc_route("removing", f, f->iface->name);
+       desc_route("removing", f);
        if (l)
                l->next = f->next;
        else
@@ -475,59 +473,60 @@
 }
 
 static int
-n_route(struct rt *rt, const struct interface *iface)
+n_route(struct rt *rt)
 {
        /* Don't set default routes if not asked to */
        if (rt->dest.s_addr == 0 &&
            rt->net.s_addr == 0 &&
-           !(iface->state->options->options & DHCPCD_GATEWAY))
+           !(rt->iface->state->options->options & DHCPCD_GATEWAY))
                return -1;
 
-       desc_route("adding", rt, iface->name);
-       if (!add_route(iface, &rt->dest, &rt->net, &rt->gate, iface->metric))
+       desc_route("adding", rt);
+       if (!add_route(rt))
                return 0;
        if (errno == EEXIST) {
                /* Pretend we added the subnet route */
-               if (rt->dest.s_addr == (iface->addr.s_addr & iface->net.s_addr) &&
-                   rt->net.s_addr == iface->net.s_addr &&
+               if (rt->dest.s_addr ==
+                   (rt->iface->addr.s_addr & rt->iface->net.s_addr) &&
+                   rt->net.s_addr == rt->iface->net.s_addr &&
                    rt->gate.s_addr == 0)
                        return 0;
                else
                        return -1;
        }
-       syslog(LOG_ERR, "%s: add_route: %m", iface->name);
+       syslog(LOG_ERR, "%s: add_route: %m", rt->iface->name);
        return -1;
 }
 
 static int
-c_route(struct rt *ort, struct rt *nrt, const struct interface *iface)
+c_route(struct rt *ort, struct rt *nrt)
 {
        /* Don't set default routes if not asked to */
        if (nrt->dest.s_addr == 0 &&
            nrt->net.s_addr == 0 &&
-           !(iface->state->options->options & DHCPCD_GATEWAY))
+           !(nrt->iface->state->options->options & DHCPCD_GATEWAY))
                return -1;
 
-       desc_route("changing", nrt, iface->name);
+       desc_route("changing", nrt);
        /* We delete and add the route so that we can change metric.
         * This also has the nice side effect of flushing ARP entries so
         * we don't have to do that manually. */
-       del_route(ort->iface, &ort->dest, &ort->net, &ort->gate, ort->metric);
-       if (!add_route(iface, &nrt->dest, &nrt->net, &nrt->gate, nrt->metric))
+       del_route(ort);
+       if (!add_route(nrt))
                return 0;
-       syslog(LOG_ERR, "%s: add_route: %m", iface->name);
+       syslog(LOG_ERR, "%s: add_route: %m", nrt->iface->name);
        return -1;
 }
 
 static int
-d_route(struct rt *rt, const struct interface *iface, int metric)
+d_route(struct rt *rt)
 {
        int retval;
 
-       desc_route("deleting", rt, iface->name);
-       retval = del_route(iface, &rt->dest, &rt->net, &rt->gate, metric);
+       desc_route("deleting", rt);
+       retval = del_route(rt);
        if (retval != 0 && errno != ENOENT && errno != ESRCH)
-               syslog(LOG_ERR,"%s: del_route: %m", iface->name);
+               syslog(LOG_ERR,"%s: del_route: %m", rt->iface->name);
        return retval;
 }
 
@@ -696,8 +695,10 @@
                dnr = get_routes(ifp);
                dnr = massage_host_routes(dnr, ifp);
                dnr = add_subnet_route(dnr, ifp);
-               dnr = add_router_host_route(dnr, ifp);
-               dnr = add_destination_route(dnr, ifp);
+               if (ifp->state->options->options & DHCPCD_GATEWAY) {
+                       dnr = add_router_host_route(dnr, ifp);
+                       dnr = add_destination_route(dnr, ifp);
+               }
                for (rt = dnr; rt && (rtn = rt->next, 1); lrt = rt, rt = rtn) {
                        rt->iface = ifp;
                        rt->metric = ifp->metric;
@@ -712,7 +713,7 @@
                                    rt->gate.s_addr != or->gate.s_addr ||
                                    rt->metric != or->metric)
                                {
-                                       if (c_route(or, rt, ifp) != 0)
+                                       if (c_route(or, rt) != 0)
                                                continue;
                                }
                                if (rtl != NULL)
@@ -721,7 +722,7 @@
                                        routes = or->next;
                                free(or);
                        } else {
-                               if (n_route(rt, ifp) != 0)
+                               if (n_route(rt) != 0)
                                        continue;
                        }
                        if (dnr == rt)
@@ -730,6 +731,7 @@
                                lrt->next = rtn;
                        rt->next = nrs;
                        nrs = rt;
+                       rt = lrt; /* When we loop this makes lrt correct */
                }
                free_routes(dnr);
        }
@@ -737,7 +739,7 @@
        /* Remove old routes we used to manage */
        for (rt = routes; rt; rt = rt->next) {
                if (find_route(nrs, rt, NULL, NULL) == NULL)
-                       d_route(rt, rt->iface, rt->iface->metric);
+                       d_route(rt);
        }
 
        free_routes(routes);
@@ -817,8 +819,9 @@
        rt = get_subnet_route(dhcp);
        if (rt != NULL) {
                rt->iface = iface;
+               rt->metric = 0;
                if (!find_route(routes, rt, NULL, NULL))
-                       del_route(iface, &rt->dest, &rt->net, &rt->gate, 0);
+                       del_route(rt);
                free(rt);
        }
 
diff -r dee4f7bc6e75 -r 4e2ecc494069 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Wed Oct 17 21:39:17 2012 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Wed Oct 17 21:48:27 2012 +0000
@@ -28,7 +28,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "5.5.4"
+#define VERSION                        "5.6.2"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r dee4f7bc6e75 -r 4e2ecc494069 external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c   Wed Oct 17 21:39:17 2012 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c   Wed Oct 17 21:48:27 2012 +0000
@@ -272,6 +272,9 @@
                    opt->type & (STRING | RFC3442 | RFC5969))
                        return 0;
 
+               if (opt->type & IPV4 && opt->type & ARRAY)
+                       return (dl % sizeof(uint32_t) == 0 ? 0 : -1);
+
                sz = 0;
                if (opt->type & (UINT32 | IPV4))
                        sz = sizeof(uint32_t);
@@ -279,9 +282,8 @@
                        sz = sizeof(uint16_t);
                if (opt->type & UINT8)
                        sz = sizeof(uint8_t);
-               if (opt->type & (IPV4 | ARRAY))
-                       return dl % sz;
-               return (dl == sz ? 0 : -1);
+               /* If we don't know the size, assume it's valid */
+               return (sz == 0 || dl == sz ? 0 : -1);
        }
 
        /* unknown option, so let it pass */
@@ -772,7 +774,7 @@
  * Otherwise we add static routes and then routers. */
 struct rt *
 get_option_routes(const struct dhcp_message *dhcp,
-    const char *ifname, int *opts)
+    const char *ifname, unsigned long long *opts)
 {
        const uint8_t *p;
        const uint8_t *e;
@@ -787,11 +789,13 @@
                p = get_option(dhcp, DHO_MSCSR, &len, NULL);
        if (p) {
                routes = decode_rfc3442_rt(len, p);
-               if (routes && !(*opts & DHCPCD_CSR_WARNED)) {
-                       syslog(LOG_DEBUG,
-                           "%s: using Classless Static Routes (RFC3442)",



Home | Main Index | Thread Index | Old Index