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 Sync



details:   https://anonhg.NetBSD.org/src/rev/8024a711a040
branches:  trunk
changeset: 341942:8024a711a040
user:      roy <roy%NetBSD.org@localhost>
date:      Mon Nov 30 16:33:00 2015 +0000

description:
Sync

diffstat:

 external/bsd/dhcpcd/dist/arp.c                    |   36 +-
 external/bsd/dhcpcd/dist/common.c                 |  113 +++++---
 external/bsd/dhcpcd/dist/common.h                 |   25 +-
 external/bsd/dhcpcd/dist/defs.h                   |    4 +-
 external/bsd/dhcpcd/dist/dhcp-common.c            |   54 +++-
 external/bsd/dhcpcd/dist/dhcp-common.h            |    5 +-
 external/bsd/dhcpcd/dist/dhcp.c                   |  274 +++++++++++----------
 external/bsd/dhcpcd/dist/dhcp.h                   |    5 +-
 external/bsd/dhcpcd/dist/dhcp6.c                  |  145 +++++++----
 external/bsd/dhcpcd/dist/dhcp6.h                  |    3 +-
 external/bsd/dhcpcd/dist/dhcpcd-definitions.conf  |   10 +-
 external/bsd/dhcpcd/dist/dhcpcd-embedded.c        |   10 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf |   57 +++-
 external/bsd/dhcpcd/dist/dhcpcd.8.in              |   35 ++-
 external/bsd/dhcpcd/dist/dhcpcd.c                 |  177 +++++++++----
 external/bsd/dhcpcd/dist/dhcpcd.conf.5.in         |   10 +-
 external/bsd/dhcpcd/dist/duid.c                   |    3 +-
 external/bsd/dhcpcd/dist/if-bsd.c                 |  127 ++++-----
 external/bsd/dhcpcd/dist/if-options.c             |   28 +-
 external/bsd/dhcpcd/dist/if-options.h             |    6 +-
 external/bsd/dhcpcd/dist/if.c                     |   14 +-
 external/bsd/dhcpcd/dist/ipv4.c                   |   79 +++++-
 external/bsd/dhcpcd/dist/ipv4.h                   |    3 +-
 external/bsd/dhcpcd/dist/ipv4ll.c                 |   13 +-
 external/bsd/dhcpcd/dist/ipv6.c                   |   70 ++++-
 external/bsd/dhcpcd/dist/ipv6.h                   |   28 +-
 external/bsd/dhcpcd/dist/script.c                 |    8 +-
 27 files changed, 830 insertions(+), 512 deletions(-)

diffs (truncated from 2771 to 300 lines):

diff -r 476e486e69e4 -r 8024a711a040 external/bsd/dhcpcd/dist/arp.c
--- a/external/bsd/dhcpcd/dist/arp.c    Mon Nov 30 13:27:09 2015 +0000
+++ b/external/bsd/dhcpcd/dist/arp.c    Mon Nov 30 16:33:00 2015 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: arp.c,v 1.14 2015/07/09 10:15:34 roy Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.15 2015/11/30 16:33:00 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -382,33 +382,33 @@
        }
 }
 
+static void
+arp_free_but1(struct interface *ifp, struct arp_state *astate)
+{
+       struct iarp_state *state;
+
+       if ((state = ARP_STATE(ifp)) != NULL) {
+               struct arp_state *p, *n;
+
+               TAILQ_FOREACH_SAFE(p, &state->arp_states, next, n) {
+                       if (p != astate)
+                               arp_free(p);
+               }
+       }
+}
+
 void
 arp_free_but(struct arp_state *astate)
 {
-       struct iarp_state *state;
-       struct arp_state *p, *n;
 
-       state = ARP_STATE(astate->iface);
-       TAILQ_FOREACH_SAFE(p, &state->arp_states, next, n) {
-               if (p != astate)
-                       arp_free(p);
-       }
+       arp_free_but1(astate->iface, astate);
 }
 
 void
 arp_close(struct interface *ifp)
 {
-       struct iarp_state *state;
-       struct arp_state *astate;
 
-       /* Freeing the last state will also free the main state,
-        * so test for both. */
-       for (;;) {
-               if ((state = ARP_STATE(ifp)) == NULL ||
-                   (astate = TAILQ_FIRST(&state->arp_states)) == NULL)
-                       break;
-               arp_free(astate);
-       }
+       arp_free_but1(ifp, NULL);
 }
 
 void
