Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/roy]: src/external/bsd/dhcpcd/dist/src Update to dhcpcd-9.3.2 with the f...



details:   https://anonhg.NetBSD.org/src/rev/47a2059e9efb
branches:  roy
changeset: 941908:47a2059e9efb
user:      roy <roy%NetBSD.org@localhost>
date:      Sun Nov 01 14:23:02 2020 +0000

description:
Update to dhcpcd-9.3.2 with the following changes:

 * DHCP: Add support for IPv6-Only Preferred option, RFC 8925.
 * BSD: `LINK_STATE_UNKNOWN` is treated as UP once again
 * privsep: pass logging to the privileged actioneer
 * privsep: allow logfile re-opening to work
 * privsep: close BPF socket on ENXIO
 * privsep: don't leave a BOOTP BPF listener rebooting in non master mode

diffstat:

 external/bsd/dhcpcd/dist/src/defs.h            |    2 +-
 external/bsd/dhcpcd/dist/src/dhcp.c            |   89 ++++++++++++++++----
 external/bsd/dhcpcd/dist/src/dhcp.h            |    3 +
 external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c |    1 +
 external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h |    2 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.8.in       |   10 +--
 external/bsd/dhcpcd/dist/src/dhcpcd.c          |   14 ++-
 external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in  |   16 ++-
 external/bsd/dhcpcd/dist/src/dhcpcd.h          |    1 +
 external/bsd/dhcpcd/dist/src/if.c              |    6 +-
 external/bsd/dhcpcd/dist/src/logerr.c          |  110 +++++++++++++++++++++---
 external/bsd/dhcpcd/dist/src/logerr.h          |    9 +-
 12 files changed, 205 insertions(+), 58 deletions(-)

diffs (truncated from 579 to 300 lines):

diff -r e757946d5b33 -r 47a2059e9efb external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Mon Oct 12 14:07:55 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h       Sun Nov 01 14:23:02 2020 +0000
@@ -29,7 +29,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "9.3.1"
+#define VERSION                        "9.3.2"
 
 #ifndef PRIVSEP_USER
 # define PRIVSEP_USER          "_" PACKAGE
diff -r e757946d5b33 -r 47a2059e9efb external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c       Mon Oct 12 14:07:55 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c       Sun Nov 01 14:23:02 2020 +0000
@@ -1520,21 +1520,15 @@
 #endif
 }
 
-void
-dhcp_close(struct interface *ifp)
+static void
+dhcp_closebpf(struct interface *ifp)
 {
        struct dhcpcd_ctx *ctx = ifp->ctx;
        struct dhcp_state *state = D_STATE(ifp);
 
-       if (state == NULL)
-               return;
-
 #ifdef PRIVSEP
-       if (IN_PRIVSEP_SE(ctx)) {
+       if (IN_PRIVSEP_SE(ctx))
                ps_bpf_closebootp(ifp);
-               if (state->addr != NULL)
-                       ps_inet_closebootp(state->addr);
-       }
 #endif
 
        if (state->bpf != NULL) {
@@ -1542,11 +1536,38 @@
                bpf_close(state->bpf);
                state->bpf = NULL;
        }
+}
+
+static void
+dhcp_closeinet(struct interface *ifp)
+{
+       struct dhcpcd_ctx *ctx = ifp->ctx;
+       struct dhcp_state *state = D_STATE(ifp);
+
+#ifdef PRIVSEP
+       if (IN_PRIVSEP_SE(ctx)) {
+               if (state->addr != NULL)
+                       ps_inet_closebootp(state->addr);
+       }
+#endif
+
        if (state->udp_rfd != -1) {
                eloop_event_delete(ctx->eloop, state->udp_rfd);
                close(state->udp_rfd);
                state->udp_rfd = -1;
        }
+}
+
+void
+dhcp_close(struct interface *ifp)
+{
+       struct dhcp_state *state = D_STATE(ifp);
+
+       if (state == NULL)
+               return;
+
+       dhcp_closebpf(ifp);
+       dhcp_closeinet(ifp);
 
        state->interval = 0;
 }
@@ -2061,12 +2082,14 @@
 
 #ifdef ARP
 #ifdef KERNEL_RFC5227
+#ifdef ARPING
 static void
 dhcp_arp_announced(struct arp_state *state)
 {
 
        arp_free(state);
 }
