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 Import dhcpcd-5.5.0 with the follow...



details:   https://anonhg.NetBSD.org/src/rev/b92840442246
branches:  trunk
changeset: 773028:b92840442246
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Jan 25 14:33:03 2012 +0000

description:
Import dhcpcd-5.5.0 with the following changes:

* Shell portability fixes, including proper printf usage.
* Detect a valid ntp.conf before adjusting it
* reboot timeout changed to 5 seconds
* When rebooting and not daemonized, reduce the discover timeout
  to allow for fallback or IPv4LL
* Respect each kernel carrier message
* Optimize some bitwise logic
* Don't remove interfaces for which commands have not been sent
* Store the assigned metric to each route so that we can change metrics on the fly
  dhcpcd -n --metric 100 iwi0
* Add SixRD support, RFC5969
* Fix SIP server support
* Only regen resolv.conf if it has changed
* Fix --reconfigure from spinning
* Add IPv6 Router Solicitation support we regards to RDNSS and DNSSL, RFC6016

diffstat:

 external/bsd/dhcpcd/dist/arp.c                       |    2 +
 external/bsd/dhcpcd/dist/common.c                    |   23 +-
 external/bsd/dhcpcd/dist/common.h                    |    6 +-
 external/bsd/dhcpcd/dist/configure.c                 |   31 +-
 external/bsd/dhcpcd/dist/defs.h                      |    2 +-
 external/bsd/dhcpcd/dist/dhcp.c                      |  108 ++-
 external/bsd/dhcpcd/dist/dhcp.h                      |    4 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf |   57 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf    |   16 +-
 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in       |    6 +-
 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in         |   10 +-
 external/bsd/dhcpcd/dist/dhcpcd.c                    |  195 +++--
 external/bsd/dhcpcd/dist/dhcpcd.conf.5.in            |    8 +-
 external/bsd/dhcpcd/dist/dhcpcd.h                    |   33 +-
 external/bsd/dhcpcd/dist/if-bsd.c                    |   19 +-
 external/bsd/dhcpcd/dist/if-options.c                |   11 +-
 external/bsd/dhcpcd/dist/if-options.h                |    5 +-
 external/bsd/dhcpcd/dist/ipv4ll.c                    |    4 +-
 external/bsd/dhcpcd/dist/ipv6rs.c                    |  705 +++++++++++++++++++
 external/bsd/dhcpcd/dist/ipv6rs.h                    |   37 +
 external/bsd/dhcpcd/dist/net.h                       |    1 +
 21 files changed, 1124 insertions(+), 159 deletions(-)

diffs (truncated from 2080 to 300 lines):

diff -r b22f640efdf3 -r b92840442246 external/bsd/dhcpcd/dist/arp.c
--- a/external/bsd/dhcpcd/dist/arp.c    Wed Jan 25 14:06:07 2012 +0000
+++ b/external/bsd/dhcpcd/dist/arp.c    Wed Jan 25 14:33:03 2012 +0000
@@ -204,6 +204,8 @@
        struct if_state *state = iface->state;
        struct timeval tv;
 
