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



details:   https://anonhg.NetBSD.org/src/rev/2d4ff66b3a60
branches:  trunk
changeset: 773336:2d4ff66b3a60
user:      roy <roy%NetBSD.org@localhost>
date:      Tue Jan 31 09:39:47 2012 +0000

description:
Import dhcpcd-5.5.1 with the following changes:
* Don't start IPv6 RS if disabled globally
* Allow dhcpcd to run on a read only filesystem
* Don't attempt to run the script if an empty string or /dev/null
* Stop truncating the netmask sockaddr on routing messages for BSD

diffstat:

 external/bsd/dhcpcd/dist/configure.c                 |   5 ++
 external/bsd/dhcpcd/dist/defs.h                      |   2 +-
 external/bsd/dhcpcd/dist/dhcp.c                      |   4 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf |  24 ++++-------
 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in         |   7 +++-
 external/bsd/dhcpcd/dist/dhcpcd.c                    |  40 ++++++++-----------
 external/bsd/dhcpcd/dist/if-bsd.c                    |  18 +-------
 7 files changed, 42 insertions(+), 58 deletions(-)

diffs (243 lines):

diff -r ab844949d8ed -r 2d4ff66b3a60 external/bsd/dhcpcd/dist/configure.c
--- a/external/bsd/dhcpcd/dist/configure.c      Tue Jan 31 09:19:58 2012 +0000
+++ b/external/bsd/dhcpcd/dist/configure.c      Tue Jan 31 09:39:47 2012 +0000
@@ -329,6 +329,11 @@
        const struct fd_list *fd;
        struct iovec iov[2];
 
+       if (iface->state->options->script == NULL ||
+           iface->state->options->script[0] == '\0' ||
+           strcmp(iface->state->options->script, "/dev/null") == 0)
+               return 0;
+
        syslog(LOG_DEBUG, "%s: executing `%s', reason %s",
            iface->name, argv[0], iface->state->reason);
 
diff -r ab844949d8ed -r 2d4ff66b3a60 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Tue Jan 31 09:19:58 2012 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Tue Jan 31 09:39:47 2012 +0000
@@ -28,7 +28,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "5.5.0"
+#define VERSION                        "5.5.1"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r ab844949d8ed -r 2d4ff66b3a60 external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c   Tue Jan 31 09:19:58 2012 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c   Tue Jan 31 09:39:47 2012 +0000
@@ -1125,10 +1125,8 @@
            iface->name, iface->leasefile);
 
        fd = open(iface->leasefile, O_WRONLY | O_CREAT | O_TRUNC, 0444);
