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.6.1 with the follow...



details:   https://anonhg.NetBSD.org/src/rev/7f39a25f6e2f
branches:  trunk
changeset: 780124:7f39a25f6e2f
user:      roy <roy%NetBSD.org@localhost>
date:      Thu Jul 12 16:47:58 2012 +0000

description:
Import dhcpcd-5.6.1 with the following changes:

Improve IPv6 RA support by allowing dhcpcd to manage addreses and
routes instead of the kernel. dhcpcd will only do this if RA has been
disabled in the kernel or instructed to do so via the dhcpcd.conf(5)
ipv6ra_own and/or ipv6ra_owndefault directives.

Send and process IPv6 Neighbor Solicitions and Adverts to prove router
reachability. If a router cannot be reached in this way then it is
expired.

diffstat:

 external/bsd/dhcpcd/dist/bind.c               |    1 +
 external/bsd/dhcpcd/dist/configure.c          |   22 +-
 external/bsd/dhcpcd/dist/defs.h               |    2 +-
 external/bsd/dhcpcd/dist/dhcp.c               |   10 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/01-test |    2 +-
 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in  |    3 +
 external/bsd/dhcpcd/dist/dhcpcd.c             |   61 +-
 external/bsd/dhcpcd/dist/dhcpcd.conf.5.in     |   21 +-
 external/bsd/dhcpcd/dist/dhcpcd.h             |   31 +-
 external/bsd/dhcpcd/dist/if-bsd.c             |  171 ++++++++-
 external/bsd/dhcpcd/dist/if-options.c         |   33 +-
 external/bsd/dhcpcd/dist/if-options.h         |    6 +
 external/bsd/dhcpcd/dist/ipv6.c               |  443 ++++++++++++++++++++++++++
 external/bsd/dhcpcd/dist/ipv6.h               |   76 ++++
 external/bsd/dhcpcd/dist/ipv6ns.c             |  349 ++++++++++++++++++++
 external/bsd/dhcpcd/dist/ipv6ns.h             |   42 ++
 external/bsd/dhcpcd/dist/ipv6rs.c             |  390 +++++++++++++++-------
 external/bsd/dhcpcd/dist/ipv6rs.h             |   44 ++-
 external/bsd/dhcpcd/dist/net.c                |   95 +---
 external/bsd/dhcpcd/dist/net.h                |   23 +-
 external/bsd/dhcpcd/dist/platform-bsd.c       |   45 ++-
 21 files changed, 1559 insertions(+), 311 deletions(-)

diffs (truncated from 2684 to 300 lines):

diff -r 72f3f6013f8a -r 7f39a25f6e2f external/bsd/dhcpcd/dist/bind.c
--- a/external/bsd/dhcpcd/dist/bind.c   Thu Jul 12 16:46:48 2012 +0000
+++ b/external/bsd/dhcpcd/dist/bind.c   Thu Jul 12 16:47:58 2012 +0000
@@ -109,6 +109,7 @@
                writepid(pidfd, pid);
                close(pidfd);
                pidfd = -1;
+               options |= DHCPCD_FORKED;
                exit(EXIT_SUCCESS);
        }
        options |= DHCPCD_DAEMONISED;
diff -r 72f3f6013f8a -r 7f39a25f6e2f external/bsd/dhcpcd/dist/configure.c
--- a/external/bsd/dhcpcd/dist/configure.c      Thu Jul 12 16:46:48 2012 +0000
+++ b/external/bsd/dhcpcd/dist/configure.c      Thu Jul 12 16:47:58 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,7 @@
                e--;
        }
        *--p = '\0';
-       if ((dhcp && iface->state->new) || (ra && iface->ras)) {
+       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 +302,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 +323,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;
        }
