CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Sat Nov 28 14:27:20 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.8.in dhcpcd.c if-options.c Log Message: Sync with dhcpcd-9.3.4 To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/external/bsd/dhcpcd/dist/src/dhcp.c cvs rdiff -u -r1.25 -r1.26 src/external/bsd/dhcpcd/dist/src/dhcp6.c cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in cvs rdiff -u -r1.46 -r1.47 src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.29 -r1.30 src/external/bsd/dhcpcd/dist/src/if-options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.43 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.44 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.43 Fri Nov 20 13:24:58 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Sat Nov 28 14:27:20 2020 @@ -2364,13 +2364,21 @@ dhcp_bind(struct interface *ifp) return; } + /* Add the address */ + if (ipv4_applyaddr(ifp) == NULL) { + /* There was an error adding the address. + * If we are in oneshot, exit with a failure. */ + if (ctx->options & DHCPCD_ONESHOT) { + loginfox("exiting due to oneshot"); + eloop_exit(ctx->eloop, EXIT_FAILURE); + } + return; + } + /* Close the BPF filter as we can now receive DHCP messages * on a UDP socket. */ dhcp_closebpf(ifp); - /* Add the address */ - ipv4_applyaddr(ifp); - openudp: /* If not in master mode, open an address specific socket. */ if (ctx->options & DHCPCD_MASTER || Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.25 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.26 --- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.25 Fri Nov 20 13:24:58 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp6.c Sat Nov 28 14:27:20 2020 @@ -2064,6 +2064,10 @@ dhcp6_checkstatusok(const struct interfa free(sbuf); state->lerror = code; errno = 0; + + if (code != 0 && ifp->ctx->options & DHCPCD_TEST) + eloop_exit(ifp->ctx->eloop, EXIT_FAILURE); + return (int)code; } Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.10 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.11 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.10 Fri Nov 20 13:24:58 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in Sat Nov 28 14:27:20 2020 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd November 3, 2020 +.Dd November 25, 2020 .Dt DHCPCD 8 .Os .Sh NAME @@ -264,18 +264,29 @@ Use this .Ar script instead of the default .Pa @SCRIPT@ . -.It Fl D , Fl Fl duid +.It Fl D , Fl Fl duid Op Ar ll | lt | uuid | value Use a DHCP Unique Identifier. If a system UUID is available, that will be used to create a DUID-UUID, otheriwse if persistent storage is available then a DUID-LLT (link local address + time) is generated, otherwise DUID-LL is generated (link local address). +The DUID type can be hinted as an optional parameter if the file +.Pa @DBDIR@/duid +does not exist. +If not +.Va ll , +.Va lt +or +.Va uuid +then +.Va value +will be converted from 00:11:22:33 format. This, plus the IAID will be used as the .Fl I , Fl Fl clientid . The DUID generated will be held in .Pa @DBDIR@/duid and should not be copied to other hosts. -This file also takes precedence over the above rules. +This file also takes precedence over the above rules except for setting a value. .It Fl d , Fl Fl debug Echo debug messages to the stderr and syslog. .It Fl E , Fl Fl lastlease @@ -747,7 +758,7 @@ This is the default behaviour and sets .Ev if_configured=true . .It Fl Fl noconfigure .Nm -will not configure the system add all. +will not configure the system at all. This is only of use if the .Fl Fl script that Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.46 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.47 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.46 Fri Nov 20 13:24:58 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Sat Nov 28 14:27:20 2020 @@ -841,13 +841,17 @@ dhcpcd_initduid(struct dhcpcd_ctx *ctx, { char buf[DUID_LEN * 3]; - if (ctx->duid != NULL) + if (ctx->duid != NULL) { + if (ifp == NULL) + goto log; return; + } duid_init(ctx, ifp); if (ctx->duid == NULL) return; +log: loginfox("DUID %s", hwaddr_ntoa(ctx->duid, ctx->duid_len, buf, sizeof(buf))); } @@ -991,17 +995,20 @@ void dhcpcd_activateinterface(struct interface *ifp, unsigned long long options) { - if (!ifp->active) { - ifp->active = IF_ACTIVE; - dhcpcd_initstate2(ifp, options); - /* It's possible we might not have been able to load - * a config. */ - if (ifp->active) { - configure_interface1(ifp); - run_preinit(ifp); -
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Sun Nov 1 14:24:01 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c dhcpcd.8.in dhcpcd.c logerr.c privsep.c Log Message: Sync with dhcpcd-9.3.2 To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/external/bsd/dhcpcd/dist/src/dhcp.c cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in cvs rdiff -u -r1.44 -r1.45 src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/logerr.c cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/privsep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.41 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.42 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.41 Mon Oct 12 14:09:03 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Sun Nov 1 14:24:01 2020 @@ -1520,21 +1520,15 @@ again: #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 @@ dhcp_close(struct interface *ifp) 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 @@ dhcp_addr_duplicated(struct interface *i #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 @@ dhcp_bind(struct interface *ifp) 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 @@ dhcp_handledhcp(struct interface *ifp, s 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 @@ dhcp_handledhcp(struct interface *ifp, s } } + if (has_option_mask(ifo->requestmask, DHO_IPV6_PREFERRED_ONLY)) { + if (get_option_uint32(ifp->ctx, _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 @@ dhcp_handledhcp(struct interface *ifp, s } 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
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Mon Oct 12 14:09:03 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.c if-bsd.c ipv6.c ipv6nd.c logerr.c privsep.c script.c Log Message: Sync withn dhcpcd-9.3.1 To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/external/bsd/dhcpcd/dist/src/dhcp.c cvs rdiff -u -r1.23 -r1.24 src/external/bsd/dhcpcd/dist/src/dhcp6.c cvs rdiff -u -r1.43 -r1.44 src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.24 -r1.25 src/external/bsd/dhcpcd/dist/src/if-bsd.c \ src/external/bsd/dhcpcd/dist/src/ipv6nd.c cvs rdiff -u -r1.14 -r1.15 src/external/bsd/dhcpcd/dist/src/ipv6.c cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/logerr.c cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/privsep.c cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/script.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.40 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.41 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.40 Mon Oct 5 16:02:15 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Mon Oct 12 14:09:03 2020 @@ -1712,7 +1712,7 @@ send_message(struct interface *ifp, uint if (callback == NULL) { /* No carrier? Don't bother sending the packet. */ - if (ifp->carrier <= LINK_DOWN) + if (!if_is_link_up(ifp)) return; logdebugx("%s: sending %s with xid 0x%x", ifp->name, @@ -1731,7 +1731,7 @@ send_message(struct interface *ifp, uint (arc4random_uniform(MSEC_PER_SEC * 2) - MSEC_PER_SEC); /* No carrier? Don't bother sending the packet. * However, we do need to advance the timeout. */ - if (ifp->carrier <= LINK_DOWN) + if (!if_is_link_up(ifp)) goto fail; logdebugx("%s: sending %s (xid 0x%x), next in %0.1f seconds", ifp->name, @@ -2633,7 +2633,7 @@ dhcp_reboot(struct interface *ifp) state->state = DHS_REBOOT; state->interval = 0; - if (ifo->options & DHCPCD_LINK && ifp->carrier <= LINK_DOWN) { + if (ifo->options & DHCPCD_LINK && !if_is_link_up(ifp)) { loginfox("%s: waiting for carrier", ifp->name); return; } @@ -2733,7 +2733,7 @@ dhcp_drop(struct interface *ifp, const c state->state = DHS_RELEASE; dhcp_unlink(ifp->ctx, state->leasefile); - if (ifp->carrier > LINK_DOWN && + if (if_is_link_up(ifp) && state->new != NULL && state->lease.server.s_addr != INADDR_ANY) { Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.23 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.24 --- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.23 Mon Oct 5 16:02:15 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp6.c Mon Oct 12 14:09:03 2020 @@ -1237,7 +1237,7 @@ dhcp6_sendmessage(struct interface *ifp, }; char uaddr[INET6_ADDRSTRLEN]; - if (!callback && ifp->carrier <= LINK_DOWN) + if (!callback && !if_is_link_up(ifp)) return 0; if (!IN6_IS_ADDR_UNSPECIFIED(>unicast)) { @@ -1298,7 +1298,7 @@ dhcp6_sendmessage(struct interface *ifp, + (unsigned int)((float)state->RT * ((float)lr / DHCP6_RAND_DIV)); - if (ifp->carrier > LINK_DOWN) + if (if_is_link_up(ifp)) logdebugx("%s: %s %s (xid 0x%02x%02x%02x)%s%s," " next in %0.1f seconds", ifp->name, @@ -1320,7 +1320,7 @@ dhcp6_sendmessage(struct interface *ifp, } } - if (ifp->carrier <= LINK_DOWN) + if (!if_is_link_up(ifp)) return 0; /* Update the elapsed time */ @@ -2906,7 +2906,7 @@ dhcp6_delegate_prefix(struct interface * if (ia->sla_len == 0) { /* no SLA configured, so lets * automate it */ - if (ifd->carrier != LINK_UP) { + if (!if_is_link_up(ifd)) { logdebugx( "%s: has no carrier, cannot" " delegate addresses", @@ -2922,7 +2922,7 @@ dhcp6_delegate_prefix(struct interface * sla = >sla[j]; if (strcmp(ifd->name, sla->ifname)) continue; - if (ifd->carrier != LINK_UP) { + if (!if_is_link_up(ifd)) { logdebugx( "%s: has no carrier, cannot" " delegate addresses", @@ -4029,7 +4029,7 @@ dhcp6_freedrop(struct interface *ifp, in if (drop && options & DHCPCD_RELEASE && state->state != DH6S_DELEGATED) { - if (ifp->carrier == LINK_UP && + if (if_is_link_up(ifp) && state->state != DH6S_RELEASED && state->state != DH6S_INFORMED) { Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.43 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.44 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.43 Mon Oct 5 16:02:15 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Mon Oct 12 14:09:03 2020 @@ -97,9 +97,6 @@ const int dhcpcd_signals_ignore[] = { const size_t dhcpcd_signals_ignore_len = __arraycount(dhcpcd_signals_ignore); #endif -#define
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Mon Oct 5 16:02:15 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcp6.c dhcpcd.c if-bsd.c if-options.c ipv6nd.c logerr.c privsep.c script.c Log Message: Sync with dhcpcd-9.3.0 To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/external/bsd/dhcpcd/dist/src/bpf.c cvs rdiff -u -r1.39 -r1.40 src/external/bsd/dhcpcd/dist/src/dhcp.c cvs rdiff -u -r1.22 -r1.23 src/external/bsd/dhcpcd/dist/src/dhcp6.c cvs rdiff -u -r1.42 -r1.43 src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.23 -r1.24 src/external/bsd/dhcpcd/dist/src/if-bsd.c \ src/external/bsd/dhcpcd/dist/src/ipv6nd.c cvs rdiff -u -r1.27 -r1.28 src/external/bsd/dhcpcd/dist/src/if-options.c cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/logerr.c cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/privsep.c cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/script.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/bpf.c diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.16 src/external/bsd/dhcpcd/dist/src/bpf.c:1.17 --- src/external/bsd/dhcpcd/dist/src/bpf.c:1.16 Mon Jun 15 16:59:05 2020 +++ src/external/bsd/dhcpcd/dist/src/bpf.c Mon Oct 5 16:02:15 2020 @@ -70,14 +70,14 @@ (insn)->jt = 0; \ (insn)->jf = 0; \ (insn)->k = (uint32_t)(v);\ -}; +} #define BPF_SET_JUMP(insn, c, v, t, f) { \ (insn)->code = (c); \ (insn)->jt = (t); \ (insn)->jf = (f); \ (insn)->k = (uint32_t)(v);\ -}; +} size_t bpf_frame_header_len(const struct interface *ifp) @@ -585,9 +585,6 @@ static const struct bpf_insn bpf_bootp_e }; #define BPF_BOOTP_ETHER_LEN __arraycount(bpf_bootp_ether) -#define BOOTP_MIN_SIZE sizeof(struct ip) + sizeof(struct udphdr) + \ -sizeof(struct bootp) - static const struct bpf_insn bpf_bootp_base[] = { /* Make sure it's an IPv4 packet. */ BPF_STMT(BPF_LD + BPF_B + BPF_IND, 0), Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.39 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.40 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.39 Sun Sep 6 14:55:34 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Mon Oct 5 16:02:15 2020 @@ -1164,7 +1164,7 @@ read_lease(struct interface *ifp, struct logdebugx("reading standard input"); sbytes = read(fileno(stdin), buf.buf, sizeof(buf.buf)); } else { - logdebugx("%s: reading lease `%s'", + logdebugx("%s: reading lease: %s", ifp->name, state->leasefile); sbytes = dhcp_readfile(ifp->ctx, state->leasefile, buf.buf, sizeof(buf.buf)); @@ -2314,7 +2314,7 @@ dhcp_bind(struct interface *ifp) state->state = DHS_BOUND; if (!state->lease.frominfo && !(ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC))) { - logdebugx("%s: writing lease `%s'", + logdebugx("%s: writing lease: %s", ifp->name, state->leasefile); if (dhcp_writefile(ifp->ctx, state->leasefile, 0640, state->new, state->new_len) == -1) @@ -2865,10 +2865,10 @@ log_dhcp(int loglevel, const char *msg, print_string(sname, sizeof(sname), OT_STRING | OT_DOMAIN, bootp->sname, sizeof(bootp->sname)); if (a == NULL) - logmessage(loglevel, "%s: %s %s %s `%s'", + logmessage(loglevel, "%s: %s %s %s %s", ifp->name, msg, tfrom, inet_ntoa(addr), sname); else - logmessage(loglevel, "%s: %s %s %s %s `%s'", + logmessage(loglevel, "%s: %s %s %s %s %s", ifp->name, msg, a, tfrom, inet_ntoa(addr), sname); } else { if (r != 0) { @@ -3477,6 +3477,16 @@ dhcp_packet(struct interface *ifp, uint8 #ifdef PRIVSEP const struct dhcp_state *state = D_CSTATE(ifp); + /* It's possible that an interface departs and arrives in short + * order to receive a BPF frame out of order. + * There is a similar check in ARP, but much lower down the stack. + * It's not needed for other inet protocols because we send the + * message as a whole and select the interface off that and then + * check state. BPF on the other hand is very interface + * specific and we do need this check. */ + if (state == NULL) + return; + /* Ignore double reads */ if (IN_PRIVSEP(ifp->ctx)) { switch (state->state) { Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.22 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.23 --- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.22 Thu Jul 2 13:59:19 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp6.c Mon Oct 5 16:02:15 2020 @@ -147,7 +147,7 @@ struct dhcp_compat { uint16_t dhcp6_opt; }; -const struct dhcp_compat dhcp_compats[] = { +static const struct dhcp_compat dhcp_compats[] = { { DHO_DNSSERVER, D6_OPTION_DNS_SERVERS }, { DHO_HOSTNAME, D6_OPTION_FQDN }, { DHO_DNSDOMAIN, D6_OPTION_FQDN }, @@ -2588,7 +2588,7 @@ dhcp6_readlease(struct interface *ifp, i logdebugx("reading
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Sun Sep 6 14:55:34 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c dhcpcd.8.in dhcpcd.c if-options.c ipv6.c ipv6nd.c logerr.c privsep.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/external/bsd/dhcpcd/dist/src/dhcp.c cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in \ src/external/bsd/dhcpcd/dist/src/logerr.c cvs rdiff -u -r1.41 -r1.42 src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.26 -r1.27 src/external/bsd/dhcpcd/dist/src/if-options.c cvs rdiff -u -r1.13 -r1.14 src/external/bsd/dhcpcd/dist/src/ipv6.c cvs rdiff -u -r1.22 -r1.23 src/external/bsd/dhcpcd/dist/src/ipv6nd.c cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/privsep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.38 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.39 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.38 Thu Jun 4 13:08:13 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Sun Sep 6 14:55:34 2020 @@ -777,7 +777,7 @@ make_message(struct bootp **bootpm, cons (type == DHCP_REQUEST && state->addr->mask.s_addr == lease->mask.s_addr && (state->new == NULL || IS_DHCP(state->new)) && - !(state->added & STATE_FAKE + !(state->added & (STATE_FAKE | STATE_EXPIRED) bootp->ciaddr = state->addr->addr.s_addr; bootp->op = BOOTREQUEST; @@ -836,7 +836,7 @@ make_message(struct bootp **bootpm, cons if (type == DHCP_DECLINE || (type == DHCP_REQUEST && (state->addr == NULL || - state->added & STATE_FAKE || + state->added & (STATE_FAKE | STATE_EXPIRED) || lease->addr.s_addr != state->addr->addr.s_addr))) { putip = true; @@ -1745,7 +1745,7 @@ send_message(struct interface *ifp, uint goto fail; len = (size_t)r; - if (!(state->added & STATE_FAKE) && + if (!(state->added & (STATE_FAKE | STATE_EXPIRED)) && state->addr != NULL && ipv4_iffindaddr(ifp, >lease.addr, NULL) != NULL) from.s_addr = state->lease.addr.s_addr; @@ -1869,14 +1869,16 @@ dhcp_discover(void *arg) state->state = DHS_DISCOVER; dhcp_new_xid(ifp); eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); - if (ifo->fallback) - eloop_timeout_add_sec(ifp->ctx->eloop, - ifo->reboot, dhcp_fallback, ifp); + if (!(state->added & STATE_EXPIRED)) { + if (ifo->fallback) + eloop_timeout_add_sec(ifp->ctx->eloop, + ifo->reboot, dhcp_fallback, ifp); #ifdef IPV4LL - else if (ifo->options & DHCPCD_IPV4LL) - eloop_timeout_add_sec(ifp->ctx->eloop, - ifo->reboot, ipv4ll_start, ifp); + else if (ifo->options & DHCPCD_IPV4LL) + eloop_timeout_add_sec(ifp->ctx->eloop, + ifo->reboot, ipv4ll_start, ifp); #endif + } if (ifo->options & DHCPCD_REQUEST) loginfox("%s: soliciting a DHCP lease (requesting %s)", ifp->name, inet_ntoa(ifo->req_addr)); @@ -1897,30 +1899,21 @@ dhcp_request(void *arg) } static void -dhcp_expire1(struct interface *ifp) -{ - struct dhcp_state *state = D_STATE(ifp); - - eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); - dhcp_drop(ifp, "EXPIRE"); - dhcp_unlink(ifp->ctx, state->leasefile); - state->interval = 0; - if (!(ifp->options->options & DHCPCD_LINK) || ifp->carrier > LINK_DOWN) - dhcp_discover(ifp); -} - -static void dhcp_expire(void *arg) { struct interface *ifp = arg; + struct dhcp_state *state = D_STATE(ifp); if (ifp->options->options & DHCPCD_LASTLEASE_EXTEND) { logwarnx("%s: DHCP lease expired, extending lease", ifp->name); - return; + state->added |= STATE_EXPIRED; + } else { + logerrx("%s: DHCP lease expired", ifp->name); + dhcp_drop(ifp, "EXPIRE"); + dhcp_unlink(ifp->ctx, state->leasefile); } - - logerrx("%s: DHCP lease expired", ifp->name); - dhcp_expire1(ifp); + state->interval = 0; + dhcp_discover(ifp); } #if defined(ARP) || defined(IN_IFF_DUPLICATED) @@ -2291,7 +2284,9 @@ dhcp_bind(struct interface *ifp) return; } if (state->reason == NULL) { - if (state->old && !(state->added & STATE_FAKE)) { + if (state->old && + !(state->added & (STATE_FAKE | STATE_EXPIRED))) + { if (state->old->yiaddr == state->new->yiaddr && lease->server.s_addr && state->state != DHS_REBIND) @@ -2364,19 +2359,6 @@ dhcp_bind(struct interface *ifp) eloop_event_add(ctx->eloop, state->udp_rfd, dhcp_handleifudp, ifp); } -static void -dhcp_lastlease(void *arg) -{ - struct interface *ifp = arg; - struct dhcp_state *state = D_STATE(ifp); - - loginfox("%s: timed out contacting a DHCP server, using last lease", - ifp->name); - dhcp_bind(ifp); - state->interval = 0; - dhcp_discover(ifp); -} - static size_t dhcp_message_new(struct bootp **bootp, const struct in_addr *addr, const struct in_addr *mask) @@ -2476,6 +2458,26 @@ dhcp_arp_bind(struct interface
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Fri Jul 3 10:46:45 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcpcd.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/external/bsd/dhcpcd/dist/src/dhcpcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.40 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.41 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.40 Thu Jul 2 13:59:19 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Fri Jul 3 10:46:45 2020 @@ -2186,6 +2186,8 @@ printpidfile: if (!(ctx.options & DHCPCD_TEST)) { /* Ensure we have the needed directories */ + if (mkdir(DBDIR, 0750) == -1 && errno != EEXIST) + logerr("%s: mkdir `%s'", __func__, DBDIR); if (mkdir(RUNDIR, 0755) == -1 && errno != EEXIST) logerr("%s: mkdir `%s'", __func__, RUNDIR); if ((pid = pidfile_lock(ctx.pidfile)) != 0) { @@ -2284,13 +2286,6 @@ printpidfile: } } - /* If we're not running in privsep, we need to create the DB - * directory here. */ - if (!(ctx.options & DHCPCD_PRIVSEP)) { - if (mkdir(DBDIR, 0755) == -1 && errno != EEXIST) - logerr("%s: mkdir `%s'", __func__, DBDIR); - } - #ifdef PRIVSEP if (IN_PRIVSEP() && ps_start() == -1) { logerr("ps_start");
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Thu Jul 2 17:15:00 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: logerr.c Log Message: dhcpcd: Fix SMALL build To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/logerr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/logerr.c diff -u src/external/bsd/dhcpcd/dist/src/logerr.c:1.6 src/external/bsd/dhcpcd/dist/src/logerr.c:1.7 --- src/external/bsd/dhcpcd/dist/src/logerr.c:1.6 Thu Jul 2 13:59:19 2020 +++ src/external/bsd/dhcpcd/dist/src/logerr.c Thu Jul 2 17:15:00 2020 @@ -117,16 +117,15 @@ logprintdate(FILE *stream) __printflike(3, 0) static int vlogprintf_r(struct logctx *ctx, FILE *stream, const char *fmt, va_list args) { - FILE *err; int len = 0, e; va_list a; #ifndef SMALL + FILE *err = ctx->log_err == NULL ? stderr : ctx->log_err; bool log_pid; #ifdef LOGERR_TAG bool log_tag; #endif - err = ctx->log_err == NULL ? stderr : ctx->log_err; if ((stream == err && ctx->log_opts & LOGERR_ERR_DATE) || (stream != err && ctx->log_opts & LOGERR_LOG_DATE)) {
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Thu Jul 2 13:59:19 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp6.c dhcpcd.c if-bsd.c if-options.c ipv6.c ipv6.h ipv6nd.c logerr.c privsep.c script.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/external/bsd/dhcpcd/dist/src/dhcp6.c \ src/external/bsd/dhcpcd/dist/src/ipv6nd.c cvs rdiff -u -r1.39 -r1.40 src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.22 -r1.23 src/external/bsd/dhcpcd/dist/src/if-bsd.c cvs rdiff -u -r1.25 -r1.26 src/external/bsd/dhcpcd/dist/src/if-options.c cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/src/ipv6.c cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/src/ipv6.h cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcpcd/dist/src/logerr.c \ src/external/bsd/dhcpcd/dist/src/privsep.c cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/script.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.21 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.22 --- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.21 Mon Jun 15 16:59:05 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp6.c Thu Jul 2 13:59:19 2020 @@ -3183,14 +3183,12 @@ dhcp6_bind(struct interface *ifp, const state->state = DH6S_BOUND; state->failed = false; - if ((state->renew != 0 || state->rebind != 0) && - state->renew != ND6_INFINITE_LIFETIME) + if (state->renew && state->renew != ND6_INFINITE_LIFETIME) eloop_timeout_add_sec(ifp->ctx->eloop, state->renew, state->state == DH6S_INFORMED ? dhcp6_startinform : dhcp6_startrenew, ifp); - if ((state->rebind != 0 || state->expire != 0) && - state->rebind != ND6_INFINITE_LIFETIME) + if (state->rebind && state->rebind != ND6_INFINITE_LIFETIME) eloop_timeout_add_sec(ifp->ctx->eloop, state->rebind, dhcp6_startrebind, ifp); if (state->expire != ND6_INFINITE_LIFETIME) Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.21 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.22 --- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.21 Mon Jun 15 16:59:05 2020 +++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c Thu Jul 2 13:59:19 2020 @@ -61,6 +61,16 @@ /* Debugging Router Solicitations is a lot of spam, so disable it */ //#define DEBUG_RS +#ifndef ND_RA_FLAG_HOME_AGENT +#define ND_RA_FLAG_HOME_AGENT 0x20 /* Home Agent flag in RA */ +#endif +#ifndef ND_RA_FLAG_PROXY +#define ND_RA_FLAG_PROXY 0x04 /* Proxy */ +#endif +#ifndef ND_OPT_PI_FLAG_ROUTER +#define ND_OPT_PI_FLAG_ROUTER 0x20 /* Router flag in PI */ +#endif + #ifndef ND_OPT_RDNSS #define ND_OPT_RDNSS 25 struct nd_opt_rdnss { /* RDNSS option RFC 6106 */ @@ -1096,6 +1106,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, uint32_t old_lifetime; int ifmtu; int loglevel; + unsigned int flags; #ifdef IPV6_MANAGETEMPADDR bool new_ia; #endif @@ -1299,13 +1310,15 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, case ND_OPT_PREFIX_INFORMATION: loglevel = new_data ? LOG_ERR : LOG_DEBUG; if (ndo.nd_opt_len != 4) { -logmessage(loglevel, "%s: invalid option len for prefix", +logmessage(loglevel, +"%s: invalid option len for prefix", ifp->name); continue; } memcpy(, p, sizeof(pi)); if (pi.nd_opt_pi_prefix_len > 128) { -logmessage(loglevel, "%s: invalid prefix len", ifp->name); +logmessage(loglevel, "%s: invalid prefix len", +ifp->name); continue; } /* nd_opt_pi_prefix is not aligned. */ @@ -1314,27 +1327,33 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, if (IN6_IS_ADDR_MULTICAST(_prefix) || IN6_IS_ADDR_LINKLOCAL(_prefix)) { -logmessage(loglevel, "%s: invalid prefix in RA", ifp->name); +logmessage(loglevel, "%s: invalid prefix in RA", +ifp->name); continue; } if (ntohl(pi.nd_opt_pi_preferred_time) > ntohl(pi.nd_opt_pi_valid_time)) { -logmessage(loglevel, "%s: pltime > vltime", ifp->name); +logmessage(loglevel, "%s: pltime > vltime", +ifp->name); continue; } + + flags = IPV6_AF_RAPFX; + /* If no flags are set, that means the prefix is + * available via the router. */ + if (pi.nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK) +flags |= IPV6_AF_ONLINK; + if (pi.nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO && + rap->iface->options->options & + DHCPCD_IPV6RA_AUTOCONF) +flags |= IPV6_AF_AUTOCONF; + if (pi.nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ROUTER) +flags |= IPV6_AF_ROUTER; + ia = ipv6nd_rapfindprefix(rap, _prefix, pi.nd_opt_pi_prefix_len); if (ia == NULL) { -unsigned int flags; - -flags = IPV6_AF_RAPFX; -if (pi.nd_opt_pi_flags_reserved & -ND_OPT_PI_FLAG_AUTO && -
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Mon Jun 15 16:59:05 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: bpf.c dhcp6.c dhcpcd.c if-bsd.c if-options.c ipv6nd.c logerr.c privsep.c script.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/src/bpf.c cvs rdiff -u -r1.20 -r1.21 src/external/bsd/dhcpcd/dist/src/dhcp6.c \ src/external/bsd/dhcpcd/dist/src/ipv6nd.c cvs rdiff -u -r1.38 -r1.39 src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.21 -r1.22 src/external/bsd/dhcpcd/dist/src/if-bsd.c cvs rdiff -u -r1.24 -r1.25 src/external/bsd/dhcpcd/dist/src/if-options.c cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/src/logerr.c \ src/external/bsd/dhcpcd/dist/src/privsep.c cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/script.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/bpf.c diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.15 src/external/bsd/dhcpcd/dist/src/bpf.c:1.16 --- src/external/bsd/dhcpcd/dist/src/bpf.c:1.15 Sun May 31 12:52:11 2020 +++ src/external/bsd/dhcpcd/dist/src/bpf.c Mon Jun 15 16:59:05 2020 @@ -703,6 +703,14 @@ bpf_bootp(const struct bpf *bpf, __unuse return -1; return 0; #else +#ifdef PRIVSEP +#if defined(__sun) /* Solaris cannot send via BPF. */ +#elif defined(BIOCSETF) +#warning No BIOCSETWF support - a compromised BPF can be used as a raw socket +#else +#warning A compromised PF_PACKET socket can be used as a raw socket +#endif +#endif return bpf_bootp_rw(bpf, true); #endif } Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.20 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.21 --- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.20 Thu Jun 4 13:08:13 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp6.c Mon Jun 15 16:59:05 2020 @@ -541,12 +541,12 @@ dhcp6_delegateaddr(struct in6_addr *addr state->reason = "DELEGATED6"; } - if (sla == NULL || sla->sla_set == 0) { + if (sla == NULL || !sla->sla_set) { /* No SLA set, so make an assumption of * desired SLA and prefix length. */ asla.sla = ifp->index; asla.prefix_len = 0; - asla.sla_set = 0; + asla.sla_set = false; sla = } else if (sla->prefix_len == 0) { /* An SLA was given, but prefix length was not. @@ -554,7 +554,7 @@ dhcp6_delegateaddr(struct in6_addr *addr * potentially more than one interface. */ asla.sla = sla->sla; asla.prefix_len = 0; - asla.sla_set = 0; + asla.sla_set = sla->sla_set; sla = } @@ -562,16 +562,15 @@ dhcp6_delegateaddr(struct in6_addr *addr uint32_t sla_max; int bits; - if (ia->sla_max == 0) { + sla_max = ia->sla_max; + if (sla_max == 0 && (sla == NULL || !sla->sla_set)) { const struct interface *ifi; - sla_max = 0; TAILQ_FOREACH(ifi, ifp->ctx->ifaces, next) { if (ifi->index > sla_max) sla_max = ifi->index; } - } else - sla_max = ia->sla_max; + } bits = fls32(sla_max); @@ -1727,6 +1726,7 @@ dhcp6_fail(struct interface *ifp) if (state->old != NULL) script_runreason(ifp, "EXPIRE6"); dhcp_unlink(ifp->ctx, state->leasefile); + dhcp6_addrequestedaddrs(ifp); } if (!dhcp6_startdiscoinform(ifp)) { @@ -2672,6 +2672,7 @@ ex: free(state->new); state->new = NULL; state->new_len = 0; + dhcp6_addrequestedaddrs(ifp); return bytes == 0 ? 0 : -1; } Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.20 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.21 --- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.20 Sun May 31 12:52:11 2020 +++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c Mon Jun 15 16:59:05 2020 @@ -1100,7 +1100,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, bool new_ia; #endif - if (ifp == NULL) { + if (ifp == NULL || RS_STATE(ifp) == NULL) { #ifdef DEBUG_RS logdebugx("RA for unexpected interface from %s", sfrom); #endif @@ -1155,10 +1155,8 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, if (ifp == rap->iface) break; } - if (rap != NULL && rap->willexpire) { - logerrx("settng def RA"); + if (rap != NULL && rap->willexpire) ipv6nd_applyra(ifp); - } #endif TAILQ_FOREACH(rap, ctx->ra_routers, next) { Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.38 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.39 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.38 Thu Jun 4 13:08:13 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Mon Jun 15 16:59:05 2020 @@ -943,9 +943,12 @@ dhcpcd_startinterface(void *arg) } #ifdef DHCP6 - if (ifo->options & DHCPCD_DHCP6) { + /* DHCPv6 could be turned off, but the interface + * is still delegated to. */ + if (ifp->active) dhcp6_find_delegates(ifp); + if (ifo->options & DHCPCD_DHCP6) { if (ifp->active == IF_ACTIVE_USER) { enum DH6S d6_state;
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Thu Jun 4 13:08:13 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.8.in dhcpcd.c if-bsd.c privsep.c script.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/external/bsd/dhcpcd/dist/src/dhcp.c \ src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.19 -r1.20 src/external/bsd/dhcpcd/dist/src/dhcp6.c cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in \ src/external/bsd/dhcpcd/dist/src/script.c cvs rdiff -u -r1.20 -r1.21 src/external/bsd/dhcpcd/dist/src/if-bsd.c cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcpcd/dist/src/privsep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.37 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.38 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.37 Sun May 31 12:52:11 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Thu Jun 4 13:08:13 2020 @@ -1034,7 +1034,7 @@ make_message(struct bootp **bootpm, cons auth = NULL; /* appease GCC */ auth_len = 0; if (ifo->auth.options & DHCPCD_AUTH_SEND) { - ssize_t alen = dhcp_auth_encode(>auth, + ssize_t alen = dhcp_auth_encode(ifp->ctx, >auth, state->auth.token, NULL, 0, 4, type, NULL, 0); if (alen != -1 && alen > UINT8_MAX) { @@ -1129,7 +1129,7 @@ make_message(struct bootp **bootpm, cons #ifdef AUTH if (ifo->auth.options & DHCPCD_AUTH_SEND && auth_len != 0) - dhcp_auth_encode(>auth, state->auth.token, + dhcp_auth_encode(ifp->ctx, >auth, state->auth.token, (uint8_t *)bootp, len, 4, type, auth, auth_len); #endif @@ -2747,6 +2747,18 @@ dhcp_drop(struct interface *ifp, const c #endif } } +#ifdef AUTH + else if (state->auth.reconf != NULL) { + /* + * Drop the lease as the token may only be present + * in the initial reply message and not subsequent + * renewals. + * If dhcpcd is restarted, the token is lost. + * XXX persist this in another file? + */ + dhcp_unlink(ifp->ctx, state->leasefile); + } +#endif eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); #ifdef AUTH @@ -4176,3 +4188,24 @@ dhcp_handleifa(int cmd, struct ipv4_addr return ia; } + +#ifndef SMALL +int +dhcp_dump(struct interface *ifp) +{ + struct dhcp_state *state; + + ifp->if_data[IF_DATA_DHCP] = state = calloc(1, sizeof(*state)); + if (state == NULL) { + logerr(__func__); + return -1; + } + state->new_len = read_lease(ifp, >new); + if (state->new == NULL) { + logerr("read_lease"); + return -1; + } + state->reason = "DUMP"; + return script_runreason(ifp, state->reason); +} +#endif Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.37 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.38 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.37 Sun May 31 12:52:11 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Thu Jun 4 13:08:13 2020 @@ -29,6 +29,7 @@ const char dhcpcd_copyright[] = "Copyright (c) 2006-2020 Roy Marples"; #include +#include #include #include #include @@ -86,6 +87,7 @@ const int dhcpcd_signals[] = { SIGHUP, SIGUSR1, SIGUSR2, + SIGCHLD, }; const size_t dhcpcd_signals_len = __arraycount(dhcpcd_signals); @@ -1340,6 +1342,9 @@ stop_all_interfaces(struct dhcpcd_ctx *c struct interface *ifp; ctx->options |= DHCPCD_EXITING; + if (ctx->ifaces == NULL) + return; + /* Drop the last interface first */ TAILQ_FOREACH_REVERSE(ifp, ctx->ifaces, if_head, next) { if (!ifp->active) @@ -1395,7 +1400,7 @@ dhcpcd_signal_cb(int sig, void *arg) unsigned long long opts; int exit_code; - if (ctx->options & DHCPCD_FORKED) { + if (sig != SIGCHLD && ctx->options & DHCPCD_FORKED) { pid_t pid = pidfile_read(ctx->pidfile); if (pid == -1) { if (errno != ENOENT) @@ -1441,6 +1446,10 @@ dhcpcd_signal_cb(int sig, void *arg) if (logopen(ctx->logfile) == -1) logerr(__func__); return; + case SIGCHLD: + while (waitpid(-1, NULL, WNOHANG) > 0) + ; + return; default: logerrx("received signal %d but don't know what to do with it", sig); @@ -1663,20 +1672,13 @@ dumperr: return 0; } -static const char *dumpskip[] = { - "PATH=", - "pid=", - "chroot=", -}; - static int dhcpcd_readdump(struct dhcpcd_ctx *ctx) { int error = 0; - size_t nifaces, buflen = 0, dlen, i; + size_t nifaces, buflen = 0, dlen; ssize_t len; - char *buf = NULL, *dp, *de; - const char *skip; + char *buf = NULL; again1: len = read(ctx->control_fd, , sizeof(nifaces)); @@ -1723,26 +1725,7 @@ again3: error = -1; goto out; } - dp = buf; - de = dp + dlen; - if (*(de - 1) != '\0') { - errno = EINVAL; - error = -1; - goto out; - } - while (dp < de) { - for (i = 0; i < __arraycount(dumpskip); i++) { -skip = dumpskip[i]; -if (strncmp(dp, skip, strlen(skip)) == 0) -
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: christos Date: Sun May 10 17:58:16 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcpcd.c Log Message: Add SIGPIPE to the list of dhcpcd affected signals since we sigignore it. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/external/bsd/dhcpcd/dist/src/dhcpcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.35 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.36 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.35 Tue Apr 21 05:55:33 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Sun May 10 13:58:16 2020 @@ -80,6 +80,7 @@ const int dhcpcd_signals[] = { SIGTERM, SIGINT, SIGALRM, + SIGPIPE, SIGHUP, SIGUSR1, SIGUSR2,
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Tue Apr 21 09:55:33 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.c if-bsd.c if-options.c ipv6.c ipv6nd.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/external/bsd/dhcpcd/dist/src/dhcp.c cvs rdiff -u -r1.17 -r1.18 src/external/bsd/dhcpcd/dist/src/dhcp6.c cvs rdiff -u -r1.34 -r1.35 src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.18 -r1.19 src/external/bsd/dhcpcd/dist/src/if-bsd.c \ src/external/bsd/dhcpcd/dist/src/ipv6nd.c cvs rdiff -u -r1.22 -r1.23 src/external/bsd/dhcpcd/dist/src/if-options.c cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/ipv6.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.35 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.36 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.35 Mon Apr 13 15:46:26 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Tue Apr 21 09:55:33 2020 @@ -3494,8 +3494,9 @@ dhcp_packet(struct interface *ifp, uint8 __func__, ifp->name); return; } - data += fl; len -= fl; + /* Move the data to avoid alignment errors. */ + memmove(data, data + fl, len); } /* Validate filter. */ @@ -3608,15 +3609,18 @@ dhcp_readudp(struct dhcpcd_ctx *ctx, str .iov_base = buf, .iov_len = sizeof(buf), }; + union { + struct cmsghdr hdr; #ifdef IP_RECVIF - unsigned char ctl[CMSG_SPACE(sizeof(struct sockaddr_dl))] = { 0 }; + uint8_t buf[CMSG_SPACE(sizeof(struct sockaddr_dl))]; #else - unsigned char ctl[CMSG_SPACE(sizeof(struct in_pktinfo))] = { 0 }; + uint8_t buf[CMSG_SPACE(sizeof(struct in_pktinfo))]; #endif + } cmsgbuf = { .buf = { 0 } }; struct msghdr msg = { .msg_name = , .msg_namelen = sizeof(from), .msg_iov = , .msg_iovlen = 1, - .msg_control = ctl, .msg_controllen = sizeof(ctl), + .msg_control = buf, .msg_controllen = sizeof(cmsgbuf.buf), }; int s; ssize_t bytes; Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.17 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.18 --- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.17 Mon Apr 13 15:46:26 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp6.c Tue Apr 21 09:55:33 2020 @@ -1585,6 +1585,7 @@ dhcp6_startdiscover(void *arg) { struct interface *ifp; struct dhcp6_state *state; + int llevel; ifp = arg; state = D6_STATE(ifp); @@ -1592,7 +1593,11 @@ dhcp6_startdiscover(void *arg) if (state->reason == NULL || strcmp(state->reason, "TIMEOUT6") != 0) dhcp6_delete_delegates(ifp); #endif - loginfox("%s: soliciting a DHCPv6 lease", ifp->name); + if (state->new == NULL && !state->failed) + llevel = LOG_INFO; + else + llevel = LOG_DEBUG; + logmessage(llevel, "%s: soliciting a DHCPv6 lease", ifp->name); state->state = DH6S_DISCOVER; state->RTC = 0; state->IMD = SOL_MAX_DELAY; @@ -1616,11 +1621,15 @@ dhcp6_startinform(void *arg) { struct interface *ifp; struct dhcp6_state *state; + int llevel; ifp = arg; state = D6_STATE(ifp); - if (state->new == NULL || ifp->options->options & DHCPCD_DEBUG) - loginfox("%s: requesting DHCPv6 information", ifp->name); + if (state->new == NULL && !state->failed) + llevel = LOG_INFO; + else + llevel = LOG_DEBUG; + logmessage(llevel, "%s: requesting DHCPv6 information", ifp->name); state->state = DH6S_INFORM; state->RTC = 0; state->IMD = INF_MAX_DELAY; @@ -1677,6 +1686,8 @@ dhcp6_fail(struct interface* ifp) { struct dhcp6_state *state = D6_STATE(ifp); + state->failed = true; + /* RFC3315 18.1.2 says that prior addresses SHOULD be used on failure. * RFC2131 3.2.3 says that MAY chose to use the prior address. * Because dhcpcd was written first for RFC2131, we have the LASTLEASE @@ -1711,33 +1722,43 @@ dhcp6_fail(struct interface* ifp) } } +static int +dhcp6_failloglevel(struct interface *ifp) +{ + const struct dhcp6_state *state = D6_CSTATE(ifp); + + return state->failed ? LOG_DEBUG : LOG_ERR; +} + static void dhcp6_failconfirm(void *arg) { - struct interface *ifp; + struct interface *ifp = arg; + int llevel = dhcp6_failloglevel(ifp); - ifp = arg; - logerrx("%s: failed to confirm prior address", ifp->name); + logmessage(llevel, "%s: failed to confirm prior DHCPv6 address", + ifp->name); dhcp6_fail(ifp); } static void dhcp6_failrequest(void *arg) { - struct interface *ifp; + struct interface *ifp = arg; + int llevel = dhcp6_failloglevel(ifp); - ifp = arg; - logerrx("%s: failed to request address", ifp->name); + logmessage(llevel, "%s: failed to request DHCPv6 address", ifp->name); dhcp6_fail(ifp); } static void dhcp6_failinform(void *arg) { - struct interface *ifp; + struct interface *ifp = arg; + int llevel = dhcp6_failloglevel(ifp); - ifp = arg; - logerrx("%s: failed to request
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Wed Apr 15 15:55:24 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: privsep.c Log Message: privsep: Redirect to /dev/null unless test or quiet and not debug Keeps the rtsol like behaviour the same. Fixes PR bin/55170 To generate a diff of this commit: cvs rdiff -u -r1.1.1.2 -r1.2 src/external/bsd/dhcpcd/dist/src/privsep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/privsep.c diff -u src/external/bsd/dhcpcd/dist/src/privsep.c:1.1.1.2 src/external/bsd/dhcpcd/dist/src/privsep.c:1.2 --- src/external/bsd/dhcpcd/dist/src/privsep.c:1.1.1.2 Mon Apr 13 15:42:21 2020 +++ src/external/bsd/dhcpcd/dist/src/privsep.c Wed Apr 15 15:55:24 2020 @@ -243,7 +243,9 @@ ps_dostart(struct dhcpcd_ctx *ctx, if (callback(recv_ctx) == -1) goto errexit; - if (!(ctx->options & (DHCPCD_TEST | DHCPCD_DEBUG))) { + if (!(ctx->options & DHCPCD_DEBUG) && + (!(ctx->options & DHCPCD_TEST) || loggetopts() & LOGERR_QUIET)) + { freopen(_PATH_DEVNULL, "w", stdout); freopen(_PATH_DEVNULL, "w", stderr); }
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Wed Apr 15 15:54:18 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcpcd.c Log Message: dhcpcd: Don't open a control socket in test mode Fixes PR bin/55170 To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/external/bsd/dhcpcd/dist/src/dhcpcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.33 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.34 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.33 Mon Apr 13 15:46:26 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Wed Apr 15 15:54:18 2020 @@ -2207,7 +2207,8 @@ printpidfile: goto run_loop; #endif - if (control_start(, + if (!(ctx.options & DHCPCD_TEST) && + control_start(, ctx.options & DHCPCD_MASTER ? NULL : argv[optind]) == -1) { logerr("%s: control_start", __func__);
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: christos Date: Sun Apr 5 15:41:45 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: script.c Log Message: Don't block signals when running hooks. Here ctx->sigset == defsigs == 0x60006003, which blocks SIGTERM by default, so running something simple from a hook, like /etc/rc.d/racoon restart does not work. The script is then stuck waiting for the daemon to die, which it won't since it will never receive the signal, and the hook never terminates. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcpcd/dist/src/script.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/script.c diff -u src/external/bsd/dhcpcd/dist/src/script.c:1.3 src/external/bsd/dhcpcd/dist/src/script.c:1.4 --- src/external/bsd/dhcpcd/dist/src/script.c:1.3 Thu Apr 2 08:41:48 2020 +++ src/external/bsd/dhcpcd/dist/src/script.c Sun Apr 5 11:41:45 2020 @@ -108,7 +108,8 @@ script_exec(const struct dhcpcd_ctx *ctx for (i = 0; i < dhcpcd_signals_len; i++) sigaddset(, dhcpcd_signals[i]); posix_spawnattr_setsigdefault(, ); - posix_spawnattr_setsigmask(, >sigset); + sigemptyset(); + posix_spawnattr_setsigmask(, ); #endif errno = 0; r = posix_spawn(, argv[0], NULL, , argv, env);
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: fox Date: Sat Feb 8 12:17:16 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c Log Message: external/bsd/dhcpcd: Fix a -Wconversion warning. Type cast uint16_t to size_t to prevent implicit type conversion. Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag. gcc version 8.3.0 Reviewed by: roy@, kamil@ To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/external/bsd/dhcpcd/dist/src/dhcp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.32 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.33 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.32 Mon Jan 27 20:42:56 2020 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Sat Feb 8 12:17:16 2020 @@ -3307,7 +3307,7 @@ is_packet_udp_bootp(void *packet, size_t memcpy(, (char *)ip + ip_hlen, sizeof(udp)); if (ntohs(udp.uh_ulen) < sizeof(udp)) return false; - if (ip_hlen + ntohs(udp.uh_ulen) > plen) + if (ip_hlen + (size_t)ntohs(udp.uh_ulen) > plen) return false; /* Check it's to and from the right ports. */
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Mon Jan 27 20:42:57 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c if-bsd.c ipv6.c ipv6.h ipv6nd.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/external/bsd/dhcpcd/dist/src/dhcp.c cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/src/if-bsd.c \ src/external/bsd/dhcpcd/dist/src/ipv6nd.c cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/ipv6.c \ src/external/bsd/dhcpcd/dist/src/ipv6.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.31 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.32 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.31 Fri Dec 20 12:01:35 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Mon Jan 27 20:42:56 2020 @@ -2335,9 +2335,10 @@ dhcp_message_new(struct bootp **bootp, static void dhcp_arp_defend_failed(struct arp_state *astate) { + struct interface *ifp = astate->iface; - dhcp_drop(astate->iface, "EXPIRED"); - dhcp_start1(astate->iface); + dhcp_drop(ifp, "EXPIRED"); + dhcp_start1(ifp); } #endif Index: src/external/bsd/dhcpcd/dist/src/if-bsd.c diff -u src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.15 src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.16 --- src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.15 Wed Nov 13 10:50:22 2019 +++ src/external/bsd/dhcpcd/dist/src/if-bsd.c Mon Jan 27 20:42:56 2020 @@ -860,8 +860,6 @@ if_address(unsigned char cmd, const stru return r; } - - #if !(defined(HAVE_IFADDRS_ADDRFLAGS) && defined(HAVE_IFAM_ADDRFLAGS)) int if_addrflags(const struct interface *ifp, const struct in_addr *addr, @@ -1194,7 +1192,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const str { struct interface *ifp; const struct sockaddr *rti_info[RTAX_MAX]; - int addrflags; + int flags; pid_t pid; if (ifam->ifam_msglen < sizeof(*ifam)) { @@ -1216,9 +1214,6 @@ if_ifa(struct dhcpcd_ctx *ctx, const str pid = 0; #endif -#ifdef HAVE_IFAM_ADDRFLAGS - addrflags = ifam->ifam_addrflags; -#endif switch (rti_info[RTAX_IFA]->sa_family) { case AF_LINK: { @@ -1252,78 +1247,70 @@ if_ifa(struct dhcpcd_ctx *ctx, const str bcast.s_addr = sin != NULL && sin->sin_family == AF_INET ? sin->sin_addr.s_addr : INADDR_ANY; -#if defined(__NetBSD_Version__) && __NetBSD_Version__ < 8 /* * NetBSD-7 and older send an invalid broadcast address. * So we need to query the actual address to get * the right one. + * We can also use this to test if the address + * has really been added or deleted. */ - { -#else - /* - * If the address was deleted, lets check if it's - * a late message and it still exists (maybe modified). - * If so, ignore it as deleting an address causes - * dhcpcd to drop any lease to which it belongs. - */ - if (ifam->ifam_type == RTM_DELADDR) { -#endif #ifdef SIOCGIFALIAS - struct in_aliasreq ifra; + struct in_aliasreq ifra; - memset(, 0, sizeof(ifra)); - strlcpy(ifra.ifra_name, ifp->name, - sizeof(ifra.ifra_name)); - ifra.ifra_addr.sin_family = AF_INET; - ifra.ifra_addr.sin_len = sizeof(ifra.ifra_addr); - ifra.ifra_addr.sin_addr = addr; - if (ioctl(ctx->pf_inet_fd, SIOCGIFALIAS, ) == -1) { -if (errno != ENXIO && errno != EADDRNOTAVAIL) - logerr("%s: SIOCGIFALIAS", __func__); -if (ifam->ifam_type != RTM_DELADDR) - break; - } + memset(, 0, sizeof(ifra)); + strlcpy(ifra.ifra_name, ifp->name, sizeof(ifra.ifra_name)); + ifra.ifra_addr.sin_family = AF_INET; + ifra.ifra_addr.sin_len = sizeof(ifra.ifra_addr); + ifra.ifra_addr.sin_addr = addr; + if (ioctl(ctx->pf_inet_fd, SIOCGIFALIAS, ) == -1) { + if (errno != ENXIO && errno != EADDRNOTAVAIL) +logerr("%s: SIOCGIFALIAS", __func__); + if (ifam->ifam_type != RTM_DELADDR) +break; + } else { + if (ifam->ifam_type == RTM_DELADDR) +break; #if defined(__NetBSD_Version__) && __NetBSD_Version__ < 8 - else -bcast = ifra.ifra_broadaddr.sin_addr; + bcast = ifra.ifra_broadaddr.sin_addr; #endif + } #else #warning No SIOCGIFALIAS support - /* - * No SIOCGIFALIAS? That sucks! - * This makes this call very heavy weight, but we - * really need to know if the message is late or not. - */ - const struct sockaddr *sa; - struct ifaddrs *ifaddrs = NULL, *ifa; - - sa = rti_info[RTAX_IFA]; - getifaddrs(); - for (ifa = ifaddrs; ifa; ifa = ifa->ifa_next) { -if (ifa->ifa_addr == NULL) - continue; -if (sa_cmp(ifa->ifa_addr, sa) == 0 && -strcmp(ifa->ifa_name, ifp->name) == 0) - break; - } - freeifaddrs(ifaddrs); + /* + * No SIOCGIFALIAS? That sucks! + * This makes this call very heavy weight, but we + * really need to know if the message is late or not. + */ + const struct sockaddr *sa; + struct ifaddrs *ifaddrs = NULL, *ifa; + + sa =
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: christos Date: Sun Jan 26 22:57:52 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: script.c Log Message: prevent coredump when state == NULL To generate a diff of this commit: cvs rdiff -u -r1.1.1.12 -r1.2 src/external/bsd/dhcpcd/dist/src/script.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/script.c diff -u src/external/bsd/dhcpcd/dist/src/script.c:1.1.1.12 src/external/bsd/dhcpcd/dist/src/script.c:1.2 --- src/external/bsd/dhcpcd/dist/src/script.c:1.1.1.12 Wed Nov 13 05:49:20 2019 +++ src/external/bsd/dhcpcd/dist/src/script.c Sun Jan 26 17:57:52 2020 @@ -453,7 +453,7 @@ make_env(const struct interface *ifp, co dumplease: #ifdef INET #ifdef IPV4LL - if (protocol == PROTO_IPV4LL) { + if (protocol == PROTO_IPV4LL && istate) { if (ipv4ll_env(fp, istate->down ? "old" : "new", ifp) == -1) goto eexit; }
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Fri Jan 3 12:39:19 UTC 2020 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcpcd.c if-options.c ipv6nd.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.19 -r1.20 src/external/bsd/dhcpcd/dist/src/if-options.c cvs rdiff -u -r1.14 -r1.15 src/external/bsd/dhcpcd/dist/src/ipv6nd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.30 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.31 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.30 Fri Dec 20 12:01:35 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Fri Jan 3 12:39:18 2020 @@ -467,25 +467,11 @@ configure_interface1(struct interface *i if (!(ifo->options & (DHCPCD_INFORM | DHCPCD_WANTDHCP))) ifo->options |= DHCPCD_STATIC; } - if (!(ifo->options & DHCPCD_ARP) || - ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC)) - ifo->options &= ~DHCPCD_IPV4LL; if (ifo->metric != -1) ifp->metric = (unsigned int)ifo->metric; - if (!(ifo->options & DHCPCD_IPV4)) - ifo->options &= ~(DHCPCD_DHCP | DHCPCD_IPV4LL | DHCPCD_WAITIP4); - #ifdef INET6 - if (!(ifo->options & DHCPCD_IPV6)) - ifo->options &= - ~(DHCPCD_IPV6RS | DHCPCD_DHCP6 | DHCPCD_WAITIP6); - - if (!(ifo->options & DHCPCD_IPV6RS)) - ifo->options &= - ~(DHCPCD_IPV6RA_AUTOCONF | DHCPCD_IPV6RA_REQRDNSS); - /* We want to setup INET6 on the interface as soon as possible. */ if (ifp->active == IF_ACTIVE_USER && ifo->options & DHCPCD_IPV6 && Index: src/external/bsd/dhcpcd/dist/src/if-options.c diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.19 src/external/bsd/dhcpcd/dist/src/if-options.c:1.20 --- src/external/bsd/dhcpcd/dist/src/if-options.c:1.19 Fri Dec 20 22:24:59 2019 +++ src/external/bsd/dhcpcd/dist/src/if-options.c Fri Jan 3 12:39:18 2020 @@ -2231,6 +2231,21 @@ finish_config(struct if_options *ifo) * guard should suffice */ ifo->options |= DHCPCD_VENDORRAW; } + + if (!(ifo->options & DHCPCD_ARP) || + ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC)) + ifo->options &= ~DHCPCD_IPV4LL; + + if (!(ifo->options & DHCPCD_IPV4)) + ifo->options &= ~(DHCPCD_DHCP | DHCPCD_IPV4LL | DHCPCD_WAITIP4); + + if (!(ifo->options & DHCPCD_IPV6)) + ifo->options &= + ~(DHCPCD_IPV6RS | DHCPCD_DHCP6 | DHCPCD_WAITIP6); + + if (!(ifo->options & DHCPCD_IPV6RS)) + ifo->options &= + ~(DHCPCD_IPV6RA_AUTOCONF | DHCPCD_IPV6RA_REQRDNSS); } /* Handy routine to read very long lines in text files. Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.14 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.15 --- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.14 Fri Dec 20 12:01:36 2019 +++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c Fri Jan 3 12:39:18 2020 @@ -622,7 +622,7 @@ ipv6nd_applyra(struct dhcpcd_ctx *ctx, s return; state->retrans = rap->retrans; - if (if_applyra(rap) == -1) + if (if_applyra(rap) == -1 && errno != ENOENT) logerr(__func__); }
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Fri Dec 20 22:24:59 UTC 2019 Modified Files: src/external/bsd/dhcpcd/dist/src: if-options.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/external/bsd/dhcpcd/dist/src/if-options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/if-options.c diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.18 src/external/bsd/dhcpcd/dist/src/if-options.c:1.19 --- src/external/bsd/dhcpcd/dist/src/if-options.c:1.18 Fri Oct 11 11:03:59 2019 +++ src/external/bsd/dhcpcd/dist/src/if-options.c Fri Dec 20 22:24:59 2019 @@ -393,8 +393,16 @@ parse_str(char *sbuf, size_t slen, const str++; } } - if (flags == PARSE_STRING_NULL && sbuf) - *sbuf = '\0'; + if (flags == PARSE_STRING_NULL) { + l++; + if (sbuf != NULL) { + if (l > slen) { +errno = ENOBUFS; +return -1; + } + *sbuf = '\0'; + } + } return (ssize_t)l; }
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Sat May 4 09:42:16 UTC 2019 Modified Files: src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcp6.c dhcpcd.c if-bsd.c if-options.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/bpf.c cvs rdiff -u -r1.18 -r1.19 src/external/bsd/dhcpcd/dist/src/dhcp.c \ src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/dhcp6.c \ src/external/bsd/dhcpcd/dist/src/if-bsd.c cvs rdiff -u -r1.13 -r1.14 src/external/bsd/dhcpcd/dist/src/if-options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/bpf.c diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.8 src/external/bsd/dhcpcd/dist/src/bpf.c:1.9 --- src/external/bsd/dhcpcd/dist/src/bpf.c:1.8 Tue Jan 22 15:20:21 2019 +++ src/external/bsd/dhcpcd/dist/src/bpf.c Sat May 4 09:42:15 2019 @@ -301,6 +301,7 @@ bpf_close(struct interface *ifp, int fd) /* Normally this is needed by bootp. * Once that uses this again, the ARP guard here can be removed. */ #ifdef ARP +#define BPF_CMP_HWADDR_LEN HWADDR_LEN / 4) + 2) * 2) + 1) static unsigned int bpf_cmp_hwaddr(struct bpf_insn *bpf, size_t bpf_len, size_t off, bool equal, uint8_t *hwaddr, size_t hwaddr_len) @@ -414,7 +415,7 @@ static const struct bpf_insn bpf_arp_eth sizeof(((struct ether_arp *)0)->arp_sha), 1, 0), BPF_STMT(BPF_RET + BPF_K, 0), }; -#define bpf_arp_ether_len __arraycount(bpf_arp_ether) +#define BPF_ARP_ETHER_LEN __arraycount(bpf_arp_ether) static const struct bpf_insn bpf_arp_filter [] = { /* Make sure this is for IP. */ @@ -425,21 +426,25 @@ static const struct bpf_insn bpf_arp_fil BPF_STMT(BPF_LD + BPF_H + BPF_IND, offsetof(struct arphdr, ar_op)), BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ARPOP_REQUEST, 2, 0), /* or ARP REPLY. */ - BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ARPOP_REPLY, 1, 1), + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ARPOP_REPLY, 1, 0), BPF_STMT(BPF_RET + BPF_K, 0), /* Make sure the protocol length matches. */ BPF_STMT(BPF_LD + BPF_B + BPF_IND, offsetof(struct arphdr, ar_pln)), BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, sizeof(in_addr_t), 1, 0), BPF_STMT(BPF_RET + BPF_K, 0), }; -#define bpf_arp_filter_len __arraycount(bpf_arp_filter) -#define bpf_arp_extra ARP_ADDRS_MAX + 1) * 2) * 2) + 2) -#define bpf_arp_hw HWADDR_LEN / 4) + 2) * 2) + 1) +#define BPF_ARP_FILTER_LEN __arraycount(bpf_arp_filter) + +#define BPF_ARP_ADDRS_LEN 1 + (ARP_ADDRS_MAX * 2) + 3 + \ +(ARP_ADDRS_MAX * 2) + 1 + +#define BPF_ARP_LEN BPF_ARP_ETHER_LEN + BPF_ARP_FILTER_LEN + \ +BPF_CMP_HWADDR_LEN + BPF_ARP_ADDRS_LEN int bpf_arp(struct interface *ifp, int fd) { - struct bpf_insn bpf[3+ bpf_arp_filter_len + bpf_arp_hw + bpf_arp_extra]; + struct bpf_insn bpf[BPF_ARP_LEN]; struct bpf_insn *bp; struct iarp_state *state; uint16_t arp_len; @@ -452,7 +457,7 @@ bpf_arp(struct interface *ifp, int fd) switch(ifp->family) { case ARPHRD_ETHER: memcpy(bp, bpf_arp_ether, sizeof(bpf_arp_ether)); - bp += bpf_arp_ether_len; + bp += BPF_ARP_ETHER_LEN; arp_len = sizeof(struct ether_header)+sizeof(struct ether_arp); break; default: @@ -462,10 +467,10 @@ bpf_arp(struct interface *ifp, int fd) /* Copy in the main filter. */ memcpy(bp, bpf_arp_filter, sizeof(bpf_arp_filter)); - bp += bpf_arp_filter_len; + bp += BPF_ARP_FILTER_LEN; /* Ensure it's not from us. */ - bp += bpf_cmp_hwaddr(bp, bpf_arp_hw, sizeof(struct arphdr), + bp += bpf_cmp_hwaddr(bp, BPF_CMP_HWADDR_LEN, sizeof(struct arphdr), false, ifp->hwaddr, ifp->hwlen); state = ARP_STATE(ifp); Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.18 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.19 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.18 Fri Apr 26 14:34:10 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Sat May 4 09:42:15 2019 @@ -3499,9 +3499,14 @@ dhcp_readudp(struct dhcpcd_ctx *ctx, str logerr(__func__); return; } + if (D_CSTATE(ifp) == NULL) { + logdebugx("%s: received BOOTP for inactive interface", + ifp->name); + return; + } } - dhcp_handlebootp(ifp, (struct bootp *)buf, (size_t)bytes, + dhcp_handlebootp(ifp, (struct bootp *)(void *)buf, (size_t)bytes, _addr); #endif } Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.18 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.19 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.18 Wed Apr 17 23:35:34 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Sat May 4 09:42:15 2019 @@ -84,6 +84,9 @@ const int dhcpcd_signals[] = { const size_t dhcpcd_signals_len = __arraycount(dhcpcd_signals); #endif +#define IF_UPANDRUNNING(a) \ + (((a)->flags & (IFF_UP | IFF_RUNNING)) == (IFF_UP | IFF_RUNNING)) + static void
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Fri Apr 26 14:34:10 UTC 2019 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c if-bsd.c ipv6nd.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/external/bsd/dhcpcd/dist/src/dhcp.c cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcpcd/dist/src/dhcp6.c \ src/external/bsd/dhcpcd/dist/src/if-bsd.c \ src/external/bsd/dhcpcd/dist/src/ipv6nd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.17 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.18 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.17 Wed Apr 17 23:35:34 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Fri Apr 26 14:34:10 2019 @@ -215,6 +215,12 @@ get_option(struct dhcpcd_ctx *ctx, } l = *p++; + /* Check we can read the option data, if present */ + if (p + l > e) { + errno = EINVAL; + return NULL; + } + if (o == DHO_OPTSOVERLOADED) { /* Ensure we only get this option once by setting * the last bit as well as the value. @@ -249,10 +255,6 @@ get_option(struct dhcpcd_ctx *ctx, bp += ol; } ol = l; - if (p + ol >= e) { -errno = EINVAL; -return NULL; - } op = p; bl += ol; } @@ -2075,7 +2077,7 @@ dhcp_arp_probed(struct arp_state *astate ifp->name, inet_ntoa(astate->addr)); if (!(ifo->options & DHCPCD_INFORM)) dhcp_bind(ifp); -#ifndef IN_IFF_TENTATIVE +#ifndef IN_IFF_DUPLICATED else { struct bootp *bootp; size_t len; @@ -2429,7 +2431,7 @@ dhcp_arp_address(struct interface *ifp) if (astate == NULL) return -1; -#ifdef IN_IFF_TENTATIVE +#ifdef IN_IFF_NOTUSEABLE if (ia == NULL || ia->addr_flags & IN_IFF_NOTUSEABLE) { state->state = DHS_PROBE; if (ia == NULL) { Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.5 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.6 --- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.5 Wed Apr 17 23:35:34 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcp6.c Fri Apr 26 14:34:10 2019 @@ -2029,12 +2029,12 @@ dhcp6_findna(struct interface *ifp, uint nd = o + ol; l -= (size_t)(nd - d); d = nd; - if (ol < 24) { + if (ol < sizeof(ia)) { errno = EINVAL; logerrx("%s: IA Address option truncated", ifp->name); continue; } - memcpy(, o, ol); + memcpy(, o, sizeof(ia)); ia.pltime = ntohl(ia.pltime); ia.vltime = ntohl(ia.vltime); /* RFC 3315 22.6 */ @@ -3035,7 +3035,7 @@ dhcp6_bind(struct interface *ifp, const * unless those values in those fields are 0. */ logwarnx("%s: ignoring T1 %"PRIu32 -" to due address expiry", +" due to address expiry", ifp->name, state->renew); state->renew = state->rebind = 0; } Index: src/external/bsd/dhcpcd/dist/src/if-bsd.c diff -u src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.5 src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.6 --- src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.5 Wed Apr 17 23:35:34 2019 +++ src/external/bsd/dhcpcd/dist/src/if-bsd.c Fri Apr 26 14:34:10 2019 @@ -943,10 +943,15 @@ if_getlifetime6(struct ipv6_addr *ia) priv = (struct priv *)ia->iface->ctx->priv; if (ioctl(priv->pf_inet6_fd, SIOCGIFALIFETIME_IN6, ) == -1) return -1; + clock_gettime(CLOCK_MONOTONIC, >created); +#if defined(__FreeBSD__) || defined(__DragonFly__) + t = ia->created.tv_sec; +#else t = time(NULL); - lifetime = _ifru.ifru_lifetime; +#endif + lifetime = _ifru.ifru_lifetime; if (lifetime->ia6t_preferred) ia->prefix_pltime = (uint32_t)(lifetime->ia6t_preferred - MIN(t, lifetime->ia6t_preferred)); @@ -956,7 +961,6 @@ if_getlifetime6(struct ipv6_addr *ia) ia->prefix_vltime = (uint32_t)(lifetime->ia6t_expire - MIN(t, lifetime->ia6t_expire)); /* Calculate the created time */ - clock_gettime(CLOCK_MONOTONIC, >created); ia->created.tv_sec -= lifetime->ia6t_vltime - ia->prefix_vltime; } else ia->prefix_vltime = ND6_INFINITE_LIFETIME; Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.5 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.6 --- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.5 Wed Apr 17 23:35:35 2019 +++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c Fri Apr 26 14:34:10 2019 @@ -190,54 +190,106 @@ ipv6nd_printoptions(const struct dhcpcd_ } static int -ipv6nd_open(struct dhcpcd_ctx *ctx) +ipv6nd_open0(void) { - int on; + int s, on; struct icmp6_filter filt; - if (ctx->nd_fd != -1) - return ctx->nd_fd; #define SOCK_FLAGS SOCK_CLOEXEC | SOCK_NONBLOCK - ctx->nd_fd = xsocket(PF_INET6, SOCK_RAW | SOCK_FLAGS, IPPROTO_ICMPV6); + s = xsocket(PF_INET6, SOCK_RAW | SOCK_FLAGS, IPPROTO_ICMPV6); #undef SOCK_FLAGS - if (ctx->nd_fd == -1) + if (s == -1) return -1; /* RFC4861 4.1 */ on = 255; - if (setsockopt(ctx->nd_fd, IPPROTO_IPV6,
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Wed Apr 17 23:35:35 UTC 2019 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.c if-bsd.c if-options.c ipv6nd.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/external/bsd/dhcpcd/dist/src/dhcp.c cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/src/dhcp6.c \ src/external/bsd/dhcpcd/dist/src/if-bsd.c \ src/external/bsd/dhcpcd/dist/src/ipv6nd.c cvs rdiff -u -r1.17 -r1.18 src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/src/if-options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.16 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.17 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.16 Thu Feb 7 21:37:36 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Wed Apr 17 23:35:34 2019 @@ -86,9 +86,9 @@ #define IPDEFTTL 64 /* RFC1340 */ #endif -/* NetBSD-7 has an incomplete IP_PKTINFO implementation. */ -#if defined(__NetBSD_Version__) && __NetBSD_Version__ < 8 -#undef IP_PKTINFO +/* Support older systems with different defines */ +#if !defined(IP_RECVPKTINFO) && defined(IP_PKTINFO) +#define IP_RECVPKTINFO IP_PKTINFO #endif /* Assert the correct structure size for on wire */ @@ -129,6 +129,9 @@ static void dhcp_arp_conflicted(struct a #endif static void dhcp_handledhcp(struct interface *, struct bootp *, size_t, const struct in_addr *); +#ifdef IP_PKTINFO +static void dhcp_handleifudp(void *); +#endif static int dhcp_initstate(struct interface *); void @@ -447,7 +450,7 @@ decode_rfc3442_rt(struct rt_head *routes memcpy(_addr, p, 4); p += 4; - /* A host route is normally set by having the + /* An on-link host route is normally set by having the * gateway match the destination or assigned address */ if (gateway.s_addr == dest.s_addr || (gateway.s_addr == bootp->yiaddr || @@ -455,17 +458,14 @@ decode_rfc3442_rt(struct rt_head *routes { gateway.s_addr = INADDR_ANY; netmask.s_addr = INADDR_BROADCAST; - rt->rt_flags = RTF_HOST; } + if (netmask.s_addr == INADDR_BROADCAST) + rt->rt_flags = RTF_HOST; sa_in_init(>rt_dest, ); sa_in_init(>rt_netmask, ); sa_in_init(>rt_gateway, ); - /* If CIDR is 32 then it's a host route. */ - if (cidr == 32) - rt->rt_flags = RTF_HOST; - TAILQ_INSERT_TAIL(routes, rt, rt_next); n++; } @@ -638,7 +638,7 @@ get_option_routes(struct rt_head *routes if ((rt = rt_new(ifp)) == NULL) return -1; - /* A host route is normally set by having the + /* A on-link host route is normally set by having the * gateway match the destination or assigned address */ if (gateway.s_addr == dest.s_addr || (gateway.s_addr == bootp->yiaddr || @@ -646,12 +646,15 @@ get_option_routes(struct rt_head *routes { gateway.s_addr = INADDR_ANY; netmask.s_addr = INADDR_BROADCAST; -rt->rt_flags = RTF_HOST; } else netmask.s_addr = route_netmask(dest.s_addr); + if (netmask.s_addr == INADDR_BROADCAST) +rt->rt_flags = RTF_HOST; + sa_in_init(>rt_dest, ); sa_in_init(>rt_netmask, ); sa_in_init(>rt_gateway, ); + TAILQ_INSERT_TAIL(routes, rt, rt_next); n++; } @@ -1587,6 +1590,11 @@ dhcp_close(struct interface *ifp) state->bpf_fd = -1; state->bpf_flags |= BPF_EOF; } + if (state->udp_fd != -1) { + eloop_event_delete(ifp->ctx->eloop, state->udp_fd); + close(state->udp_fd); + state->udp_fd = -1; + } state->interval = 0; } @@ -1604,11 +1612,15 @@ dhcp_openudp(struct interface *ifp) n = 1; if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, , sizeof(n)) == -1) goto eexit; +#ifdef IP_RECVPKTINFO + if (setsockopt(s, IPPROTO_IP, IP_RECVPKTINFO, , sizeof(n)) == -1) + goto eexit; +#endif memset(, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_port = htons(BOOTPC); if (ifp) { - struct dhcp_state *state = D_STATE(ifp); + const struct dhcp_state *state = D_CSTATE(ifp); if (state->addr) sin.sin_addr.s_addr = state->addr->addr.s_addr; @@ -1699,12 +1711,8 @@ dhcp_sendudp(struct interface *ifp, stru struct msghdr msg; struct sockaddr_in sin; struct iovec iov[1]; + struct dhcp_state *state = D_STATE(ifp); ssize_t r; -#ifdef IP_PKTINFO - uint8_t cmsg[CMSG_SPACE(sizeof(struct in_pktinfo))]; - struct cmsghdr *cm; - struct in_pktinfo ipi; -#endif iov[0].iov_base = data; iov[0].iov_len = len; @@ -1723,29 +1731,15 @@ dhcp_sendudp(struct interface *ifp, stru msg.msg_iov = iov; msg.msg_iovlen = 1; -#ifdef IP_PKTINFO - /* Set the outbound interface */ - msg.msg_control = cmsg; - msg.msg_controllen = sizeof(cmsg); - - memset(, 0, sizeof(ipi)); - ipi.ipi_ifindex = ifp->index; - cm = CMSG_FIRSTHDR(); - if (cm == NULL) { - errno = ESRCH; - return -1; + s = state->udp_fd;
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Tue Jan 22 21:38:08 UTC 2019 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcpcd.c Log Message: Fix SMALLPROG build. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/src/dhcpcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.15 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.16 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.15 Tue Jan 22 15:20:21 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Tue Jan 22 21:38:08 2019 @@ -765,7 +765,9 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx * #ifdef NOCARRIER_PRESERVE_IP dhcpcd_drop(ifp, 0); #endif +#ifdef IPV4LL ipv4ll_reset(ifp); +#endif } } dhcpcd_initstate(ifp, 0);
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Tue Jan 22 15:20:21 UTC 2019 Modified Files: src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcp6.c dhcpcd.c if-bsd.c if-options.c ipv6nd.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/bpf.c cvs rdiff -u -r1.14 -r1.15 src/external/bsd/dhcpcd/dist/src/dhcp.c \ src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.2 -r1.3 src/external/bsd/dhcpcd/dist/src/dhcp6.c \ src/external/bsd/dhcpcd/dist/src/if-bsd.c \ src/external/bsd/dhcpcd/dist/src/ipv6nd.c cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/if-options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/bpf.c diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.7 src/external/bsd/dhcpcd/dist/src/bpf.c:1.8 --- src/external/bsd/dhcpcd/dist/src/bpf.c:1.7 Sat Jun 2 09:44:27 2018 +++ src/external/bsd/dhcpcd/dist/src/bpf.c Tue Jan 22 15:20:21 2019 @@ -1,6 +1,6 @@ /* * dhcpcd: BPF arp and bootp filtering - * Copyright (c) 2006-2018 Roy Marples + * Copyright (c) 2006-2019 Roy Marples * All rights reserved * Redistribution and use in source and binary forms, with or without Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.14 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.15 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.14 Sun Nov 4 16:30:28 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Tue Jan 22 15:20:21 2019 @@ -1,6 +1,6 @@ /* * dhcpcd - DHCP client daemon - * Copyright (c) 2006-2018 Roy Marples + * Copyright (c) 2006-2019 Roy Marples * All rights reserved * Redistribution and use in source and binary forms, with or without @@ -1604,11 +1604,6 @@ dhcp_openudp(struct interface *ifp) n = 1; if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, , sizeof(n)) == -1) goto eexit; -#ifdef SO_RERROR - n = 1; - if (setsockopt(s, SOL_SOCKET, SO_RERROR, , sizeof(n)) == -1) - goto eexit; -#endif memset(, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_port = htons(BOOTPC); @@ -2636,6 +2631,7 @@ dhcp_reboot(struct interface *ifp) * interface gets the reply. */ ia = ipv4_iffindaddr(ifp, >lease.addr, NULL); if (ia != NULL && + !(ifp->ctx->options & DHCPCD_TEST) && #ifdef IN_IFF_NOTUSEABLE !(ia->addr_flags & IN_IFF_NOTUSEABLE) && #endif Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.14 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.15 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.14 Mon Aug 27 13:43:05 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Tue Jan 22 15:20:21 2019 @@ -1,6 +1,6 @@ /* * dhcpcd - DHCP client daemon - * Copyright (c) 2006-2018 Roy Marples + * Copyright (c) 2006-2019 Roy Marples * All rights reserved * Redistribution and use in source and binary forms, with or without @@ -25,7 +25,7 @@ * SUCH DAMAGE. */ -const char dhcpcd_copyright[] = "Copyright (c) 2006-2018 Roy Marples"; +const char dhcpcd_copyright[] = "Copyright (c) 2006-2019 Roy Marples"; #include #include @@ -314,13 +314,6 @@ dhcpcd_daemonise(struct dhcpcd_ctx *ctx) return 0; } - /* Store the pid and routing message seq number so we can identify - * the last message successfully sent to the kernel. - * This allows us to ignore all messages we sent after forking - * and detaching. */ - ctx->ppid = getpid(); - ctx->pseq = ctx->sseq; - switch (pid = fork()) { case -1: logerr("%s: fork", __func__); @@ -451,6 +444,10 @@ configure_interface1(struct interface *i ifo->options &= ~(DHCPCD_IPV6RS | DHCPCD_DHCP6 | DHCPCD_WAITIP6); + if (!(ifo->options & DHCPCD_IPV6RS)) + ifo->options &= + ~(DHCPCD_IPV6RA_AUTOCONF | DHCPCD_IPV6RA_REQRDNSS); + /* We want to setup INET6 on the interface as soon as possible. */ if (ifp->active == IF_ACTIVE_USER && ifo->options & DHCPCD_IPV6 && @@ -738,6 +735,7 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx * #endif dhcp_abort(ifp); ipv6nd_expire(ifp, 0); + dhcp6_abort(ifp); #else dhcpcd_drop(ifp, 0); #endif @@ -754,19 +752,21 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx * #endif if (ifp->wireless) { uint8_t ossid[IF_SSIDLEN]; -#ifdef NOCARRIER_PRESERVE_IP size_t olen; olen = ifp->ssid_len; -#endif memcpy(ossid, ifp->ssid, ifp->ssid_len); if_getssid(ifp); -#ifdef NOCARRIER_PRESERVE_IP + /* If we changed SSID network, drop leases */ if (ifp->ssid_len != olen || memcmp(ifp->ssid, ossid, ifp->ssid_len)) +{ +#ifdef NOCARRIER_PRESERVE_IP dhcpcd_drop(ifp, 0); #endif + ipv4ll_reset(ifp); +} } dhcpcd_initstate(ifp, 0); script_runreason(ifp, "CARRIER"); Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.2 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.3
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: sevan Date: Mon Aug 27 13:43:05 UTC 2018 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcpcd.c Log Message: Update usage() to include documented flags To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/external/bsd/dhcpcd/dist/src/dhcpcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.13 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.14 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.13 Thu Jun 21 11:58:23 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Mon Aug 27 13:43:05 2018 @@ -86,19 +86,22 @@ static void usage(void) { -printf("usage: "PACKAGE"\t[-46ABbDdEGgHJKkLnPpqTVw]\n" +printf("usage: "PACKAGE"\t[-146ABbDdEGgHJKLMNPpqTV]\n" "\t\t[-C, --nohook hook] [-c, --script script]\n" "\t\t[-e, --env value] [-F, --fqdn FQDN] [-f, --config file]\n" "\t\t[-h, --hostname hostname] [-I, --clientid clientid]\n" - "\t\t[-i, --vendorclassid vendorclassid] [-l, --leasetime seconds]\n" - "\t\t[-m, --metric metric] [-O, --nooption option]\n" - "\t\t[-o, --option option] [-Q, --require option]\n" - "\t\t[-r, --request address] [-S, --static value]\n" - "\t\t[-s, --inform address[/cidr]] [-t, --timeout seconds]\n" - "\t\t[-u, --userclass class] [-v, --vendor code, value]\n" - "\t\t[-W, --whitelist address[/cidr]] [-y, --reboot seconds]\n" + "\t\t[-i, --vendorclassid vendorclassid] [-j, --logfile logfile]\n" + "\t\t[-l, --leasetime seconds] [-m, --metric metric]\n" + "\t\t[-O, --nooption option] [-o, --option option]\n" + "\t\t[-Q, --require option] [-r, --request address]\n" + "\t\t[-S, --static value]\n" + "\t\t[-s, --inform address[/cidr[/broadcast_address]]]\n [--inform6]" + "\t\t[-t, --timeout seconds] [-u, --userclass class]\n" + "\t\t[-v, --vendor code, value] [-W, --whitelist address[/cidr]] [-w]\n" + "\t\t[--waitip [4 | 6]] [-y, --reboot seconds]\n" "\t\t[-X, --blacklist address[/cidr]] [-Z, --denyinterfaces pattern]\n" - "\t\t[-z, --allowinterfaces pattern] [interface] [...]\n" + "\t\t[-z, --allowinterfaces pattern] [--inactive] [interface] [...]\n" + " "PACKAGE"\t-n, --rebind [interface]\n" " "PACKAGE"\t-k, --release [interface]\n" " "PACKAGE"\t-U, --dumplease interface\n" " "PACKAGE"\t--version\n"
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Mon Aug 20 10:55:59 UTC 2018 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/src/dhcp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.12 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.13 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.12 Fri Aug 3 02:17:33 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Mon Aug 20 10:55:59 2018 @@ -86,6 +86,11 @@ #define IPDEFTTL 64 /* RFC1340 */ #endif +/* NetBSD-7 has an incomplete IP_PKTINFO implementation. */ +#if defined(__NetBSD_Version__) && __NetBSD_Version__ < 8 +#undef IP_PKTINFO +#endif + /* Assert the correct structure size for on wire */ __CTASSERT(sizeof(struct ip) == 20); __CTASSERT(sizeof(struct udphdr) == 8);
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: kamil Date: Fri Aug 3 02:17:33 UTC 2018 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c Log Message: Fix build failure in dhcpcd under uUBSan GCC with -fsanitize=undefiend detects a potential overflow in the code. Cast the return value of ntohs(3) to size_t. Fix merged upstream by . To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/src/dhcp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.11 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.12 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.11 Mon Jun 4 16:45:52 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Fri Aug 3 02:17:33 2018 @@ -3267,7 +3267,7 @@ get_udp_data(void *udp, size_t *len) struct bootp_pkt *p; p = (struct bootp_pkt *)udp; - *len = ntohs(p->ip.ip_len) - sizeof(p->ip) - sizeof(p->udp); + *len = (size_t)ntohs(p->ip.ip_len) - sizeof(p->ip) - sizeof(p->udp); return (char *)udp + offsetof(struct bootp_pkt, bootp); }
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Thu Jun 21 11:58:23 UTC 2018 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcpcd.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/src/dhcpcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.12 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.13 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.12 Mon Jun 4 09:56:16 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Thu Jun 21 11:58:23 2018 @@ -373,7 +373,7 @@ dhcpcd_drop(struct interface *ifp, int s #ifdef IPV4LL ipv4ll_drop(ifp); #endif -#ifdef DHCP +#ifdef INET dhcp_drop(ifp, stop ? "STOP" : "EXPIRE"); #endif #ifdef ARP
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Mon Jun 4 16:45:52 UTC 2018 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/dhcp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.10 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.11 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.10 Sat Jun 2 09:44:27 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Mon Jun 4 16:45:52 2018 @@ -2101,8 +2101,10 @@ dhcp_arp_probed(struct arp_state *astate if (ifp->ctx->options & DHCPCD_FORKED) return; +#ifdef IPV4LL /* Stop IPv4LL now we have a working DHCP address */ ipv4ll_drop(ifp); +#endif if (ifo->options & DHCPCD_INFORM) dhcp_inform(ifp);
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Mon Jun 4 09:56:16 UTC 2018 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcpcd.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/src/dhcpcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.11 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.12 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.11 Sat Jun 2 09:44:27 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Mon Jun 4 09:56:16 2018 @@ -363,14 +363,25 @@ static void dhcpcd_drop(struct interface *ifp, int stop) { +#ifdef DHCP6 dhcp6_drop(ifp, stop ? NULL : "EXPIRE6"); +#endif +#ifdef INET6 ipv6nd_drop(ifp); ipv6_drop(ifp); +#endif +#ifdef IPV4LL ipv4ll_drop(ifp); +#endif +#ifdef DHCP dhcp_drop(ifp, stop ? "STOP" : "EXPIRE"); +#endif #ifdef ARP arp_drop(ifp); #endif +#if !defined(DHCP6) && !defined(DHCP) + UNUSED(stop); +#endif } static void @@ -773,8 +784,10 @@ static void warn_iaid_conflict(struct interface *ifp, uint16_t ia_type, uint8_t *iaid) { struct interface *ifn; +#ifdef INET6 size_t i; struct if_ia *ia; +#endif TAILQ_FOREACH(ifn, ifp->ctx->ifaces, next) { if (ifn == ifp || !ifn->active) @@ -783,12 +796,14 @@ warn_iaid_conflict(struct interface *ifp memcmp(ifn->options->iaid, iaid, sizeof(ifn->options->iaid)) == 0) break; +#ifdef INET6 for (i = 0; i < ifn->options->ia_len; i++) { ia = >options->ia[i]; if (ia->ia_type == ia_type && memcmp(ia->iaid, iaid, sizeof(ia->iaid)) == 0) break; } +#endif } /* This is only a problem if the interfaces are on the same network. */ @@ -802,7 +817,6 @@ dhcpcd_startinterface(void *arg) { struct interface *ifp = arg; struct if_options *ifo = ifp->options; - size_t i; char buf[DUID_LEN * 3]; int carrier; struct timespec tv; @@ -842,13 +856,17 @@ dhcpcd_startinterface(void *arg) } if (ifo->options & (DHCPCD_DUID | DHCPCD_IPV6)) { +#ifdef INET6 + size_t i; struct if_ia *ia; +#endif /* Report IAIDs */ loginfox("%s: IAID %s", ifp->name, hwaddr_ntoa(ifo->iaid, sizeof(ifo->iaid), buf, sizeof(buf))); warn_iaid_conflict(ifp, 0, ifo->iaid); +#ifdef INET6 for (i = 0; i < ifo->ia_len; i++) { ia = >ia[i]; if (memcmp(ifo->iaid, ia->iaid, sizeof(ifo->iaid))) { @@ -859,6 +877,7 @@ dhcpcd_startinterface(void *arg) warn_iaid_conflict(ifp, ia->ia_type, ia->iaid); } } +#endif } if (ifo->options & DHCPCD_IPV6 && ipv6_start(ifp) == -1) {
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Sat Jun 2 09:44:27 UTC 2018 Modified Files: src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcpcd.c if-options.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/bpf.c cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/dhcp.c \ src/external/bsd/dhcpcd/dist/src/if-options.c cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/dhcpcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/bpf.c diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.6 src/external/bsd/dhcpcd/dist/src/bpf.c:1.7 --- src/external/bsd/dhcpcd/dist/src/bpf.c:1.6 Mon Jan 1 11:50:56 2018 +++ src/external/bsd/dhcpcd/dist/src/bpf.c Sat Jun 2 09:44:27 2018 @@ -108,7 +108,7 @@ bpf_open(struct interface *ifp, int (*fi size_t buf_len; struct bpf_version pv; #ifdef BIOCIMMEDIATE - int flags; + unsigned int flags; #endif #ifndef O_CLOEXEC int fd_opts; @@ -411,7 +411,7 @@ static const struct bpf_insn bpf_arp_eth /* Make sure the hardware length matches. */ BPF_STMT(BPF_LD + BPF_B + BPF_IND, offsetof(struct arphdr, ar_hln)), BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, - sizeof((struct ether_arp *)0)->arp_sha, 1, 0), + sizeof(((struct ether_arp *)0)->arp_sha), 1, 0), BPF_STMT(BPF_RET + BPF_K, 0), }; #define bpf_arp_ether_len __arraycount(bpf_arp_ether) @@ -540,7 +540,7 @@ static const struct bpf_insn bpf_bootp_e #define BPF_BOOTP_ETHER_LEN __arraycount(bpf_bootp_ether) static const struct bpf_insn bpf_bootp_filter[] = { - /* Make sure it's an IPv4 packet. */ + /* Make sure it's an optionless IPv4 packet. */ BPF_STMT(BPF_LD + BPF_B + BPF_IND, 0), BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0x45, 1, 0), BPF_STMT(BPF_RET + BPF_K, 0), Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.9 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.10 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.9 Tue Mar 27 06:16:34 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Sat Jun 2 09:44:27 2018 @@ -3276,7 +3276,7 @@ valid_udp_packet(void *data, size_t data struct bootp_pkt *p; uint16_t bytes; - if (data_len < sizeof(p->ip) + sizeof(p->udp)) { + if (data_len < sizeof(p->ip)) { if (from) from->s_addr = INADDR_ANY; errno = ERANGE; @@ -3291,6 +3291,12 @@ valid_udp_packet(void *data, size_t data } bytes = ntohs(p->ip.ip_len); + /* Check we have a payload */ + if (bytes <= sizeof(p->ip) + sizeof(p->udp)) { + errno = ERANGE; + return -1; + } + /* Check we don't go beyond the payload */ if (bytes > data_len) { errno = ENOBUFS; return -1; @@ -3334,7 +3340,7 @@ dhcp_handlepacket(struct interface *ifp, state->bpf_flags & RAW_PARTIALCSUM) == -1) { if (errno == EINVAL) - logerrx("%s: UDP checksum failure from %s", + logerrx("%s: checksum failure from %s", ifp->name, inet_ntoa(from)); else logerr("%s: invalid UDP packet from %s", Index: src/external/bsd/dhcpcd/dist/src/if-options.c diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.9 src/external/bsd/dhcpcd/dist/src/if-options.c:1.10 --- src/external/bsd/dhcpcd/dist/src/if-options.c:1.9 Wed May 2 22:08:45 2018 +++ src/external/bsd/dhcpcd/dist/src/if-options.c Sat Jun 2 09:44:27 2018 @@ -1360,6 +1360,7 @@ parse_option(struct dhcpcd_ctx *ctx, con for (sl = 0; sl < ifo->ia_len; sl++) { if ((arg == NULL && !ifo->ia[sl].iaid_set) || (arg != NULL && ifo->ia[sl].iaid_set && + ifo->ia[sl].ia_type == (uint16_t)i && ifo->ia[sl].iaid[0] == iaid[0] && ifo->ia[sl].iaid[1] == iaid[1] && ifo->ia[sl].iaid[2] == iaid[2] && @@ -1369,10 +1370,6 @@ parse_option(struct dhcpcd_ctx *ctx, con break; } } - if (ia && ia->ia_type != (uint16_t)i) { - logerrx("Cannot mix IA for the same IAID"); - break; - } if (ia == NULL) { ia = reallocarray(ifo->ia, ifo->ia_len + 1, sizeof(*ifo->ia)); Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.10 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.11 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.10 Fri Apr 6 10:47:47 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Sat Jun 2 09:44:27 2018 @@ -770,20 +770,23 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx * } static void -warn_iaid_conflict(struct interface *ifp, uint8_t *iaid) +warn_iaid_conflict(struct interface *ifp, uint16_t ia_type, uint8_t *iaid) { struct interface *ifn; size_t i; + struct if_ia *ia; TAILQ_FOREACH(ifn, ifp->ctx->ifaces, next) { if (ifn == ifp || !ifn->active) continue; - if (memcmp(ifn->options->iaid, iaid, + if (ia_type == 0 && + memcmp(ifn->options->iaid, iaid, sizeof(ifn->options->iaid)) == 0) break; for (i = 0; i < ifn->options->ia_len; i++) { - if (memcmp(>options->ia[i].iaid,
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Wed May 2 22:08:45 UTC 2018 Modified Files: src/external/bsd/dhcpcd/dist/src: if-options.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/if-options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/if-options.c diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.8 src/external/bsd/dhcpcd/dist/src/if-options.c:1.9 --- src/external/bsd/dhcpcd/dist/src/if-options.c:1.8 Fri Apr 6 10:47:47 2018 +++ src/external/bsd/dhcpcd/dist/src/if-options.c Wed May 2 22:08:45 2018 @@ -1850,6 +1850,7 @@ err_sla: logerrx("invalid code: %s", arg); return -1; } + fp = strskipwhite(fp); if (fp) { s = parse_string(NULL, 0, fp); if (s == -1) { @@ -1912,12 +1913,32 @@ err_sla: } if (fp) *fp++ = '\0'; - if (strcasecmp(arg, "hmacmd5") == 0 || - strcasecmp(arg, "hmac-md5") == 0) - ifo->auth.algorithm = AUTH_ALG_HMAC_MD5; - else { - logerrx("%s: unsupported algorithm", arg); - return 1; + if (ifo->auth.protocol == AUTH_PROTO_TOKEN) { + np = strchr(arg, '/'); + if (np) { +if (fp == NULL || np < fp) + *np++ = '\0'; +else + np = NULL; + } + if (parse_uint32(>auth.token_snd_secretid, + arg) == -1) +logerrx("%s: not a number", arg); + else +ifo->auth.token_rcv_secretid = +ifo->auth.token_snd_secretid; + if (np && + parse_uint32(>auth.token_rcv_secretid, + np) == -1) +logerrx("%s: not a number", arg); + } else { + if (strcasecmp(arg, "hmacmd5") == 0 || + strcasecmp(arg, "hmac-md5") == 0) +ifo->auth.algorithm = AUTH_ALG_HMAC_MD5; + else { +logerrx("%s: unsupported algorithm", arg); +return 1; + } } arg = fp; if (arg == NULL) {
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Fri Apr 6 10:47:47 UTC 2018 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcpcd.c if-options.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/if-options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.9 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.10 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.9 Tue Mar 27 06:16:34 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Fri Apr 6 10:47:47 2018 @@ -577,7 +577,7 @@ dhcpcd_selectprofile(struct interface *i } else *ifp->profile = '\0'; - free_options(ifp->options); + free_options(ifp->ctx, ifp->options); ifp->options = ifo; if (profile) { add_options(ifp->ctx, ifp->name, ifp->options, @@ -995,6 +995,7 @@ dhcpcd_handleinterface(void *arg, int ac } /* Check if we already have the interface */ iff = if_find(ctx->ifaces, ifp->name); + if (iff != NULL) { if (iff->active) logdebugx("%s: interface updated", iff->name); @@ -1013,9 +1014,12 @@ dhcpcd_handleinterface(void *arg, int ac } iff = ifp; } - if_learnaddrs(ctx, ifs, ); - if (action > 0 && iff->active) - dhcpcd_prestartinterface(iff); + + if (action > 0) { + if_learnaddrs(ctx, ifs, ); + if (iff->active) + dhcpcd_prestartinterface(iff); + } /* Free our discovered list */ while ((ifp = TAILQ_FIRST(ifs))) { @@ -1161,7 +1165,7 @@ reload_config(struct dhcpcd_ctx *ctx) if (ctx->options & DHCPCD_DAEMONISED) ifo->options |= DHCPCD_DAEMONISED; ctx->options = ifo->options; - free_options(ifo); + free_options(ctx, ifo); } static void @@ -1519,6 +1523,8 @@ main(int argc, char **argv) #ifdef INET ctx.udp_fd = -1; #endif + rt_init(); + logopts = LOGERR_ERR|LOGERR_LOG|LOGERR_LOG_DATE|LOGERR_LOG_PID; i = 0; while ((opt = getopt_long(argc, argv, @@ -1613,7 +1619,7 @@ main(int argc, char **argv) if (i == 2) { printf("Interface options:\n"); if (optind == argc - 1) { - free_options(ifo); + free_options(, ifo); ifo = read_config(, argv[optind], NULL, NULL); if (ifo == NULL) goto exit_failure; @@ -1929,8 +1935,6 @@ printpidfile: } } - rt_init(); - TAILQ_FOREACH(ifp, ctx.ifaces, next) { if (ifp->active) dhcpcd_initstate1(ifp, argc, argv, 0); @@ -1981,7 +1985,7 @@ printpidfile: handle_exit_timeout, ); } } - free_options(ifo); + free_options(, ifo); ifo = NULL; if_sortinterfaces(); @@ -2018,6 +2022,7 @@ exit1: } free(ctx.ifaces); } + free_options(, ifo); rt_dispose(); free(ctx.duid); if (ctx.link_fd != -1) { @@ -2025,7 +2030,6 @@ exit1: close(ctx.link_fd); } if_closesockets(); - free_options(ifo); free_globals(); ipv6_ctxfree(); dev_stop(); Index: src/external/bsd/dhcpcd/dist/src/if-options.c diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.7 src/external/bsd/dhcpcd/dist/src/if-options.c:1.8 --- src/external/bsd/dhcpcd/dist/src/if-options.c:1.7 Mon Jan 29 11:13:06 2018 +++ src/external/bsd/dhcpcd/dist/src/if-options.c Fri Apr 6 10:47:47 2018 @@ -1086,14 +1086,8 @@ parse_option(struct dhcpcd_ctx *ctx, con strncmp(arg, "ms_classless_static_routes=", strlen("ms_classless_static_routes=")) == 0) { - struct interface *ifp; struct in_addr addr3; - ifp = if_find(ctx->ifaces, ifname); - if (ifp == NULL) { -logerrx("static routes require an interface"); -return -1; - } fp = np = strwhite(p); if (np == NULL) { logerrx("all routes need a gateway"); @@ -1107,7 +1101,7 @@ parse_option(struct dhcpcd_ctx *ctx, con *fp = ' '; return -1; } - if ((rt = rt_new(ifp)) == NULL) { + if ((rt = rt_new0(ctx)) == NULL) { *fp = ' '; return -1; } @@ -1117,16 +,9 @@ parse_option(struct dhcpcd_ctx *ctx, con TAILQ_INSERT_TAIL(>routes, rt, rt_next); *fp = ' '; } else if (strncmp(arg, "routers=", strlen("routers=")) == 0) { - struct interface *ifp; - - ifp = if_find(ctx->ifaces, ifname); - if (ifp == NULL) { -logerrx("static routes require an interface"); -return -1; - } if (parse_addr(, NULL, p) == -1) return -1; - if ((rt = rt_new(ifp)) == NULL) + if ((rt = rt_new0(ctx)) == NULL) return -1; addr2.s_addr = INADDR_ANY; sa_in_init(>rt_dest, ); @@ -2367,7 +2354,7 @@ read_config(struct dhcpcd_ctx *ctx, buf = malloc(buflen); if (buf == NULL) { logerr(__func__); - free_options(ifo); + free_options(ctx, ifo); return NULL; } ldop = edop = NULL; @@ -2381,7 +2368,7 @@ read_config(struct dhcpcd_ctx *ctx, if (nbuf == NULL) { logerr(__func__); free(buf); - free_options(ifo); + free_options(ctx, ifo); return NULL; } buf = nbuf; @@
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Tue Mar 27 06:16:34 UTC 2018 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c dhcpcd.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/dhcp.c \ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.8 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.9 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.8 Mon Jan 29 11:13:06 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Tue Mar 27 06:16:34 2018 @@ -3653,6 +3653,7 @@ dhcp_start1(void *arg) state = D_STATE(ifp); clock_gettime(CLOCK_MONOTONIC, >started); + state->interval = 0; free(state->offer); state->offer = NULL; state->offer_len = 0; @@ -3891,7 +3892,7 @@ dhcp_abort(struct interface *ifp) } void -dhcp_handleifa(int cmd, struct ipv4_addr *ia) +dhcp_handleifa(int cmd, struct ipv4_addr *ia, pid_t pid) { struct interface *ifp; struct dhcp_state *state; @@ -3905,12 +3906,13 @@ dhcp_handleifa(int cmd, struct ipv4_addr if (cmd == RTM_DELADDR) { if (state->addr == ia) { - loginfox("%s: deleted IP address %s", - ifp->name, ia->saddr); + loginfox("%s: pid %d deleted IP address %s", + ifp->name, pid, ia->saddr); state->addr = NULL; /* Don't clear the added state as we need * to drop the lease. */ dhcp_drop(ifp, "EXPIRE"); + dhcp_start1(ifp); } return; } Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.8 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.9 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.8 Mon Jan 29 11:13:06 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Tue Mar 27 06:16:34 2018 @@ -437,19 +437,15 @@ configure_interface1(struct interface *i ifo->options &= ~(DHCPCD_IPV6RS | DHCPCD_DHCP6 | DHCPCD_WAITIP6); - /* We want to disable kernel interface RA as early as possible. */ + /* We want to setup INET6 on the interface as soon as possible. */ if (ifp->active == IF_ACTIVE_USER && - !(ifp->ctx->options & DHCPCD_DUMPLEASE)) + ifo->options & DHCPCD_IPV6 && + !(ifp->ctx->options & (DHCPCD_DUMPLEASE | DHCPCD_TEST))) { - int ra_global, ra_iface; - /* If not doing any DHCP, disable the RDNSS requirement. */ if (!(ifo->options & (DHCPCD_DHCP | DHCPCD_DHCP6))) ifo->options &= ~DHCPCD_IPV6RA_REQRDNSS; - ra_global = if_checkipv6(ifp->ctx, NULL); - ra_iface = if_checkipv6(ifp->ctx, ifp); - if (ra_global == -1 || ra_iface == -1) - ifo->options &= ~DHCPCD_IPV6RS; + if_setup_inet6(ifp); } #endif @@ -959,20 +955,6 @@ dhcpcd_activateinterface(struct interfac } } -static void -dhcpcd_handlelink(void *arg) -{ - struct dhcpcd_ctx *ctx; - - ctx = arg; - if (if_handlelink(ctx) == -1) { - logerr(__func__); - eloop_event_delete(ctx->eloop, ctx->link_fd); - close(ctx->link_fd); - ctx->link_fd = -1; - } -} - int dhcpcd_handleinterface(void *arg, int action, const char *ifname) { @@ -1045,6 +1027,83 @@ dhcpcd_handleinterface(void *arg, int ac return 1; } +static void +dhcpcd_handlelink(void *arg) +{ + struct dhcpcd_ctx *ctx = arg; + + if (if_handlelink(ctx) == -1) { + if (errno == ENOBUFS || errno == ENOMEM) { + dhcpcd_linkoverflow(ctx); + return; + } + logerr(__func__); + } +} + +static void +dhcpcd_checkcarrier(void *arg) +{ + struct interface *ifp = arg; + + dhcpcd_handlecarrier(ifp->ctx, LINK_UNKNOWN, ifp->flags, ifp->name); +} + +void +dhcpcd_linkoverflow(struct dhcpcd_ctx *ctx) +{ + struct if_head *ifaces; + struct ifaddrs *ifaddrs; + struct interface *ifp, *ifn, *ifp1; + + logerrx("route socket overflowed - learning interface state"); + + /* Close the existing socket and open a new one. + * This is easier than draining the kernel buffer of an + * in-determinate size. */ + eloop_event_delete(ctx->eloop, ctx->link_fd); + close(ctx->link_fd); + if_closesockets_os(ctx); + if (if_opensockets_os(ctx) == -1) { + logerr("%s: if_opensockets", __func__); + eloop_exit(ctx->eloop, EXIT_FAILURE); + return; + } + eloop_event_add(ctx->eloop, ctx->link_fd, dhcpcd_handlelink, ctx); + + /* Work out the current interfaces. */ + ifaces = if_discover(ctx, , ctx->ifc, ctx->ifv); + + /* Punt departed interfaces */ + TAILQ_FOREACH_SAFE(ifp, ctx->ifaces, next, ifn) { + if (if_find(ifaces, ifp->name) != NULL) + continue; + dhcpcd_handleinterface(ctx, -1, ifp->name); + } + + /* Add new interfaces */ + TAILQ_FOREACH_SAFE(ifp, ifaces, next, ifn) { + ifp1 = if_find(ctx->ifaces, ifp->name); + if (ifp1 != NULL) { + /* If the interface already exists, + * check carrier state. */ + eloop_timeout_add_sec(ctx->eloop, 0, + dhcpcd_checkcarrier, ifp1); + continue; + } + TAILQ_REMOVE(ifaces, ifp, next); + TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next); +
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Mon Jan 29 11:13:06 UTC 2018 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c dhcpcd.c if-options.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/dhcp.c \ src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/if-options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.7 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.8 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.7 Mon Jan 1 11:50:56 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Mon Jan 29 11:13:06 2018 @@ -1462,8 +1462,11 @@ get_lease(struct interface *ifp, if (ifp->options->options & (DHCPCD_STATIC | DHCPCD_INFORM)) { if (ifp->options->req_addr.s_addr != INADDR_ANY) { lease->mask = ifp->options->req_mask; - lease->brd.s_addr = - lease->addr.s_addr | ~lease->mask.s_addr; + if (ifp->options->req_brd.s_addr != INADDR_ANY) +lease->brd = ifp->options->req_brd; + else +lease->brd.s_addr = +lease->addr.s_addr | ~lease->mask.s_addr; } else { const struct ipv4_addr *ia; @@ -2076,7 +2079,7 @@ dhcp_arp_probed(struct arp_state *astate logdebugx("%s: DAD completed for %s", ifp->name, inet_ntoa(astate->addr)); - if (state->state != DHS_INFORM) + if (!(ifo->options & DHCPCD_INFORM)) dhcp_bind(ifp); #ifndef IN_IFF_TENTATIVE else { Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.7 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.8 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.7 Mon Jan 1 11:50:56 2018 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Mon Jan 29 11:13:06 2018 @@ -712,8 +712,10 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx * eloop_timeout_delete(ifp->ctx->eloop, dhcpcd_pollup, ifp); if (carrier == LINK_UNKNOWN) { - if (errno != ENOTTY) /* For example a PPP link on BSD */ + if (errno != ENOTTY && errno != ENXIO) { + /* Don't log an error if interface departed */ logerr("%s: %s", ifp->name, __func__); + } } else if (carrier == LINK_DOWN || (ifp->flags & IFF_UP) == 0) { if (ifp->carrier != LINK_DOWN) { if (ifp->carrier == LINK_UP) @@ -977,9 +979,8 @@ dhcpcd_handleinterface(void *arg, int ac struct dhcpcd_ctx *ctx; struct ifaddrs *ifaddrs; struct if_head *ifs; - struct interface *ifp, *iff, *ifn; + struct interface *ifp, *iff; const char * const argv[] = { ifname }; - int i; ctx = arg; if (action == -1) { @@ -998,62 +999,41 @@ dhcpcd_handleinterface(void *arg, int ac return 0; } - i = -1; ifs = if_discover(ctx, , -1, UNCONST(argv)); if (ifs == NULL) { logerr(__func__); return -1; } - TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) { - if (strcmp(ifp->name, ifname) != 0) - continue; - - /* If running off an interface list, check it's in it. */ - if (ctx->ifc || ctx->options & DHCPCD_INACTIVE) { - for (i = 0; i < ctx->ifc; i++) -if (strcmp(ctx->ifv[i], ifname) == 0) - break; - if (i >= ctx->ifc) { -ifp->active = IF_INACTIVE; -ifp->carrier = LINK_UNKNOWN; - } - } - - i = 0; - /* Check if we already have the interface */ - iff = if_find(ctx->ifaces, ifp->name); - if (iff) { - if (iff->active) -logdebugx("%s: interface updated", iff->name); - /* The flags and hwaddr could have changed */ - iff->flags = ifp->flags; - iff->hwlen = ifp->hwlen; - if (ifp->hwlen != 0) -memcpy(iff->hwaddr, ifp->hwaddr, iff->hwlen); - } else { - TAILQ_REMOVE(ifs, ifp, next); - TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next); - if (!ifp->active) -continue; + ifp = if_find(ifs, ifname); + if (ifp == NULL) { + /* This can happen if an interface is quickly added + * and then removed. */ + errno = ENOENT; + return -1; + } + /* Check if we already have the interface */ + iff = if_find(ctx->ifaces, ifp->name); + if (iff != NULL) { + if (iff->active) + logdebugx("%s: interface updated", iff->name); + /* The flags and hwaddr could have changed */ + iff->flags = ifp->flags; + iff->hwlen = ifp->hwlen; + if (ifp->hwlen != 0) + memcpy(iff->hwaddr, ifp->hwaddr, iff->hwlen); + } else { + TAILQ_REMOVE(ifs, ifp, next); + TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next); + if (ifp->active) { logdebugx("%s: interface added", ifp->name); dhcpcd_initstate(ifp, 0); run_preinit(ifp); - iff = ifp; } - if (action > 0 && iff->active) - dhcpcd_prestartinterface(iff); + iff = ifp; } - if_learnaddrs(ctx, ifs, ); - - /* Now we have learned addresses, start the interface */ - TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) { - if (strcmp(ifp->name, ifname) != 0) - continue; - iff = if_find(ctx->ifaces, ifp->name); - if (action > 0 && iff->active) - dhcpcd_prestartinterface(iff); - } + if (action > 0 && iff->active) +
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Mon Jan 1 11:50:56 UTC 2018 Modified Files: src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcpcd.c if-options.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcpcd/dist/src/bpf.c \ src/external/bsd/dhcpcd/dist/src/if-options.c cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/dhcp.c \ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/bpf.c diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.5 src/external/bsd/dhcpcd/dist/src/bpf.c:1.6 --- src/external/bsd/dhcpcd/dist/src/bpf.c:1.5 Wed Dec 6 10:35:05 2017 +++ src/external/bsd/dhcpcd/dist/src/bpf.c Mon Jan 1 11:50:56 2018 @@ -1,6 +1,6 @@ /* * dhcpcd: BPF arp and bootp filtering - * Copyright (c) 2006-2017 Roy Marples+ * Copyright (c) 2006-2018 Roy Marples * All rights reserved * Redistribution and use in source and binary forms, with or without Index: src/external/bsd/dhcpcd/dist/src/if-options.c diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.5 src/external/bsd/dhcpcd/dist/src/if-options.c:1.6 --- src/external/bsd/dhcpcd/dist/src/if-options.c:1.5 Tue Sep 19 19:19:21 2017 +++ src/external/bsd/dhcpcd/dist/src/if-options.c Mon Jan 1 11:50:56 2018 @@ -1,6 +1,6 @@ /* * dhcpcd - DHCP client daemon - * Copyright (c) 2006-2017 Roy Marples + * Copyright (c) 2006-2018 Roy Marples * All rights reserved * Redistribution and use in source and binary forms, with or without Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.6 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.7 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.6 Wed Dec 6 10:35:05 2017 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Mon Jan 1 11:50:56 2018 @@ -1,6 +1,6 @@ /* * dhcpcd - DHCP client daemon - * Copyright (c) 2006-2017 Roy Marples + * Copyright (c) 2006-2018 Roy Marples * All rights reserved * Redistribution and use in source and binary forms, with or without @@ -777,7 +777,8 @@ make_message(struct bootp **bootpm, cons (type == DHCP_INFORM || type == DHCP_RELEASE || (type == DHCP_REQUEST && state->addr->mask.s_addr == lease->mask.s_addr && - (state->new == NULL || IS_DHCP(state->new) + (state->new == NULL || IS_DHCP(state->new)) && + !(state->added & STATE_FAKE bootp->ciaddr = state->addr->addr.s_addr; bootp->op = BOOTREQUEST; @@ -845,6 +846,7 @@ make_message(struct bootp **bootpm, cons if (type == DHCP_DECLINE || (type == DHCP_REQUEST && (state->addr == NULL || + state->added & STATE_FAKE || lease->addr.s_addr != state->addr->addr.s_addr))) { PUT_ADDR(DHO_IPADDRESS, >addr); @@ -1587,10 +1589,6 @@ dhcp_openudp(struct interface *ifp) int s; struct sockaddr_in sin; int n; - struct dhcp_state *state; -#ifdef SO_BINDTODEVICE - struct ifreq ifr; -#endif if ((s = xsocket(PF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP)) == -1) return -1; @@ -1598,20 +1596,12 @@ dhcp_openudp(struct interface *ifp) n = 1; if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, , sizeof(n)) == -1) goto eexit; -#ifdef SO_BINDTODEVICE - if (ifp) { - memset(, 0, sizeof(ifr)); - strlcpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name)); - if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, , - sizeof(ifr)) == -1) - goto eexit; - } -#endif memset(, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_port = htons(BOOTPC); if (ifp) { - state = D_STATE(ifp); + struct dhcp_state *state = D_STATE(ifp); + if (state->addr) sin.sin_addr.s_addr = state->addr->addr.s_addr; } @@ -1694,6 +1684,63 @@ dhcp_makeudppacket(size_t *sz, const uin return udpp; } +static ssize_t +dhcp_sendudp(struct interface *ifp, struct in_addr *to, void *data, size_t len) +{ + int s; + struct msghdr msg; + struct sockaddr_in sin; + struct iovec iov[1]; + ssize_t r; +#ifdef IP_PKTINFO + uint8_t cmsg[CMSG_SPACE(sizeof(struct in_pktinfo))]; + struct cmsghdr *cm; + struct in_pktinfo ipi; +#endif + + iov[0].iov_base = data; + iov[0].iov_len = len; + + memset(, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_addr = *to; + sin.sin_port = htons(BOOTPS); +#ifdef HAVE_SA_LEN + sin.sin_len = sizeof(sin); +#endif + + memset(, 0, sizeof(msg)); + msg.msg_name = (void *) + msg.msg_namelen = sizeof(sin); + msg.msg_iov = iov; + msg.msg_iovlen = 1; + +#ifdef IP_PKTINFO + /* Set the outbound interface */ + msg.msg_control = cmsg; + msg.msg_controllen = sizeof(cmsg); + + memset(, 0, sizeof(ipi)); + ipi.ipi_ifindex = ifp->index; + cm = CMSG_FIRSTHDR(); + if (cm == NULL) { + errno = ESRCH; + return -1; + } + cm->cmsg_level = IPPROTO_IP; + cm->cmsg_type = IP_PKTINFO; +
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Wed Dec 6 10:35:05 UTC 2017 Modified Files: src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcpcd.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/src/bpf.c cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcpcd/dist/src/dhcp.c \ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/bpf.c diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.4 src/external/bsd/dhcpcd/dist/src/bpf.c:1.5 --- src/external/bsd/dhcpcd/dist/src/bpf.c:1.4 Tue Sep 19 19:19:21 2017 +++ src/external/bsd/dhcpcd/dist/src/bpf.c Wed Dec 6 10:35:05 2017 @@ -194,7 +194,8 @@ eexit: /* BPF requires that we read the entire buffer. * So we pass the buffer in the API so we can loop on >1 packet. */ ssize_t -bpf_read(struct interface *ifp, int fd, void *data, size_t len, int *flags) +bpf_read(struct interface *ifp, int fd, void *data, size_t len, +unsigned int *flags) { ssize_t fl = (ssize_t)bpf_frame_header_len(ifp); ssize_t bytes; @@ -203,7 +204,7 @@ bpf_read(struct interface *ifp, int fd, struct bpf_hdr packet; const char *payload; - *flags = 0; + *flags &= ~BPF_EOF; for (;;) { if (state->buffer_len == 0) { bytes = read(fd, state->buffer, state->buffer_size); Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.5 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.6 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.5 Sat Oct 7 14:14:40 2017 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Wed Dec 6 10:35:05 2017 @@ -428,7 +428,6 @@ decode_rfc3442_rt(struct rt_head *routes if ((rt = rt_new(ifp)) == NULL) return -1; - TAILQ_INSERT_TAIL(routes, rt, rt_next); /* If we have ocets then we have a destination and netmask */ dest.s_addr = 0; @@ -461,6 +460,8 @@ decode_rfc3442_rt(struct rt_head *routes /* If CIDR is 32 then it's a host route. */ if (cidr == 32) rt->rt_flags = RTF_HOST; + + TAILQ_INSERT_TAIL(routes, rt, rt_next); n++; } return n; @@ -1408,27 +1409,24 @@ dhcp_env(char **env, const char *prefix, continue; if (dhcp_getoverride(ifo, opt->option)) continue; - if ((p = get_option(ifp->ctx, bootp, bootp_len, - opt->option, ))) - { - ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name, - opt, dhcp_getoption, p, pl); - if (opt->option == DHO_VIVSO && - pl > (int)sizeof(uint32_t)) - { - memcpy(, p, sizeof(en)); -en = ntohl(en); -vo = vivso_find(en, ifp); -if (vo) { - /* Skip over en + total size */ - p += sizeof(en) + 1; - pl -= sizeof(en) + 1; - ep += dhcp_envoption(ifp->ctx, - ep, prefix, ifp->name, - vo, dhcp_getoption, p, pl); -} - } - } + p = get_option(ifp->ctx, bootp, bootp_len, opt->option, ); + if (p == NULL) + continue; + ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name, + opt, dhcp_getoption, p, pl); + + if (opt->option != DHO_VIVSO || pl <= (int)sizeof(uint32_t)) + continue; + memcpy(, p, sizeof(en)); + en = ntohl(en); + vo = vivso_find(en, ifp); + if (vo == NULL) + continue; + /* Skip over en + total size */ + p += sizeof(en) + 1; + pl -= sizeof(en) + 1; + ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name, + vo, dhcp_getoption, p, pl); } for (i = 0, opt = ifo->dhcp_override; @@ -1437,10 +1435,11 @@ dhcp_env(char **env, const char *prefix, { if (has_option_mask(ifo->nomask, opt->option)) continue; - if ((p = get_option(ifp->ctx, bootp, bootp_len, - opt->option, ))) - ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name, - opt, dhcp_getoption, p, pl); + p = get_option(ifp->ctx, bootp, bootp_len, opt->option, ); + if (p == NULL) + continue; + ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name, + opt, dhcp_getoption, p, pl); } return ep - env; @@ -1519,6 +1518,8 @@ static void dhcp_new_xid(struct interface *ifp) { struct dhcp_state *state; + const struct interface *ifp1; + const struct dhcp_state *state1; state = D_STATE(ifp); if (ifp->options->options & DHCPCD_XID_HWADDR && @@ -1527,8 +1528,30 @@ dhcp_new_xid(struct interface *ifp) memcpy(>xid, (ifp->hwaddr + ifp->hwlen) - sizeof(state->xid), sizeof(state->xid)); - else + else { +again: state->xid = arc4random(); + } + + /* Ensure it's unique */ + TAILQ_FOREACH(ifp1, ifp->ctx->ifaces, next) { + if (ifp == ifp1) + continue; + if ((state1 = D_CSTATE(ifp1)) == NULL) + continue; + if (state1->xid == state->xid) + break; + } + if (ifp1 != NULL) { + if (ifp->options->options & DHCPCD_XID_HWADDR && + ifp->hwlen >= sizeof(state->xid)) + { + logerrx("%s: duplicate xid on %s", + ifp->name, ifp1->name); + return; + } + goto again; + } /* We can't do this when sharing leases across
CVS commit: src/external/bsd/dhcpcd/dist/src/crypt
Module Name:src Committed By: roy Date: Sun Oct 8 09:10:11 UTC 2017 Removed Files: src/external/bsd/dhcpcd/dist/src/crypt: crypt.h hmac_md5.c Log Message: Cleanup To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/dhcpcd/dist/src/crypt/crypt.h \ src/external/bsd/dhcpcd/dist/src/crypt/hmac_md5.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Sat Oct 7 14:14:40 UTC 2017 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c Log Message: Remove mistakenly commited debug. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/src/dhcp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.4 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.5 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.4 Sat Oct 7 14:11:07 2017 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Sat Oct 7 14:14:40 2017 @@ -1487,7 +1487,6 @@ get_lease(struct interface *ifp, if (get_option_uint32(ctx, >renewaltime, bootp, len, DHO_RENEWALTIME) != 0) lease->renewaltime = 0; - lease->renewaltime = 30; if (get_option_uint32(ctx, >rebindtime, bootp, len, DHO_REBINDTIME) != 0) lease->rebindtime = 0; @@ -2750,18 +2749,10 @@ dhcp_handledhcp(struct interface *ifp, s #endif if (state->xid != ntohl(bootp->xid)) { - if (state->state != DHS_BOUND && state->state != DHS_NONE) { + if (state->state != DHS_BOUND && state->state != DHS_NONE) logdebugx("%s: wrong xid 0x%x (expecting 0x%x) from %s", ifp->name, ntohl(bootp->xid), state->xid, inet_ntoa(*from)); - char old[sizeof(state->leasefile)]; - - memcpy(old, state->leasefile, sizeof(old)); - snprintf(state->leasefile, sizeof(state->leasefile), "/tmp/dhcpcd-wrongxid-0x%x.%d", state->xid, rand()); - if (write_lease(ifp, bootp, bootp_len) == -1) - logerr(__func__); - memcpy(state->leasefile, old, sizeof(old)); - } dhcp_redirect_dhcp(ifp, bootp, bootp_len, from); return; }
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: bsiegert Date: Tue Sep 5 11:58:55 UTC 2017 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcp.c Log Message: dhcp: Fix classless static routes Assign the netwask correctly from the message. Cherry-picked from upstream in https://dev.marples.name/rDHC510c760cb24ef4b1b16cc14732c5ffe0fbb0d96d. This fixes route assignments when running on Google Compute Engine, which uses classless static routes. To generate a diff of this commit: cvs rdiff -u -r1.1.1.3 -r1.2 src/external/bsd/dhcpcd/dist/src/dhcp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.1.1.3 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.2 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.1.1.3 Fri Apr 14 09:53:07 2017 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Tue Sep 5 11:58:55 2017 @@ -452,7 +452,7 @@ decode_rfc3442_rt(struct rt_head *routes } sa_in_init(>rt_dest, ); - sa_in_init(>rt_dest, ); + sa_in_init(>rt_netmask, ); sa_in_init(>rt_gateway, ); /* If CIDR is 32 then it's a host route. */
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: roy Date: Wed May 10 11:03:44 UTC 2017 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcpcd.c if-options.c Log Message: Sync To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcpcd/dist/src/dhcpcd.c \ src/external/bsd/dhcpcd/dist/src/if-options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.3 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.4 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.3 Fri Apr 14 09:56:32 2017 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Wed May 10 11:03:44 2017 @@ -477,6 +477,10 @@ configure_interface1(struct interface *i * between reboots without persitent storage, * generating the IAID from the MAC address is the only * logical default. + * Saying that, if a VLANID has been specified then we + * can use that. It's possible that different interfaces + * can have the same VLANID, but this is no worse than + * generating the IAID from the duplicate MAC address. * * dhclient uses the last 4 bytes of the MAC address. * dibbler uses an increamenting counter. @@ -487,11 +491,18 @@ configure_interface1(struct interface *i * dhcpcd-6.1.0 and earlier used the interface name, * falling back to interface index if name > 4. */ - if (ifp->hwlen >= sizeof(ifo->iaid)) + if (ifp->vlanid != 0) { + uint32_t vlanid; + + /* Maximal VLANID is 4095, so prefix with 0xff + * so we don't conflict with an interface index. */ + vlanid = htonl(ifp->vlanid | 0xff00); + memcpy(ifo->iaid, , sizeof(vlanid)); + } else if (ifp->hwlen >= sizeof(ifo->iaid)) { memcpy(ifo->iaid, ifp->hwaddr + ifp->hwlen - sizeof(ifo->iaid), sizeof(ifo->iaid)); - else { + } else { uint32_t len; len = (uint32_t)strlen(ifp->name); @@ -503,7 +514,7 @@ configure_interface1(struct interface *i } else { /* IAID is the same size as a uint32_t */ len = htonl(ifp->index); -memcpy(ifo->iaid, , sizeof(len)); +memcpy(ifo->iaid, , sizeof(ifo->iaid)); } } ifo->options |= DHCPCD_IAID; @@ -775,7 +786,7 @@ warn_iaid_conflict(struct interface *ifp /* This is only a problem if the interfaces are on the same network. */ if (ifn) - logerr("%s: IAID conflicts with one assigned to %s", + logerrx("%s: IAID conflicts with one assigned to %s", ifp->name, ifn->name); } @@ -1510,6 +1521,7 @@ main(int argc, char **argv) #endif case 'P': ctx.options |= DHCPCD_PRINT_PIDFILE; + logopts &= ~(LOGERR_LOG | LOGERR_ERR); break; case 'T': i = 1; @@ -1603,10 +1615,12 @@ printpidfile: * instance for that interface. */ if (optind == argc - 1 && !(ctx.options & DHCPCD_MASTER)) { const char *per; + const char *ifname; - if (strlen(argv[optind]) > IF_NAMESIZE) { -logerrx("%s: interface name too long", -argv[optind]); + ifname = *ctx.ifv; + if (ifname == NULL || strlen(ifname) > IF_NAMESIZE) { +errno = ifname == NULL ? EINVAL : E2BIG; +logerr("%s: ", ifname); goto exit_failure; } /* Allow a dhcpcd interface per address family */ @@ -1621,7 +1635,7 @@ printpidfile: per = ""; } snprintf(ctx.pidfile, sizeof(ctx.pidfile), - PIDFILE, "-", argv[optind], per); + PIDFILE, "-", ifname, per); } else { snprintf(ctx.pidfile, sizeof(ctx.pidfile), PIDFILE, "", "", ""); @@ -1643,20 +1657,13 @@ printpidfile: goto exit_failure; } - /* Open our persistent sockets. - * This is needed early for dumping leases on valid interfaces. */ -#ifdef USE_SIGNALS - if (sig == 0) { -#endif + if (ctx.options & DHCPCD_DUMPLEASE) { + /* Open sockets so we can dump something about + * valid interfaces. */ if (if_opensockets() == -1) { logerr("%s: if_opensockets", __func__); goto exit_failure; } -#ifdef USE_SIGNALS - } -#endif - - if (ctx.options & DHCPCD_DUMPLEASE) { if (optind != argc) { /* We need to try and find the interface so we can load * the hardware address to compare automated IAID */ @@ -1803,6 +1810,12 @@ printpidfile: logdebugx(PACKAGE "-" VERSION " starting"); ctx.options |= DHCPCD_STARTED; + + if (if_opensockets() == -1) { + logerr("%s: if_opensockets", __func__); + goto exit_failure; + } + #ifdef USE_SIGNALS if (eloop_signal_set_cb(ctx.eloop, dhcpcd_signals, dhcpcd_signals_len, Index: src/external/bsd/dhcpcd/dist/src/if-options.c diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.3 src/external/bsd/dhcpcd/dist/src/if-options.c:1.4 --- src/external/bsd/dhcpcd/dist/src/if-options.c:1.3 Fri Apr 14 09:56:32 2017 +++ src/external/bsd/dhcpcd/dist/src/if-options.c Wed May 10 11:03:44 2017 @@ -93,7 +93,7 @@ #define O_IPV6 O_BASE + 33 #define O_CONTROLGRP O_BASE + 34 #define O_SLAAC O_BASE + 35 -// unused O_BASE +
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: christos Date: Thu Apr 6 14:01:27 UTC 2017 Modified Files: src/external/bsd/dhcpcd/dist/src: if-options.c Log Message: The last stderr message felt lonely and committed suicide. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/dhcpcd/dist/src/if-options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/if-options.c diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.1.1.1 src/external/bsd/dhcpcd/dist/src/if-options.c:1.2 --- src/external/bsd/dhcpcd/dist/src/if-options.c:1.1.1.1 Fri Mar 31 16:51:16 2017 +++ src/external/bsd/dhcpcd/dist/src/if-options.c Thu Apr 6 10:01:27 2017 @@ -2138,8 +2138,8 @@ parse_config_line(struct dhcpcd_ctx *ctx continue; if (cf_options[i].has_arg == required_argument && !line) { - fprintf(stderr, - PACKAGE ": option requires an argument -- %s\n", + syslog(LOG_ERR, + PACKAGE ": option requires an argument -- %s", opt); return -1; }
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: christos Date: Thu Apr 6 14:00:34 UTC 2017 Modified Files: src/external/bsd/dhcpcd/dist/src: dhcpcd.c Log Message: transposition police! To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/dhcpcd/dist/src/dhcpcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.1.1.1 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.2 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.1.1.1 Fri Mar 31 16:51:15 2017 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Thu Apr 6 10:00:34 2017 @@ -1494,7 +1494,7 @@ main(int argc, char **argv) #ifdef USE_SIGNALS case 'k': sig = SIGALRM; - siga = "ARLM"; + siga = "ALRM"; break; case 'n': sig = SIGHUP;
CVS commit: src/external/bsd/dhcpcd/dist/src
Module Name:src Committed By: kamil Date: Mon Apr 3 00:42:20 UTC 2017 Modified Files: src/external/bsd/dhcpcd/dist/src: bpf.c Log Message: Try to fix build of dhcpcd (bpf.c) - violation of stack protector (GCC) Patch obtained from To generate a diff of this commit: cvs rdiff -u -r1.1.1.2 -r1.2 src/external/bsd/dhcpcd/dist/src/bpf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/dist/src/bpf.c diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.1.1.2 src/external/bsd/dhcpcd/dist/src/bpf.c:1.2 --- src/external/bsd/dhcpcd/dist/src/bpf.c:1.1.1.2 Sun Apr 2 18:54:20 2017 +++ src/external/bsd/dhcpcd/dist/src/bpf.c Mon Apr 3 00:42:20 2017 @@ -419,13 +419,13 @@ static const struct bpf_insn bpf_arp_fil BPF_STMT(BPF_RET + BPF_K, 0), }; #define bpf_arp_filter_len __arraycount(bpf_arp_filter) -#define bpf_arp_extra (((ARP_ADDRS_MAX + 1) * 2) * 2) + 2 +#define bpf_arp_extra ARP_ADDRS_MAX + 1) * 2) * 2) + 2) +#define bpf_arp_hw HWADDR_LEN / 4) + 2) * 2) + 1) int bpf_arp(struct interface *ifp, int fd) { - size_t bpf_hw = (((sizeof(ifp->hwaddr) / 4) + 2) * 2) + 1; - struct bpf_insn bpf[3 + bpf_arp_filter_len + bpf_hw + bpf_arp_extra]; + struct bpf_insn bpf[3+ bpf_arp_filter_len + bpf_arp_hw + bpf_arp_extra]; struct bpf_insn *bp; struct iarp_state *state; @@ -449,7 +449,7 @@ bpf_arp(struct interface *ifp, int fd) bp += bpf_arp_filter_len; /* Ensure it's not from us. */ - bp += bpf_cmp_hwaddr(bp, bpf_hw, sizeof(struct arphdr), + bp += bpf_cmp_hwaddr(bp, bpf_arp_hw, sizeof(struct arphdr), false, ifp->hwaddr, ifp->hwlen); state = ARP_STATE(ifp);