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-7.0.0-beta3 with the ...



details:   https://anonhg.NetBSD.org/src/rev/dfd3d9ff2bfa
branches:  trunk
changeset: 823165:dfd3d9ff2bfa
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Apr 14 09:53:06 2017 +0000

description:
Import dhcpcd-7.0.0-beta3 with the following changes:
  *  restored --logfile support as a few people complained it vanished
     The new logging code even makes the overall binary size smaller
     on most platforms.
  *  BPF filter now trims garbage trailing the payload
     OK, it's not garbage, but userland doesn't know some drivers append
     FCS to it.
  *  support NetBSD's RO_MSGFILTER socket option to reduce avoid context
     switching for route(4) messages that don't interest us.
  *  Don't open sockets if just sending signals.
  *  HMAC-MD5 test's now check expectations in code rather than relying
     on visual confirmation.
  *  added eloop-bench to test performance of eloop with available
     polling mechanisms.

diffstat:

 external/bsd/dhcpcd/dist/BUILDING.md                     |    2 +-
 external/bsd/dhcpcd/dist/Makefile                        |   10 +-
 external/bsd/dhcpcd/dist/compat/dprintf.c                |    5 +-
 external/bsd/dhcpcd/dist/compat/dprintf.h                |    2 +-
 external/bsd/dhcpcd/dist/src/Makefile                    |    7 +-
 external/bsd/dhcpcd/dist/src/arp.c                       |   46 +-
 external/bsd/dhcpcd/dist/src/bpf.h                       |    2 +-
 external/bsd/dhcpcd/dist/src/common.c                    |    7 +-
 external/bsd/dhcpcd/dist/src/control.c                   |    6 +-
 external/bsd/dhcpcd/dist/src/defs.h                      |    2 +-
 external/bsd/dhcpcd/dist/src/dev.c                       |   21 +-
 external/bsd/dhcpcd/dist/src/dhcp-common.c               |   17 +-
 external/bsd/dhcpcd/dist/src/dhcp.c                      |  290 +++++------
 external/bsd/dhcpcd/dist/src/dhcp6.c                     |  290 +++++------
 external/bsd/dhcpcd/dist/src/dhcpcd.8.in                 |   17 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in            |   16 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.h                    |    2 +-
 external/bsd/dhcpcd/dist/src/duid.c                      |   22 +-
 external/bsd/dhcpcd/dist/src/eloop.c                     |   26 +-
 external/bsd/dhcpcd/dist/src/if-bsd.c                    |   75 ++-
 external/bsd/dhcpcd/dist/src/if-linux.c                  |   24 +-
 external/bsd/dhcpcd/dist/src/if-options.h                |    2 +-
 external/bsd/dhcpcd/dist/src/if.c                        |   27 +-
 external/bsd/dhcpcd/dist/src/ipv4.c                      |   39 +-
 external/bsd/dhcpcd/dist/src/ipv4ll.c                    |   27 +-
 external/bsd/dhcpcd/dist/src/ipv6.c                      |   80 +-
 external/bsd/dhcpcd/dist/src/ipv6nd.c                    |  161 ++---
 external/bsd/dhcpcd/dist/src/logerr.c                    |  368 +++++++++++++++
 external/bsd/dhcpcd/dist/src/logerr.h                    |   77 +++
 external/bsd/dhcpcd/dist/src/route.c                     |   26 +-
 external/bsd/dhcpcd/dist/src/script.c                    |   27 +-
 external/bsd/dhcpcd/dist/tests/Makefile                  |   16 +
 external/bsd/dhcpcd/dist/tests/crypt/.gitignore          |    1 +
 external/bsd/dhcpcd/dist/tests/crypt/GNUmakefile         |    7 +
 external/bsd/dhcpcd/dist/tests/crypt/Makefile            |   38 +
 external/bsd/dhcpcd/dist/tests/crypt/README.md           |    8 +
 external/bsd/dhcpcd/dist/tests/crypt/run-test.c          |   38 +
 external/bsd/dhcpcd/dist/tests/crypt/test.h              |   32 +
 external/bsd/dhcpcd/dist/tests/crypt/test_hmac_md5.c     |  207 ++++++++
 external/bsd/dhcpcd/dist/tests/eloop-bench/.gitignore    |    1 +
 external/bsd/dhcpcd/dist/tests/eloop-bench/Makefile      |   42 +
 external/bsd/dhcpcd/dist/tests/eloop-bench/README.md     |   53 ++
 external/bsd/dhcpcd/dist/tests/eloop-bench/eloop-bench.c |  166 ++++++
 43 files changed, 1688 insertions(+), 644 deletions(-)

