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



details:   https://anonhg.NetBSD.org/src/rev/5ac1c33a6b2c
branches:  trunk
changeset: 759061:5ac1c33a6b2c
user:      roy <roy%NetBSD.org@localhost>
date:      Sat Nov 27 11:24:09 2010 +0000

description:
Import dhcpcd-5.2.9 with the following changes:
* syntax in 50-ypbind hook has been fixed
* man page corrections
* report hwaddr used by dhcpcd when debug is enabled
* Fix detecting inet address for INFORM support
* document reason RELEASE in dhcpcd-run-hooks
* Support RTM_CHGADDR in the upcoming NetBSD-6
  This is used to work out if the hwaddr has changed as the interface
  does not go down/up unlike other OSes
* ntp hook no longer attempts to restart ntpd if 1st attempt failed

diffstat:

 external/bsd/dhcpcd/dist/common.c                 |   4 +-
 external/bsd/dhcpcd/dist/defs.h                   |   2 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf |   2 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ypbind   |   6 +-
 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in    |  11 ++--
 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in      |   6 +-
 external/bsd/dhcpcd/dist/dhcpcd.c                 |  56 ++++++++++++++++++++--
 external/bsd/dhcpcd/dist/dhcpcd.conf.5.in         |   2 +-
 external/bsd/dhcpcd/dist/dhcpcd.h                 |   1 +
 external/bsd/dhcpcd/dist/eloop.c                  |  10 ----
 external/bsd/dhcpcd/dist/eloop.h                  |  12 +++-
 external/bsd/dhcpcd/dist/if-bsd.c                 |  42 +++++++++++++---
 external/bsd/dhcpcd/dist/net.c                    |   8 ++-
 13 files changed, 118 insertions(+), 44 deletions(-)

diffs (truncated from 399 to 300 lines):

diff -r de963dcf59bc -r 5ac1c33a6b2c external/bsd/dhcpcd/dist/common.c
--- a/external/bsd/dhcpcd/dist/common.c Sat Nov 27 10:41:16 2010 +0000
+++ b/external/bsd/dhcpcd/dist/common.c Sat Nov 27 11:24:09 2010 +0000
@@ -26,7 +26,9 @@
  */
 
 /* Needed define to get at getline for glibc and FreeBSD */
-#define _GNU_SOURCE
+#ifndef _GNU_SOURCE
+#  define _GNU_SOURCE
+#endif
 
 #include <sys/cdefs.h>
 
diff -r de963dcf59bc -r 5ac1c33a6b2c external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Sat Nov 27 10:41:16 2010 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Sat Nov 27 11:24:09 2010 +0000
@@ -28,7 +28,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "5.2.8"
+#define VERSION                        "5.2.9"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r de963dcf59bc -r 5ac1c33a6b2c external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf
--- a/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf Sat Nov 27 10:41:16 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf Sat Nov 27 11:24:09 2010 +0000
@@ -8,7 +8,7 @@
 #   NTP_CONF=/usr/pkg/etc/ntpd.conf
 # to use openntpd from pkgsrc instead of the system provided ntp.
 
-: ${ntpd_restart_cmd:="service_condcommand ntpd restart || service_condcommand ntp restart"}
+: ${ntpd_restart_cmd:=service_condcommand ntpd restart}
 if type invoke-rc.d >/dev/null 2>&1; then
        # Debian has a seperate file for DHCP config to avoid stamping on
        # the master.
diff -r de963dcf59bc -r 5ac1c33a6b2c external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ypbind
--- a/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ypbind   Sat Nov 27 10:41:16 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ypbind   Sat Nov 27 11:24:09 2010 +0000
@@ -1,8 +1,8 @@
 # Sample dhcpcd hook for ypbind
 # This script is only suitable for the Linux version.
 
-: ${ypbind_restart_cmd:="service_command ypbind restart"}
-: ${ypbind_stop_cmd:="service_condcommand ypbind stop"}
+: ${ypbind_restart_cmd:=service_command ypbind restart}
+: ${ypbind_stop_cmd:=service_condcommand ypbind stop}
 ypbind_dir="$state_dir/ypbind"
 
 best_domain()
@@ -65,7 +65,7 @@
 
 if [ "$reason" = PREINIT ]; then
        rm -f "$ypbind_dir/$interface"
-else if $if_up || $if_down; then
+elif $if_up || $if_down; then
        if [ -n "$new_nis_domain" ]; then
                make_yp_binding
        elif [ -n "$old_nis_domain" ]; then
diff -r de963dcf59bc -r 5ac1c33a6b2c external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in
--- a/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in    Sat Nov 27 10:41:16 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in    Sat Nov 27 11:24:09 2010 +0000
@@ -27,7 +27,7 @@
 .Os
 .Sh NAME
 .Nm dhcpcd-run-hooks