+       if (state->new == NULL)
+               return;
        if (iface->arp_fd == -1) {
                open_socket(iface, ETHERTYPE_ARP);
                add_event(iface->arp_fd, handle_arp_packet, iface);
diff -r b22f640efdf3 -r b92840442246 external/bsd/dhcpcd/dist/common.c
--- a/external/bsd/dhcpcd/dist/common.c Wed Jan 25 14:06:07 2012 +0000
+++ b/external/bsd/dhcpcd/dist/common.c Wed Jan 25 14:33:03 2012 +0000
@@ -1,6 +1,6 @@
 /* 
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2009 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2011 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -200,6 +200,27 @@
        return gettimeofday(tp, NULL);
 }
 
+ssize_t
+setvar(char ***e, const char *prefix, const char *var, const char *value)
+{
+       size_t len = strlen(prefix) + strlen(var) + strlen(value) + 4;
+
+       **e = xmalloc(len);
+       snprintf(**e, len, "%s_%s=%s", prefix, var, value);
+       (*e)++;
+       return len;
+}
+
+ssize_t
+setvard(char ***e, const char *prefix, const char *var, int value)
+{
+       char buffer[32];
+
+       snprintf(buffer, sizeof(buffer), "%d", value);
+       return setvar(e, prefix, var, buffer);
+}
+
+
 time_t
 uptime(void)
 {
diff -r b22f640efdf3 -r b92840442246 external/bsd/dhcpcd/dist/common.h
--- a/external/bsd/dhcpcd/dist/common.h Wed Jan 25 14:06:07 2012 +0000
+++ b/external/bsd/dhcpcd/dist/common.h Wed Jan 25 14:33:03 2012 +0000
@@ -1,6 +1,6 @@
 /* 
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2009 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2011 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -28,8 +28,8 @@
 #ifndef COMMON_H
 #define COMMON_H
 
+#include <sys/time.h>
 #include <stdio.h>
-#include <time.h>
 
 #include "config.h"
 #include "defs.h"
@@ -72,6 +72,8 @@
 char *get_line(FILE * __restrict);
 extern int clock_monotonic;
 int get_monotonic(struct timeval *);
+ssize_t setvar(char ***, const char *, const char *, const char *);
+ssize_t setvard(char ***, const char *, const char *, int);
 time_t uptime(void);
 int writepid(int, pid_t);
 void *xrealloc(void *, size_t);
diff -r b22f640efdf3 -r b92840442246 external/bsd/dhcpcd/dist/configure.c
--- a/external/bsd/dhcpcd/dist/configure.c      Wed Jan 25 14:06:07 2012 +0000
+++ b/external/bsd/dhcpcd/dist/configure.c      Wed Jan 25 14:33:03 2012 +0000
@@ -46,6 +46,7 @@
 #include "dhcp.h"
 #include "if-options.h"
 #include "if-pref.h"
+#include "ipv6rs.h"
 #include "net.h"
 #include "signals.h"
 
@@ -63,7 +64,6 @@
 
 static struct rt *routes;
 
-
 static int
 exec_script(char *const *argv, char *const *env)
 {
@@ -169,6 +169,14 @@
        ssize_t e, elen, l;
        const struct if_options *ifo = iface->state->options;
        const struct interface *ifp;
+       int dhcp, ra;
+
+       dhcp = 0;
+       ra = 0;
+       if (strcmp(iface->state->reason, "ROUTERADVERT") == 0)
+               ra = 1;
+       else
+               dhcp = 1;
 
        /* When dumping the lease, we only want to report interface and
           reason - the other interface variables are meaningless */
@@ -236,7 +244,7 @@
                        snprintf(env[elen++], e, "old_ssid=%s", iface->ssid);
                }
        }