diffs (truncated from 5655 to 300 lines):

diff -r 870f5cdc9d23 -r dfd3d9ff2bfa external/bsd/dhcpcd/dist/BUILDING.md
--- a/external/bsd/dhcpcd/dist/BUILDING.md      Fri Apr 14 09:50:56 2017 +0000
+++ b/external/bsd/dhcpcd/dist/BUILDING.md      Fri Apr 14 09:53:06 2017 +0000
@@ -11,7 +11,7 @@
 size is a concern, you can use the `--small` configure option to enable
 a reduced feature set within dhcpcd.
 Currently this just removes non important options out of
-`dhcpcd-definitions.conf`, the custom logger and
+`dhcpcd-definitions.conf`, the logfile option and
 support for DHCPv6 Prefix Delegation.
 Other features maybe dropped as and when required.
 dhcpcd can also be made smaller by removing the IPv4 or IPv6 stack:
diff -r 870f5cdc9d23 -r dfd3d9ff2bfa external/bsd/dhcpcd/dist/Makefile
--- a/external/bsd/dhcpcd/dist/Makefile Fri Apr 14 09:50:56 2017 +0000
+++ b/external/bsd/dhcpcd/dist/Makefile Fri Apr 14 09:53:06 2017 +0000
@@ -16,7 +16,7 @@
 
 CLEANFILES+=   *.tar.xz
 
-.PHONY:                hooks import import-bsd test
+.PHONY:                hooks import import-bsd tests
 
 .SUFFIXES:     .in
 
@@ -26,8 +26,10 @@
 depend: config.h
        for x in ${SUBDIRS}; do cd $$x; ${MAKE} $@; cd ..; done
 
-test:
-       cd $@; ${MAKE} $@; ./$@
+tests:
+       cd $@; ${MAKE} $@
+
+test: tests
 
 hooks:
        cd $@; ${MAKE}
@@ -43,7 +45,7 @@
 
 clean:
        rm -rf cov-int
-       for x in ${SUBDIRS} test; do cd $$x; ${MAKE} $@; cd ..; done
+       for x in ${SUBDIRS} tests; do cd $$x; ${MAKE} $@; cd ..; done
 
 distclean: clean
        rm -f config.h config.mk config.log \
diff -r 870f5cdc9d23 -r dfd3d9ff2bfa external/bsd/dhcpcd/dist/compat/dprintf.c
--- a/external/bsd/dhcpcd/dist/compat/dprintf.c Fri Apr 14 09:50:56 2017 +0000
+++ b/external/bsd/dhcpcd/dist/compat/dprintf.c Fri Apr 14 09:53:06 2017 +0000
@@ -1,6 +1,6 @@
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2014 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2017 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -41,7 +41,7 @@
        if ((e = dup(fd)) == -1)
                return -1;
 
-       if ((fp = fdopen(e, "w")) == NULL) {
+       if ((fp = fdopen(e, "a")) == NULL) {
                close(e);
                return -1;
        }
@@ -62,4 +62,3 @@
        va_end(va);
        return e;
 }
-
diff -r 870f5cdc9d23 -r dfd3d9ff2bfa external/bsd/dhcpcd/dist/compat/dprintf.h
--- a/external/bsd/dhcpcd/dist/compat/dprintf.h Fri Apr 14 09:50:56 2017 +0000
+++ b/external/bsd/dhcpcd/dist/compat/dprintf.h Fri Apr 14 09:53:06 2017 +0000
@@ -1,6 +1,6 @@
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2014 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2017 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
diff -r 870f5cdc9d23 -r dfd3d9ff2bfa external/bsd/dhcpcd/dist/src/Makefile
--- a/external/bsd/dhcpcd/dist/src/Makefile     Fri Apr 14 09:50:56 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/Makefile     Fri Apr 14 09:53:06 2017 +0000
@@ -1,12 +1,12 @@
 # dhcpcd Makefile
 
 PROG=          dhcpcd