diff -r 476e486e69e4 -r 8024a711a040 external/bsd/dhcpcd/dist/common.c
--- a/external/bsd/dhcpcd/dist/common.c Mon Nov 30 13:27:09 2015 +0000
+++ b/external/bsd/dhcpcd/dist/common.c Mon Nov 30 16:33:00 2015 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: common.c,v 1.14 2015/07/09 10:15:34 roy Exp $");
+ __RCSID("$NetBSD: common.c,v 1.15 2015/11/30 16:33:00 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -56,29 +56,6 @@
 #  define _PATH_DEVNULL "/dev/null"
 #endif
 
-const char *
-get_hostname(char *buf, size_t buflen, int short_hostname)
-{
-       char *p;
-
-       if (gethostname(buf, buflen) != 0)
-               return NULL;
-       buf[buflen - 1] = '\0';
-       if (strcmp(buf, "(none)") == 0 ||
-           strcmp(buf, "localhost") == 0 ||
-           strncmp(buf, "localhost.", strlen("localhost.")) == 0 ||
-           buf[0] == '.')
-               return NULL;
-
-       if (short_hostname) {
-               p = strchr(buf, '.');
-               if (p)
-                       *p = '\0';
-       }
-
-       return buf;
-}
-
 #if USE_LOGFILE
 void
 logger_open(struct dhcpcd_ctx *ctx)
@@ -115,6 +92,21 @@
        closelog();
 }
 
+/*
+ * NetBSD's gcc has been modified to check for the non standard %m in printf
+ * like functions and warn noisily about it that they should be marked as
+ * syslog like instead.
+ * This is all well and good, but our logger also goes via vfprintf and
+ * when marked as a sysloglike funcion, gcc will then warn us that the
+ * function should be printflike instead!
+ * This creates an infinte loop of gcc warnings.
+ * Until NetBSD solves this issue, we have to disable a gcc diagnostic
+ * for our fully standards compliant code in the logger function.
+ */
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5))
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmissing-format-attribute"
+#endif
 void
 logger(struct dhcpcd_ctx *ctx, int pri, const char *fmt, ...)
 {
@@ -124,9 +116,6 @@
        char fmt_cpy[1024];
 #endif
 
-       if (pri >= LOG_DEBUG && ctx && !(ctx->options & DHCPCD_DEBUG))
-               return;
-
        serrno = errno;
        va_start(va, fmt);
 
@@ -147,8 +136,18 @@
                                fmt_left -= 2;
                                p++;
                        } else if (p[0] == '%' && p[1] == 'm') {
-                               if (serr == NULL)
+                               if (serr == NULL) {
+                                       /* strerror_r isn't portable.
+                                        * strerror_l isn't widely found
+                                        * and also problematic to use.
+                                        * Also, if strerror_l exists then
+                                        * strerror could easily be made
+                                        * treadsafe in the same libc.
+                                        * dhcpcd is only threaded in RTEMS
+                                        * where strerror is threadsafe,
+                                        * so this should be fine. */
                                        serr = strerror(serrno);
+                               }
                                fmt_wrote = strlcpy(fp, serr, fmt_left);
                                if (fmt_wrote > fmt_left)
                                        break;
@@ -165,44 +164,62 @@
                *fp++ = '\0';
                fmt = fmt_cpy;
        }
-
 #endif
 