+#endif
 #else
 static void
 dhcp_arp_defend_failed(struct arp_state *astate)
@@ -2321,23 +2344,24 @@
                        logerr("dhcp_writefile: %s", state->leasefile);
        }
 
+       old_state = state->added;
+
        /* Close the BPF filter as we can now receive DHCP messages
         * on a UDP socket. */
-       old_state = state->added;
-       if (ctx->options & DHCPCD_MASTER ||
-           state->old == NULL ||
-           state->old->yiaddr != state->new->yiaddr || old_state & STATE_FAKE)
-               dhcp_close(ifp);
-
+       dhcp_closebpf(ifp);
+
+       /* Add the address */
        ipv4_applyaddr(ifp);
 
        /* If not in master mode, open an address specific socket. */
        if (ctx->options & DHCPCD_MASTER ||
            (state->old != NULL &&
-           state->old->yiaddr == state->new->yiaddr &&
-           old_state & STATE_ADDED && !(old_state & STATE_FAKE)))
+            state->old->yiaddr == state->new->yiaddr &&
+            old_state & STATE_ADDED && !(old_state & STATE_FAKE)))
                return;
 
+       dhcp_closeinet(ifp);
+
 #ifdef PRIVSEP
        if (IN_PRIVSEP_SE(ctx)) {
                if (ps_inet_openbootp(state->addr) == -1)
@@ -2926,6 +2950,8 @@
        unsigned int i;
        char *msg;
        bool bootp_copied;
+       uint32_t v6only_time = 0;
+       bool use_v6only = false;
 #ifdef AUTH
        const uint8_t *auth;
        size_t auth_len;
@@ -3143,6 +3169,23 @@
                }
        }
 
+       if (has_option_mask(ifo->requestmask, DHO_IPV6_PREFERRED_ONLY)) {
+               if (get_option_uint32(ifp->ctx, &v6only_time, bootp, bootp_len,
+                   DHO_IPV6_PREFERRED_ONLY) == 0 &&
+                   (state->state == DHS_DISCOVER || state->state == DHS_REBOOT))
+               {
+                       char v6msg[128];
+
+                       use_v6only = true;
+                       if (v6only_time < MIN_V6ONLY_WAIT)
+                               v6only_time = MIN_V6ONLY_WAIT;
+                       snprintf(v6msg, sizeof(v6msg),
+                           "IPv6-Only Preferred received (%u seconds)",
+                           v6only_time);
+                       LOGDHCP(LOG_INFO, v6msg);
+               }
+       }
+
        /* DHCP Auto-Configure, RFC 2563 */
        if (type == DHCP_OFFER && bootp->yiaddr == 0) {
                LOGDHCP(LOG_WARNING, "no address given");
@@ -3177,12 +3220,22 @@
                        }
                        eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
                        eloop_timeout_add_sec(ifp->ctx->eloop,
-                           DHCP_MAX, dhcp_discover, ifp);
+                           use_v6only ? v6only_time : DHCP_MAX,
+                           dhcp_discover, ifp);
                }
 #endif
                return;
        }
 
+       if (use_v6only) {
+               dhcp_drop(ifp, "EXPIRE");
+               dhcp_unlink(ifp->ctx, state->leasefile);
+               eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
+               eloop_timeout_add_sec(ifp->ctx->eloop, v6only_time,
+                   dhcp_discover, ifp);
+               return;
+       }
+
        /* Ensure that the address offered is valid */
        if ((type == 0 || type == DHCP_OFFER || type == DHCP_ACK) &&
            (bootp->ciaddr == INADDR_ANY || bootp->ciaddr == INADDR_BROADCAST)
diff -r e757946d5b33 -r 47a2059e9efb external/bsd/dhcpcd/dist/src/dhcp.h
--- a/external/bsd/dhcpcd/dist/src/dhcp.h       Mon Oct 12 14:07:55 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.h       Sun Nov 01 14:23:02 2020 +0000
@@ -116,6 +116,7 @@
        DHO_RAPIDCOMMIT            = 80,  /* RFC 4039 */
        DHO_FQDN                   = 81,
        DHO_AUTHENTICATION         = 90,  /* RFC 3118 */
+       DHO_IPV6_PREFERRED_ONLY    = 108, /* RFC 8925 */
        DHO_AUTOCONFIGURE          = 116, /* RFC 2563 */
        DHO_DNSSEARCH              = 119, /* RFC 3397 */
        DHO_CSR                    = 121, /* RFC 3442 */
@@ -139,6 +140,8 @@
        FQDN_BOTH       = 0x31
 };
 