-       if (iface->state->old) {
+       if (dhcp && iface->state->old) {
                e = configure_env(NULL, NULL, iface->state->old, ifo);
                if (e > 0) {
                        env = xrealloc(env, sizeof(char *) * (elen + e + 1));
@@ -248,7 +256,7 @@
        }
 
 dumplease:
-       if (iface->state->new) {
+       if (dhcp && iface->state->new) {
                e = configure_env(NULL, NULL, iface->state->new, ifo);
                if (e > 0) {
                        env = xrealloc(env, sizeof(char *) * (elen + e + 1));
@@ -258,6 +266,13 @@
                append_config(&env, &elen, "new",
                    (const char *const *)ifo->config);
        }
+       if (ra) {
+               e = ipv6rs_env(NULL, NULL, iface);
+               if (e > 0) {
+                       env = xrealloc(env, sizeof(char *) * (elen + e + 1));
+                       elen += ipv6rs_env(env + elen, "new", iface);
+               }
+       }
 
        /* Add our base environment */
        if (ifo->environ) {
@@ -471,10 +486,8 @@
        /* 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->iface->metric);
-       if (!add_route(iface, &nrt->dest, &nrt->net, &nrt->gate,
-               iface->metric))
+       del_route(ort->iface, &ort->dest, &ort->net, &ort->gate, ort->metric);
+       if (!add_route(iface, &nrt->dest, &nrt->net, &nrt->gate, nrt->metric))
                return 0;
        syslog(LOG_ERR, "%s: add_route: %m", iface->name);
        return -1;
@@ -661,6 +674,7 @@
                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;
                        /* Is this route already in our table? */
                        if ((find_route(nrs, rt, NULL, NULL)) != NULL)
                                continue;
@@ -669,7 +683,8 @@
                        if ((or = find_route(routes, rt, &rtl, NULL))) {
                                if (or->iface != ifp ||
                                    or->src.s_addr != ifp->addr.s_addr ||
-                                   rt->gate.s_addr != or->gate.s_addr)
+                                   rt->gate.s_addr != or->gate.s_addr ||
+                                   rt->metric != or->metric)
                                {
                                        if (c_route(or, rt, ifp) != 0)
                                                continue;
diff -r b22f640efdf3 -r b92840442246 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Wed Jan 25 14:06:07 2012 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Wed Jan 25 14:33:03 2012 +0000
@@ -28,7 +28,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "5.2.12"
+#define VERSION                        "5.5.0"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r b22f640efdf3 -r b92840442246 external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c   Wed Jan 25 14:06:07 2012 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c   Wed Jan 25 14:33:03 2012 +0000
@@ -1,6 +1,6 @@
 /* 
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2010 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2011 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -50,6 +50,7 @@
 #define RFC3361        (1 << 10)
 #define RFC3397        (1 << 11)
 #define RFC3442 (1 << 12)
+#define RFC5969 (1 << 13)
 
 #define IPV4R  IPV4 | REQUEST
 
@@ -159,6 +160,8 @@
        { 114,  STRING,         "default_url" },
        { 118,  IPV4,           "subnet_selection" },
        { 119,  STRING | RFC3397,       "domain_search" },
+       { 120,  STRING | RFC3361,       "sip_server" },
+       { 212,  RFC5969,        "sixrd" },
        { 0, 0, NULL }
 };
 
@@ -266,18 +269,17 @@
                        *type = opt->type;
 
                if (opt->type == 0 ||
-                   opt->type & STRING ||
-                   opt->type & RFC3442)
+                   opt->type & (STRING | RFC3442 | RFC5969))
                        return 0;
 
                sz = 0;
-               if (opt->type & UINT32 || opt->type & IPV4)
+               if (opt->type & (UINT32 | IPV4))
                        sz = sizeof(uint32_t);
                if (opt->type & UINT16)
                        sz = sizeof(uint16_t);
                if (opt->type & UINT8)
                        sz = sizeof(uint8_t);
-               if (opt->type & IPV4 || opt->type & ARRAY)
+               if (opt->type & (IPV4 | ARRAY))
                        return dl % sz;
                return (dl == sz ? 0 : -1);
        }
@@ -424,7 +426,7 @@
  * separated string. Returns length of string (including
  * terminating zero) or zero on error. out may be NULL
  * to just determine output length. */
-static ssize_t
+ssize_t
 decode_rfc3397(char *out, ssize_t len, int pl, const uint8_t *p)
 {
        const uint8_t *r, *q = p;
@@ -620,11 +622,11 @@
                addr.s_addr = INADDR_BROADCAST;
                l = ((dl / sizeof(addr.s_addr)) * ((4 * 4) + 1)) + 1;
                sip = p = xmalloc(l);
-               while (l != 0) {
+               while (dl != 0) {
                        memcpy(&addr.s_addr, data, sizeof(addr.s_addr));
                        data += sizeof(addr.s_addr);
                        p += snprintf(p, l - (p - sip), "%s ", inet_ntoa(addr));
-                       l -= sizeof(addr.s_addr);
+                       dl -= sizeof(addr.s_addr);
                }
                *--p = '\0';
                break;
@@ -636,6 +638,74 @@
        return sip;
 }
 
+/* Decode an RFC5969 6rd order option into a space
+ * separated string. Returns length of string (including
+ * terminating zero) or zero on error. */
+static ssize_t
+decode_rfc5969(char *out, ssize_t len, int pl, const uint8_t *p)
+{
+       uint8_t ipv4masklen, ipv6prefixlen;
+       uint8_t ipv6prefix[16];
+       uint8_t br[4];
+       int i;
+       ssize_t b, bytes = 0;
+
+       if (pl < 22) {
+               errno = EINVAL;
+               return 0;
+       }
+       
+       ipv4masklen = *p++;
+       pl--;
+       ipv6prefixlen = *p++;
+       pl--;
+       
+       for (i = 0; i < 16; i++) {
+               ipv6prefix[i] = *p++;
+               pl--;
+       }
+       if (out) {
+               b= snprintf(out, len,
+                   "%d %d "
+                   "%02x%02x:%02x%02x:"
+                   "%02x%02x:%02x%02x:"
+                   "%02x%02x:%02x%02x:"
+                   "%02x%02x:%02x%02x",



Home | Main Index | Thread Index | Old Index