-SRCS=          common.c control.c dhcpcd.c duid.c eloop.c
+SRCS=          common.c control.c dhcpcd.c duid.c eloop.c logerr.c
 SRCS+=         if.c if-options.c sa.c route.c
 SRCS+=         dhcp-common.c script.c
 
 CFLAGS?=       -O2
-MKDIRS=
+SUBDIRS+=      ${MKDIRS}
 
 TOP?=          ..
 include ${TOP}/iconfig.mk
@@ -45,6 +45,7 @@
                $< > $@
 
 all: ${TOP}/config.h ${PROG} ${SCRIPTS} ${MAN5} ${MAN8}
+       for x in ${SUBDIRS}; do cd $$x; ${MAKE} $@; cd ..; done
 
 dev:
        cd dev && ${MAKE}
@@ -80,6 +81,7 @@
        ${INSTALL} -d ${DESTDIR}${DBDIR}
 
 proginstall: _proginstall ${EMBEDDEDINSTALL}
+       for x in ${SUBDIRS}; do cd $$x; ${MAKE} $@; cd ..; done
 
 _maninstall: ${MAN5} ${MAN8}
        ${INSTALL} -d ${DESTDIR}${MANDIR}/man5
@@ -125,6 +127,7 @@
 
 clean:
        rm -f ${OBJS} ${PROG} ${PROG}.core ${CLEANFILES}
+       for x in ${SUBDIRS}; do cd $$x; ${MAKE} $@; cd ..; done
 
 distclean: clean
        rm -f .depend
diff -r 870f5cdc9d23 -r dfd3d9ff2bfa external/bsd/dhcpcd/dist/src/arp.c
--- a/external/bsd/dhcpcd/dist/src/arp.c        Fri Apr 14 09:50:56 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.c        Fri Apr 14 09:53:06 2017 +0000
@@ -38,7 +38,6 @@
 #include <signal.h>
 #include <stdlib.h>
 #include <string.h>
-#include <syslog.h>
 #include <unistd.h>
 
 #define ELOOP_QUEUE 5
@@ -52,6 +51,7 @@
 #include "if.h"
 #include "if-options.h"
 #include "ipv4ll.h"
+#include "logerr.h"
 
 #if defined(ARP) && (!defined(KERNEL_RFC5227) || defined(ARPING))
 #define ARP_LEN                                                                      \
@@ -152,7 +152,7 @@
        }
        if (ifn) {
 #ifdef ARP_DEBUG
-               syslog(LOG_DEBUG, "%s: ignoring ARP from self", ifp->name);
+               logdebugx("%s: ignoring ARP from self", ifp->name);
 #endif
                return;
        }
@@ -180,7 +180,7 @@
 
        if ((state = ARP_STATE(ifp)) != NULL && state->fd != -1) {
                eloop_event_delete(ifp->ctx->eloop, state->fd);
-               bpf_close(state->fd);
+               bpf_close(ifp, state->fd);
                state->fd = -1;
        }
 }