-.Nd DHCP client configuration script 
+.Nd DHCP client configuration script
 .Sh DESCRIPTION
 .Nm
 is used by
@@ -35,7 +35,7 @@
 to run any system and user defined hook scripts.
 System hook scripts are found in
 .Pa @HOOKDIR@
-and the user defined hooks are 
+and the user defined hooks are
 .Pa @SYSCONFDIR@/dhcpcd.enter-hook .
 and
 .Pa @SYSCONFDIR@/dhcpcd.exit-hook .
@@ -97,6 +97,8 @@
 dhcpcd failed to contact any DHCP servers but was able to use an old lease.
 .It Dv EXPIRE
 dhcpcd's lease or state expired and it failed to obtain a new one.
+.It Dv RELEASE
+dhcpcd's lease was released back to the DHCP server for re-use.
 .It Dv NAK
 dhcpcd received a NAK from the DHCP server.
 This should be treated as EXPIRE.
@@ -110,16 +112,15 @@
 Static configuration and DHCP INFORM is still allowed.
 .It Dv STOP
 dhcpcd stopped running on the interface.
-.iT Dv DUMP
+.It Dv DUMP
 dhcpcd has been asked to dump the last lease for the interface.
 .It Dv TEST
 dhcpcd received an OFFER from a DHCP server but will not configure the
 interface.
 This is primarily used to test the variables are filled correctly for the
 script to process them.
-
 .El
-.Sh FILES 
+.Sh FILES
 When
 .Nm
 runs, it loads
diff -r de963dcf59bc -r 5ac1c33a6b2c external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in
--- a/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in      Sat Nov 27 10:41:16 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in      Sat Nov 27 11:24:09 2010 +0000
@@ -29,7 +29,7 @@
        echo "${result# *}"
 }
 
-# List interface config files in a dir
+# List interface config files in a directory.
 # If dhcpcd is running as a single instance then it will have a list of
 # interfaces in the preferred order.
 # Otherwise we just use what we have.
@@ -94,8 +94,8 @@
        fi
 }
 
-# Compare two files
-# If different, replace first with second otherwise remove second
+# Compare two files.
+# If different, replace first with second otherwise remove second.
 change_file()
 {
        if [ -e "$1" ]; then
diff -r de963dcf59bc -r 5ac1c33a6b2c external/bsd/dhcpcd/dist/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/dhcpcd.c Sat Nov 27 10:41:16 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.c Sat Nov 27 11:24:09 2010 +0000
@@ -809,17 +809,23 @@
        if (ifo->options & DHCPCD_CLIENTID)
                syslog(LOG_DEBUG, "%s: using ClientID %s", iface->name,
                    hwaddr_ntoa(iface->clientid + 1, *iface->clientid));
+       else
+               syslog(LOG_DEBUG, "%s: using hwaddr %s", iface->name,
+                   hwaddr_ntoa(iface->hwaddr, iface->hwlen));
 }
 
 int
 select_profile(struct interface *iface, const char *profile)
 {
        struct if_options *ifo;
+       int ret;
 
+       ret = 0;
        ifo = read_config(cffile, iface->name, iface->ssid, profile);
        if (ifo == NULL) {
                syslog(LOG_DEBUG, "%s: no profile %s", iface->name, profile);
-               return -1;
+               ret = -1;
+               goto exit;
        }
        if (profile != NULL) {
                strlcpy(iface->state->profile, profile,
@@ -830,8 +836,11 @@
                *iface->state->profile = '\0';
        free_options(iface->state->options);
        iface->state->options = ifo;
-       configure_interface1(iface);
-       return 0;
+
+exit:
+       if (profile)
+               configure_interface1(iface);
+       return ret;
 }
 
 static void
@@ -841,7 +850,6 @@
 
        iface = (struct interface *)arg;
        select_profile(iface, iface->state->options->fallback);
-       configure_interface1(iface);
        start_interface(iface);
 }
 
@@ -1273,6 +1281,43 @@
        }
 }
 
+#ifdef RTM_CHGADDR
+void
+handle_hwaddr(const char *ifname, unsigned char *hwaddr, size_t hwlen)
+{
+       struct interface *ifp;
+       struct if_options *ifo;
+
+       for (ifp = ifaces; ifp; ifp = ifp->next)
+               if (strcmp(ifp->name, ifname) == 0 && ifp->hwlen <= hwlen) {
+                       ifo = ifp->state->options;
+                       if (!(ifo->options &
+                           (DHCPCD_INFORM | DHCPCD_STATIC | DHCPCD_CLIENTID))
+                           && ifp->state->new != NULL &&
+                           ifp->state->new->cookie == htonl(MAGIC_COOKIE))
+                       {
+                               syslog(LOG_INFO,
+                                   "%s: expiring for new hardware address",
+                                   ifp->name);
+                               drop_config(ifp, "EXPIRE");
+                       }
+                       memcpy(ifp->hwaddr, hwaddr, hwlen);
+                       ifp->hwlen = hwlen;
+                       if (!(ifo->options &
+                           (DHCPCD_INFORM | DHCPCD_STATIC | DHCPCD_CLIENTID)))
+                       {
+                               syslog(LOG_DEBUG, "%s: using hwaddr %s",
+                                   ifp->name,
+                                   hwaddr_ntoa(ifp->hwaddr, ifp->hwlen));
+                               ifp->state->interval = 0;
+                               ifp->state->nakoff = 1;
+                               start_interface(ifp);
+                       }
+               }
+       free(hwaddr);
+}
+#endif
+
 void
 handle_ifa(int type, const char *ifname,
     struct in_addr *addr, struct in_addr *net, struct in_addr *dst)