-       if (fd == -1) {
-               syslog(LOG_ERR, "%s: open: %m", iface->name);
+       if (fd == -1)
                return -1;
-       }
 
        /* Only write as much as we need */
        while (p < e) {
diff -r ab844949d8ed -r 2d4ff66b3a60 external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf
--- a/external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf      Tue Jan 31 09:19:58 2012 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf      Tue Jan 31 09:39:47 2012 +0000
@@ -12,7 +12,7 @@
 
 build_resolv_conf()
 {
-       local cf="$state_dir/resolv.conf.$interface$ifsuffix"
+       local cf="$state_dir/resolv.conf.$interface$if_suffix"
        local interfaces= header= search= srvs= servers= x=
 
        # Build a list of interfaces
@@ -114,37 +114,31 @@
        done
        if type resolvconf >/dev/null 2>&1; then
                [ -n "$ifmetric" ] && export IF_METRIC="$ifmetric"
-               printf %s "$conf" | resolvconf -a "$interface$ifsuffix"
+               printf %s "$conf" | resolvconf -a "$interface$if_suffix"
                return $?
        fi
 
-       if [ -e "$resolv_conf_dir/$interface$ifsuffix" ]; then
-               rm -f "$resolv_conf_dir/$interface$ifsuffix"
+       if [ -e "$resolv_conf_dir/$interface$if_suffix" ]; then
+               rm -f "$resolv_conf_dir/$interface$if_suffix"
        fi
        [ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
-       printf %s "$conf" > "$resolv_conf_dir/$interface$ifsuffix"
+       printf %s "$conf" > "$resolv_conf_dir/$interface$if_suffix"
        build_resolv_conf
 }
 
 remove_resolv_conf()
 {
        if type resolvconf >/dev/null 2>&1; then
-               resolvconf -d "$interface$ifsuffix" -f
+               resolvconf -d "$interface$if_suffix" -f
        else
-               if [ -e "$resolv_conf_dir/$interface$ifsuffix" ]; then
-                       rm -f "$resolv_conf_dir/$interface$ifsuffix"
+               if [ -e "$resolv_conf_dir/$interface$if_suffix" ]; then
+                       rm -f "$resolv_conf_dir/$interface$if_suffix"
                fi
                build_resolv_conf
        fi
 }
 
-if [ "$reason" = ROUTERADVERT ]; then
-       ifsuffix=":ra"
-else
-       ifsuffix=
-fi
-
-if $if_up; then
+if $if_up || [ "$reason" = ROUTERADVERT ]; then
        add_resolv_conf
 elif $if_down; then
        remove_resolv_conf
diff -r ab844949d8ed -r 2d4ff66b3a60 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in
--- a/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in      Tue Jan 31 09:19:58 2012 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in      Tue Jan 31 09:39:47 2012 +0000
@@ -16,7 +16,12 @@
 PREINIT|EXPIRE|FAIL|IPV4LL|NAK|NOCARRIER|RELEASE|STOP) if_down=true;;
 esac
 
-[ "$reason" = ROUTERADVERT -a "$ra_count" != 0 ] && if_up=true
+if [ "$reason" = ROUTERADVERT ]; then
+       if_suffix=":ra"
+       [ "$new_ra_count" != 0 ] && if_up=true
+else
+       if_suffix=
+fi
 
 # Ensure that all arguments are unique
 uniqify()
diff -r ab844949d8ed -r 2d4ff66b3a60 external/bsd/dhcpcd/dist/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/dhcpcd.c Tue Jan 31 09:19:58 2012 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.c Tue Jan 31 09:39:47 2012 +0000
@@ -912,13 +912,13 @@
                        syslog(LOG_INFO, "%s: carrier lost", iface->name);
                        close_sockets(iface);
                        delete_timeouts(iface, start_expire, NULL);
-                       drop_dhcp(iface, "NOCARRIER");
                        if (iface->ras) {
                                ipv6rs_free(iface);
                                iface->ras = NULL;
                                iface->state->reason = "ROUTERADVERT";
                                run_script(iface);
                        }
+                       drop_dhcp(iface, "NOCARRIER");
                }
        } else if (carrier == 1 && !(~iface->flags & (IFF_UP | IFF_RUNNING))) {
                if (iface->carrier != LINK_UP) {
@@ -1162,7 +1162,7 @@
        free(iface->state->offer);
        iface->state->offer = NULL;
 
-       if (ifo->options & DHCPCD_IPV6RS)
+       if (options & DHCPCD_IPV6RS && ifo->options & DHCPCD_IPV6RS)
                ipv6rs_start(iface);
 
        if (iface->state->arping_index < ifo->arping_len) {
@@ -1934,29 +1934,25 @@
                }
 
                /* Ensure we have the needed directories */
-               if (mkdir(RUNDIR, 0755) == -1 && errno != EEXIST) {
+               if (mkdir(RUNDIR, 0755) == -1 && errno != EEXIST)
                        syslog(LOG_ERR, "mkdir `%s': %m", RUNDIR);
-                       exit(EXIT_FAILURE);
-               }
-               if (mkdir(DBDIR, 0755) == -1 && errno != EEXIST) {
+               if (mkdir(DBDIR, 0755) == -1 && errno != EEXIST)
                        syslog(LOG_ERR, "mkdir `%s': %m", DBDIR);
-                       exit(EXIT_FAILURE);
-               }
 
                pidfd = open(pidfile, O_WRONLY | O_CREAT | O_NONBLOCK, 0664);
-               if (pidfd == -1) {
+               if (pidfd == -1)
                        syslog(LOG_ERR, "open `%s': %m", pidfile);
-                       exit(EXIT_FAILURE);
+               else {
+                       /* Lock the file so that only one instance of dhcpcd
+                        * runs on an interface */
+                       if (flock(pidfd, LOCK_EX | LOCK_NB) == -1) {
+                               syslog(LOG_ERR, "flock `%s': %m", pidfile);
+                               exit(EXIT_FAILURE);
+                       }
+                       if (set_cloexec(pidfd) == -1)
+                               exit(EXIT_FAILURE);
+                       writepid(pidfd, getpid());
                }
-               /* Lock the file so that only one instance of dhcpcd runs
-                * on an interface */
-               if (flock(pidfd, LOCK_EX | LOCK_NB) == -1) {
-                       syslog(LOG_ERR, "flock `%s': %m", pidfile);
-                       exit(EXIT_FAILURE);
-               }
-               if (set_cloexec(pidfd) == -1)
-                       exit(EXIT_FAILURE);
-               writepid(pidfd, getpid());
        }
 
        syslog(LOG_INFO, "version " VERSION " starting");
@@ -1968,10 +1964,8 @@
        add_event(signal_fd, handle_signal, NULL);
 
        if (options & DHCPCD_MASTER) {
-               if (start_control() == -1) {
+               if (start_control() == -1)
                        syslog(LOG_ERR, "start_control: %m");
-                       exit(EXIT_FAILURE);
-               }
        }
 
        if (init_sockets() == -1) {
@@ -2045,7 +2039,7 @@
 
        if (!(options & DHCPCD_BACKGROUND)) {
                /* If we don't have a carrier, we may have to wait for a second
-                * before one becomes available if we brought an interface up. */
+                * before one becomes available if we brought an interface up */
                if (opt == 0 &&
                    options & DHCPCD_LINK &&
                    options & DHCPCD_WAITUP &&
diff -r ab844949d8ed -r 2d4ff66b3a60 external/bsd/dhcpcd/dist/if-bsd.c
--- a/external/bsd/dhcpcd/dist/if-bsd.c Tue Jan 31 09:19:58 2012 +0000
+++ b/external/bsd/dhcpcd/dist/if-bsd.c Tue Jan 31 09:39:47 2012 +0000
@@ -195,7 +195,7 @@
                struct rt_msghdr hdr;
                char buffer[sizeof(su) * 4];
        } rtm;
-       char *bp = rtm.buffer, *p;
+       char *bp = rtm.buffer;
        size_t l;
        int retval = 0;
 
@@ -250,20 +250,8 @@
        } else
                ADDADDR(gate);
 
-       if (rtm.hdr.rtm_addrs & RTA_NETMASK) {
-               /* Ensure that netmask is set correctly */
-               memset(&su, 0, sizeof(su));
-               su.sin.sin_family = AF_INET;
-               su.sin.sin_len = sizeof(su.sin);
-               memcpy(&su.sin.sin_addr, &net->s_addr, sizeof(su.sin.sin_addr));
-               p = su.sa.sa_len + (char *)&su;
-               for (su.sa.sa_len = 0; p > (char *)&su;)
-                       if (*--p != 0) {
-                               su.sa.sa_len = 1 + p - (char *)&su;
-                               break;
-                       }
-               ADDSU(su);
-       }
+       if (rtm.hdr.rtm_addrs & RTA_NETMASK)
+               ADDADDR(net);
 
        if (rtm.hdr.rtm_addrs & RTA_IFA)
                ADDADDR(&iface->addr);



Home | Main Index | Thread Index | Old Index