@@ -202,7 +202,7 @@
        while (!(flags & BPF_EOF)) {
                bytes = bpf_read(ifp, state->fd, buf, sizeof(buf), &flags);
                if (bytes == -1) {
-                       syslog(LOG_ERR, "%s: arp bpf_read: %m", ifp->name);
+                       logerr("%s: %s", __func__, ifp->name);
                        arp_close(ifp);
                        return;
                }
@@ -222,7 +222,7 @@
        if (state->fd == -1) {
                state->fd = bpf_open(ifp, bpf_arp);
                if (state->fd == -1) {
-                       syslog(LOG_ERR, "%s: %s: %m", __func__, ifp->name);
+                       logerr("%s: %s", __func__, ifp->name);
                        return -1;
                }
                eloop_event_add(ifp->ctx->eloop, state->fd, arp_read, ifp);
@@ -256,13 +256,12 @@
                tv.tv_nsec = 0;
                eloop_timeout_add_tv(ifp->ctx->eloop, &tv, arp_probed, astate);
        }
-       syslog(LOG_DEBUG,
-           "%s: ARP probing %s (%d of %d), next in %0.1f seconds",
+       logdebugx("%s: ARP probing %s (%d of %d), next in %0.1f seconds",
            ifp->name, inet_ntoa(astate->addr),
            astate->probes ? astate->probes : PROBE_NUM, PROBE_NUM,
            timespec_to_double(&tv));
        if (arp_request(ifp, 0, astate->addr.s_addr) == -1)
-               syslog(LOG_ERR, "send_arp: %m");
+               logerr(__func__);
 }
 
 void
@@ -270,15 +269,16 @@
 {
 
        if (arp_open(astate->iface) == -1) {
-               syslog(LOG_ERR, "%s: %s: %m", __func__, astate->iface->name);
+               logerr(__func__);
                return;
        } else {
                const struct iarp_state *state = ARP_CSTATE(astate->iface);
 
-               bpf_arp(astate->iface, state->fd);
+               if (bpf_arp(astate->iface, state->fd) == -1)
+                       logerr(__func__);
        }
        astate->probes = 0;
-       syslog(LOG_DEBUG, "%s: probing for %s",
+       logdebugx("%s: probing for %s",
            astate->iface->name, inet_ntoa(astate->addr));
        arp_probe1(astate);
 }
@@ -311,18 +311,16 @@
        astate->claims++;
 #else
        if (++astate->claims < ANNOUNCE_NUM)
-               syslog(LOG_DEBUG,
-                   "%s: ARP announcing %s (%d of %d), "
+               logdebugx("%s: ARP announcing %s (%d of %d), "
                    "next in %d.0 seconds",
                    ifp->name, inet_ntoa(astate->addr),
                    astate->claims, ANNOUNCE_NUM, ANNOUNCE_WAIT);
        else
-               syslog(LOG_DEBUG,
-                   "%s: ARP announcing %s (%d of %d)",
+               logdebugx("%s: ARP announcing %s (%d of %d)",
                    ifp->name, inet_ntoa(astate->addr),
                    astate->claims, ANNOUNCE_NUM);
        if (arp_request(ifp, astate->addr.s_addr, astate->addr.s_addr) == -1)
-               syslog(LOG_ERR, "arp_request: %m");
+               logerr(__func__);
 #endif
        eloop_timeout_add_sec(ifp->ctx->eloop, ANNOUNCE_WAIT,
            astate->claims < ANNOUNCE_NUM ? arp_announce1 : arp_announced,
@@ -335,7 +333,7 @@
 
 #ifndef KERNEL_RFC5227
        if (arp_open(astate->iface) == -1) {
-               syslog(LOG_ERR, "%s: %s: %m", __func__, astate->iface->name);
+               logerr(__func__);
                return;
        }
 #endif
@@ -352,13 +350,13 @@
        if (amsg != NULL) {
                char buf[HWADDR_LEN * 3];
 
-               syslog(LOG_ERR, "%s: hardware address %s claims %s",
+               logerrx("%s: hardware address %s claims %s",
                    astate->iface->name,
                    hwaddr_ntoa(amsg->sha, astate->iface->hwlen,
                    buf, sizeof(buf)),
                    inet_ntoa(astate->failed));
        } else
-               syslog(LOG_ERR, "%s: DAD detected %s",
+               logerrx("%s: DAD detected %s",
                    astate->iface->name, inet_ntoa(astate->failed));
 }
 
@@ -389,7 +387,7 @@
                ifp->if_data[IF_DATA_ARP] = malloc(sizeof(*state));
                state = ARP_STATE(ifp);
                if (state == NULL) {
-                       syslog(LOG_ERR, "%s: %m", __func__);
+                       logerr(__func__);
                        return NULL;
                }
                state->fd = -1;
@@ -400,7 +398,7 @@
        }
 
        if ((astate = calloc(1, sizeof(*astate))) == NULL) {
-               syslog(LOG_ERR, "%s: %s: %m", ifp->name, __func__);
+               logerr(__func__);
                return NULL;
        }
        astate->iface = ifp;
@@ -409,7 +407,8 @@
        state = ARP_STATE(ifp);
        TAILQ_INSERT_TAIL(&state->arp_states, astate, next);
 
-       bpf_arp(ifp, state->fd);
+       if (bpf_arp(ifp, state->fd) == -1)
+               logerr(__func__); /* try and continue */
 
        return astate;
 }
@@ -444,7 +443,8 @@
                free(state);
                ifp->if_data[IF_DATA_ARP] = NULL;
        } else
-               bpf_arp(ifp, state->fd);
+               if (bpf_arp(ifp, state->fd) == -1)
+                       logerr(__func__);
 }
 
 static void



Home | Main Index | Thread Index | Old Index