@@ -1640,7 +1685,8 @@
        if (iface->udp_fd == -1 &&
            iface->addr.s_addr != 0 &&
            iface->state->new != NULL &&
-           iface->state->new->cookie == htonl(MAGIC_COOKIE))
+           (iface->state->new->cookie == htonl(MAGIC_COOKIE) ||
+           iface->state->options->options & DHCPCD_INFORM))
        {
                if (open_udp_socket(iface) == -1 && errno != EADDRINUSE)
                        syslog(LOG_ERR, "%s: open_udp_socket: %m", iface->name);
diff -r de963dcf59bc -r 5ac1c33a6b2c external/bsd/dhcpcd/dist/dhcpcd.conf.5.in
--- a/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in Sat Nov 27 10:41:16 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in Sat Nov 27 11:24:09 2010 +0000
@@ -27,7 +27,7 @@
 .Os
 .Sh NAME
 .Nm dhcpcd.conf
-.Nd dhcpcd configuration file 
+.Nd dhcpcd configuration file
 .Sh DESCRIPTION
 Although
 .Nm dhcpcd
diff -r de963dcf59bc -r 5ac1c33a6b2c external/bsd/dhcpcd/dist/dhcpcd.h
--- a/external/bsd/dhcpcd/dist/dhcpcd.h Sat Nov 27 10:41:16 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.h Sat Nov 27 11:24:09 2010 +0000
@@ -123,6 +123,7 @@
 struct interface *find_interface(const char *);
 int handle_args(struct fd_list *, int, char **);
 void handle_interface(int, const char *);
+void handle_hwaddr(const char *, unsigned char *, size_t);
 void handle_ifa(int, const char *,
     struct in_addr *, struct in_addr *, struct in_addr *);
 void handle_exit_timeout(void *);
diff -r de963dcf59bc -r 5ac1c33a6b2c external/bsd/dhcpcd/dist/eloop.c
--- a/external/bsd/dhcpcd/dist/eloop.c  Sat Nov 27 10:41:16 2010 +0000
+++ b/external/bsd/dhcpcd/dist/eloop.c  Sat Nov 27 11:24:09 2010 +0000
@@ -224,16 +224,6 @@
 }
 
 void
-delete_timeouts( void *arg, void (*callback)(void *), ...)
-{
-       va_list va;
-
-       va_start(va, callback);
-       v_delete_q_timeouts(0, arg, callback, va);
-       va_end(va);
-}
-
-void
 delete_q_timeout(int queue, void (*callback)(void *), void *arg)
 {
        struct timeout *t, *tt, *last = NULL;
diff -r de963dcf59bc -r 5ac1c33a6b2c external/bsd/dhcpcd/dist/eloop.h
--- a/external/bsd/dhcpcd/dist/eloop.h  Sat Nov 27 10:41:16 2010 +0000
+++ b/external/bsd/dhcpcd/dist/eloop.h  Sat Nov 27 11:24:09 2010 +0000
@@ -30,9 +30,14 @@
 
 #include <time.h>
 
-#define add_timeout_tv(a, b, c) add_q_timeout_tv(0, a, b, c)
-#define add_timeout_sec(a, b, c) add_q_timeout_sec(0, a, b, c)
-#define delete_timeout(a, b) delete_q_timeout(0, a, b)
+#ifndef ELOOP_QUEUE
+  #define ELOOP_QUEUE 0
+#endif
+
+#define add_timeout_tv(a, b, c) add_q_timeout_tv(ELOOP_QUEUE, a, b, c)
+#define add_timeout_sec(a, b, c) add_q_timeout_sec(ELOOP_QUEUE, a, b, c)
+#define delete_timeout(a, b) delete_q_timeout(ELOOP_QUEUE, a, b)
+#define delete_timeouts(a, ...) delete_q_timeouts(ELOOP_QUEUE, a, __VA_ARGS__)
 
 void add_event(int fd, void (*)(void *), void *);



Home | Main Index | Thread Index | Old Index