+#define        MIN_V6ONLY_WAIT         300 /* seconds, RFC 8925 */
+
 /* Sizes for BOOTP options */
 #define        BOOTP_CHADDR_LEN         16
 #define        BOOTP_SNAME_LEN          64
diff -r e757946d5b33 -r 47a2059e9efb external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c    Mon Oct 12 14:07:55 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c    Sun Nov 01 14:23:02 2020 +0000
@@ -234,6 +234,7 @@
 "embed uint16 country_code\n"
 "define 100 string posix_timezone\n"
 "define 101 string tzdb_timezone\n"
+"define 108 uint32 ipv6_only_preferred\n"
 "define 116 byte auto_configure\n"
 "define 117 array uint16 name_service_search\n"
 "define 118 ipaddress subnet_selection\n"
diff -r e757946d5b33 -r 47a2059e9efb external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h
--- a/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h    Mon Oct 12 14:07:55 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h    Sun Nov 01 14:23:02 2020 +0000
@@ -30,7 +30,7 @@
 #define INITDEFINENDS         6
 #define INITDEFINE6S         14
 #else
-#define INITDEFINES         124
+#define INITDEFINES         125
 #define INITDEFINENDS         7
 #define INITDEFINE6S         69
 #endif
diff -r e757946d5b33 -r 47a2059e9efb external/bsd/dhcpcd/dist/src/dhcpcd.8.in
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.8.in  Mon Oct 12 14:07:55 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.8.in  Sun Nov 01 14:23:02 2020 +0000
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd September 2, 2020
+.Dd October 30, 2020
 .Dt DHCPCD 8
 .Os
 .Sh NAME
@@ -846,13 +846,5 @@
 .Sh AUTHORS
 .An Roy Marples Aq Mt roy%marples.name@localhost
 .Sh BUGS
-If
-.Nm
-is running in a
-.Xr chroot 2
-then re-opening the
-.Fl Fl logfile
-from SIGUSR2 may not work.
-.Pp
 Please report them to
 .Lk http://roy.marples.name/projects/dhcpcd
diff -r e757946d5b33 -r 47a2059e9efb external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c     Mon Oct 12 14:07:55 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c     Sun Nov 01 14:23:02 2020 +0000
@@ -1422,10 +1422,15 @@
                return;
        case SIGUSR2:
                loginfox(sigmsg, "SIGUSR2", "reopening log");
-               /* XXX This may not work that well in a chroot */
-               logclose();
+#ifdef PRIVSEP
+               if (IN_PRIVSEP(ctx)) {
+                       if (ps_root_logreopen(ctx) == -1)
+                               logerr("ps_root_logreopen");
+                       return;
+               }
+#endif
                if (logopen(ctx->logfile) == -1)
-                       logerr(__func__);
+                       logerr("logopen");
                return;
        case SIGCHLD:
                while (waitpid(-1, NULL, WNOHANG) > 0)
@@ -1860,7 +1865,7 @@
        ctx.dhcp6_wfd = -1;
 #endif
 #ifdef PRIVSEP
-       ctx.ps_root_fd = ctx.ps_data_fd = -1;
+       ctx.ps_root_fd = ctx.ps_log_fd = ctx.ps_data_fd = -1;
        ctx.ps_inet_fd = ctx.ps_control_fd = -1;
        TAILQ_INIT(&ctx.ps_processes);
 #endif
@@ -2328,6 +2333,7 @@
        /* We have now forked, setsid, forked once more.
         * From this point on, we are the controlling daemon. */
        ctx.options |= DHCPCD_STARTED;
+       logdebugx("spawned master process on PID %d", getpid());
        if ((pid = pidfile_lock(ctx.pidfile)) != 0) {
                logerr("%s: pidfile_lock %d", __func__, pid);
 #ifdef PRIVSEP
diff -r e757946d5b33 -r 47a2059e9efb external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in     Mon Oct 12 14:07:55 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in     Sun Nov 01 14:23:02 2020 +0000
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd September 28, 2020



Home | Main Index | Thread Index | Old Index