-       if (ctx == NULL || !(ctx->options & DHCPCD_QUIET)) {
+       if ((ctx == NULL || !(ctx->options & DHCPCD_QUIET)) &&
+           (pri < LOG_DEBUG || (ctx->options & DHCPCD_DEBUG)))
+       {
                va_list vac;
 
                va_copy(vac, va);
+#ifdef HAVE_PRINTF_M
+               errno = serrno;
+#endif
                vfprintf(pri <= LOG_ERR ? stderr : stdout, fmt, vac);
                fputc('\n', pri <= LOG_ERR ? stderr : stdout);
                va_end(vac);
        }
 
-#ifdef HAVE_PRINTF_M
-       errno = serrno;
-#endif
+       /* Don't send to syslog if dumping leases or testing */
+       if (ctx->options & (DHCPCD_DUMPLEASE | DHCPCD_TEST))
+               goto out;
+
        if (ctx && ctx->log_fd != -1) {
-               struct timeval tv;
-               char buf[32];
+               if (pri < LOG_DEBUG || (ctx->options & DHCPCD_DEBUG)) {
+                       struct timeval tv;
+                       char buf[32];
 
-               /* Write the time, syslog style. month day time - */
-               if (gettimeofday(&tv, NULL) != -1) {
-                       time_t now;
-                       struct tm tmnow;
+                       /* Write the time, syslog style. month day time - */
+                       if (gettimeofday(&tv, NULL) != -1) {
+                               time_t now;
+                               struct tm tmnow;
 
-                       tzset();
-                       now = tv.tv_sec;
-                       localtime_r(&now, &tmnow);
-                       strftime(buf, sizeof(buf), "%b %d %T ", &tmnow);
-                       dprintf(ctx->log_fd, "%s", buf);
+                               tzset();
+                               now = tv.tv_sec;
+                               localtime_r(&now, &tmnow);
+                               strftime(buf, sizeof(buf), "%b %d %T ", &tmnow);
+                               dprintf(ctx->log_fd, "%s", buf);
+                       }
+
+#ifdef HAVE_PRINTF_M
+                       errno = serrno;
+#endif
+                       vdprintf(ctx->log_fd, fmt, va);
+                       dprintf(ctx->log_fd, "\n");
                }
-
-               vdprintf(ctx->log_fd, fmt, va);
-               dprintf(ctx->log_fd, "\n");
-       } else
+       } else {
+#ifdef HAVE_PRINTF_M
+               errno = serrno;
+#endif
                vsyslog(pri, fmt, va);
+       }
+out:
        va_end(va);
 }
 #endif
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5))
+#pragma GCC diagnostic pop
+#endif
 
 ssize_t
 setvar(struct dhcpcd_ctx *ctx,
diff -r 476e486e69e4 -r 8024a711a040 external/bsd/dhcpcd/dist/common.h
--- a/external/bsd/dhcpcd/dist/common.h Mon Nov 30 13:27:09 2015 +0000
+++ b/external/bsd/dhcpcd/dist/common.h Mon Nov 30 16:33:00 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: common.h,v 1.11 2015/10/14 15:58:08 christos Exp $ */
+/* $NetBSD: common.h,v 1.12 2015/11/30 16:33:00 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -115,25 +115,19 @@
 #endif
 
 #if __GNUC__ > 2 || defined(__INTEL_COMPILER)
-# ifndef __dead
-#  define __dead __attribute__((__noreturn__))
-# endif
 # ifndef __packed
-#  define __packed   __attribute__((__packed__))
-# endif
-# ifndef __syslog_attribute__
-#  define __syslog__ __printf__
+#  define __packed __attribute__((__packed__))
 # endif
 # ifndef __sysloglike
-#  define __sysloglike(a, b) __attribute__((__format__(__syslog__, a, b)))
+#  ifndef __syslog_attribute_
+#    define __syslog__ __printf__
+#  endif
+#  define __sysloglike(a, b) __attribute__((format(__syslog__, a, b)))
 # endif
 # ifndef __unused
-#  define __unused   __attribute__((__unused__))
+#  define __unused __attribute__((__unused__))
 # endif
 #else
-# ifndef __dead
-#  define __dead
-# endif
 # ifndef __packed
 #  define __packed
 # endif
@@ -146,7 +140,7 @@
 #endif
 
 #ifndef __arraycount
-#define __arraycount(__x)       (sizeof(__x) / sizeof(__x[0]))
+#  define __arraycount(__x)       (sizeof(__x) / sizeof(__x[0]))
 #endif
 
 /* We don't really need this as our supported systems define __restrict
@@ -162,7 +156,6 @@
 #endif
 
 void get_line_free(void);
-const char *get_hostname(char *, size_t, int);
 extern int clock_monotonic;
 int get_monotonic(struct timespec *);
 
@@ -177,7 +170,7 @@
 #if USE_LOGFILE
 void logger_open(struct dhcpcd_ctx *);
 #define logger_mask(ctx, lvl) setlogmask((lvl))
-__sysloglike(3, 4) void logger(struct dhcpcd_ctx *, int, const char *, ...);
+void logger(struct dhcpcd_ctx *, int, const char *, ...) __sysloglike(3, 4);



Home | Main Index | Thread Index | Old Index