diff -r 72f3f6013f8a -r 7f39a25f6e2f external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Thu Jul 12 16:46:48 2012 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Thu Jul 12 16:47:58 2012 +0000
@@ -28,7 +28,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "5.5.6"
+#define VERSION                        "5.6.1"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r 72f3f6013f8a -r 7f39a25f6e2f external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c   Thu Jul 12 16:46:48 2012 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c   Thu Jul 12 16:47:58 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 */
@@ -1361,7 +1363,6 @@
 configure_env(char **env, const char *prefix, const struct dhcp_message *dhcp,
     const struct if_options *ifo)
 {
-       unsigned int i;
        const uint8_t *p;
        int pl;
        struct in_addr addr;
@@ -1404,7 +1405,6 @@
                        net.s_addr = get_netmask(addr.s_addr);
                        setvar(&ep, prefix, "subnet_mask", inet_ntoa(net));
                }
-               i = inet_ntocidr(net);
                snprintf(cidr, sizeof(cidr), "%d", inet_ntocidr(net));
                setvar(&ep, prefix, "subnet_cidr", cidr);
                if (get_option_addr(&brd, dhcp, DHO_BROADCAST) == -1) {
diff -r 72f3f6013f8a -r 7f39a25f6e2f external/bsd/dhcpcd/dist/dhcpcd-hooks/01-test
--- a/external/bsd/dhcpcd/dist/dhcpcd-hooks/01-test     Thu Jul 12 16:46:48 2012 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-hooks/01-test     Thu Jul 12 16:47:58 2012 +0000
@@ -2,5 +2,5 @@
 
 if [ "$reason" = "TEST" ]; then
        set | grep "^\(interface\|metric\|pid\|reason\|skip_hooks\)=" | sort
-       set | grep "^\(new_\|old_\)" | sort
+       set | grep "^\(new_\|old_\|ra_count=\|ra[0-9]*_\)" | sort
 fi
diff -r 72f3f6013f8a -r 7f39a25f6e2f external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in
--- a/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in      Thu Jul 12 16:46:48 2012 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in      Thu Jul 12 16:47:58 2012 +0000
@@ -16,6 +16,9 @@
 signature_end="$signature_base_end $from $ifname"
 state_dir=/var/run/dhcpcd
 
+: ${if_up:=false}
+: ${if_down:=false}
+
 # Ensure that all arguments are unique
 uniqify()
 {
diff -r 72f3f6013f8a -r 7f39a25f6e2f external/bsd/dhcpcd/dist/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/dhcpcd.c Thu Jul 12 16:46:48 2012 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.c Thu Jul 12 16:47:58 2012 +0000
@@ -67,6 +67,8 @@
 #include "if-options.h"
 #include "if-pref.h"
 #include "ipv4ll.h"
+#include "ipv6.h"
+#include "ipv6ns.h"
 #include "ipv6rs.h"
 #include "net.h"
 #include "platform.h"
@@ -80,7 +82,6 @@
 #define RELEASE_DELAY_S                0
 #define RELEASE_DELAY_NS       10000000
 
-unsigned long long options = 0;
 int pidfd = -1;
 struct interface *ifaces = NULL;
 int ifac = 0;
@@ -95,7 +96,7 @@
 static int ifc;
 static char *cffile;
 static char *pidfile;
-static int linkfd = -1, ipv6rsfd = -1;
+static int linkfd = -1, ipv6rsfd = -1, ipv6nsfd = -1;
 
 struct dhcp_op {
        uint8_t value;
@@ -254,15 +255,8 @@
        struct interface *ifp, *ifl = NULL;
 
        syslog(LOG_INFO, "%s: removing interface", iface->name);
-       if (iface->ras) {
-               ipv6rs_free(iface);
-               iface->ras = NULL;
-               run_script_reason(iface, "ROUTERADVERT");
-       }
-       if (strcmp(iface->state->reason, "RELEASE") != 0)
-               drop_dhcp(iface, "STOP");
-       close_sockets(iface);
-       delete_timeout(NULL, iface);
+
+       // Remove the interface from our list
        for (ifp = ifaces; ifp; ifp = ifp->next) {
                if (ifp == iface)
                        break;
@@ -272,6 +266,12 @@
                ifl->next = ifp->next;
        else
                ifaces = ifp->next;
+
+       ipv6rs_drop(iface);
+       if (strcmp(iface->state->reason, "RELEASE") != 0)
+               drop_dhcp(iface, "STOP");
+       close_sockets(iface);
+       delete_timeout(NULL, iface);
        free_interface(ifp);
        if (!(options & (DHCPCD_MASTER | DHCPCD_TEST)))
                exit(EXIT_FAILURE);
@@ -822,7 +822,7 @@
                                        memset(iface->clientid + 2 + ifl,
                                            0, 4 - ifl);
                        } else {
-                               ifl = htonl(if_nametoindex(iface->name));
+                               ifl = htonl(iface->index);
                                memcpy(iface->clientid + 2, &ifl, 4);
                        }
                } else if (len == 0) {
@@ -922,11 +922,7 @@
                        syslog(LOG_INFO, "%s: carrier lost", iface->name);
                        close_sockets(iface);
                        delete_timeouts(iface, start_expire, NULL);
-                       if (iface->ras) {
-                               ipv6rs_free(iface);
-                               iface->ras = NULL;
-                               run_script_reason(iface, "ROUTERADVERT");
-                       }
+                       ipv6rs_drop(iface);
                        drop_dhcp(iface, "NOCARRIER");
                }
        } else if (carrier == 1 && !(~iface->flags & IFF_UP)) {
@@ -1499,12 +1495,12 @@
 static void
 handle_signal(_unused void *arg)
 {
-       struct interface *ifp, *ifl;
+       struct interface *ifp;
        struct if_options *ifo;
        int sig = signal_read();
-       int do_release, do_rebind, i;
+       int do_release, i;
 
-       do_rebind = do_release = 0;
+       do_release = 0;
        switch (sig) {
        case SIGINT:
                syslog(LOG_INFO, "received SIGINT, stopping");
@@ -1561,11 +1557,9 @@
        /* As drop_dhcp could re-arrange the order, we do it like this. */
        for (;;) {
                /* Be sane and drop the last config first */
-               ifl = NULL;
                for (ifp = ifaces; ifp; ifp = ifp->next) {
                        if (ifp->next == NULL)
                                break;
-                       ifl = ifp;
                }
                if (ifp == NULL)
                        break;
@@ -1582,7 +1576,7 @@
 handle_args(struct fd_list *fd, int argc, char **argv)
 {
        struct interface *ifp;
-       int do_exit = 0, do_release = 0, do_reboot = 0, do_reconf = 0;
+       int do_exit = 0, do_release = 0, do_reboot = 0;
        int opt, oi = 0;
        ssize_t len;
        size_t l;
@@ -1618,7 +1612,7 @@
                        if (argc == 1) {
                                for (ifp = ifaces; ifp; ifp = ifp->next) {
                                        len++;
-                                       if (ifp->ras)
+                                       if (ipv6rs_has_ra(ifp))
                                                len++;
                                }
                                len = write(fd->fd, &len, sizeof(len));
@@ -1633,7 +1627,7 @@
                                for (ifp = ifaces; ifp; ifp = ifp->next)
                                        if (strcmp(argv[opt], ifp->name) == 0) {
                                                len++;
-                                               if (ifp->ras)
+                                               if (ipv6rs_has_ra(ifp))
                                                        len++;
                                        }
                        }
@@ -1673,7 +1667,7 @@
        {
                switch (opt) {
                case 'g':
-                       do_reconf = 1;
+                       /* Assumed if below not set */
                        break;
                case 'k':
                        do_release = 1;
@@ -1916,7 +1910,7 @@
                        syslog(LOG_INFO, "sending signal %d to pid %d",
                            sig, pid);
                if (pid == 0 || kill(pid, sig) != 0) {
-                       if (sig != SIGALRM)
+                       if (sig != SIGALRM && errno != EPERM)
                                syslog(LOG_ERR, ""PACKAGE" not running");



Home | Main Index | Thread Index | Old Index