Module Name: src Committed By: martin Date: Sat Oct 12 14:44:33 UTC 2019
Modified Files: src/doc [netbsd-9]: 3RDPARTY src/external/bsd/dhcpcd/dist/src [netbsd-9]: arp.c bpf.c bpf.h common.c common.h control.h defs.h dhcp-common.c dhcp-common.h dhcp.c dhcp.h dhcp6.c dhcpcd.8.in dhcpcd.c dhcpcd.conf.5.in if-bsd.c if-options.c if.c if.h ipv4.c ipv4.h ipv4ll.c ipv4ll.h ipv6.c ipv6.h ipv6nd.c route.c src/external/bsd/dhcpcd/sbin/dhcpcd [netbsd-9]: Makefile Added Files: src/external/bsd/dhcpcd [netbsd-9]: NetBSD-upgrade src/external/bsd/dhcpcd/dist/src [netbsd-9]: dhcpcd-embedded.c dhcpcd-embedded.h Removed Files: src/external/bsd/dhcpcd/dist [netbsd-9]: .gitignore BUILDING.md Makefile Makefile.inc config-null.mk configure iconfig.mk src/external/bsd/dhcpcd/dist/compat [netbsd-9]: _strtoi.h arc4random.c arc4random.h arc4random_uniform.c arc4random_uniform.h bitops.h consttime_memequal.h dprintf.c dprintf.h endian.h pidfile.c pidfile.h queue.h rb.c rbtree.h reallocarray.c reallocarray.h strlcpy.c strlcpy.h strtoi.c strtoi.h strtou.c src/external/bsd/dhcpcd/dist/compat/crypt [netbsd-9]: hmac.c hmac.h md5.c md5.h sha256.c sha256.h src/external/bsd/dhcpcd/dist/hooks [netbsd-9]: 50-dhcpcd-compat 50-yp.conf Makefile src/external/bsd/dhcpcd/dist/src [netbsd-9]: GNUmakefile Makefile dev.c dhcpcd-definitions-small.conf dhcpcd-definitions.conf dhcpcd-embedded.c.in dhcpcd-embedded.h.in genembedc genembedh if-linux-wext.c if-linux.c if-sun.c src/external/bsd/dhcpcd/dist/src/dev [netbsd-9]: Makefile udev.c src/external/bsd/dhcpcd/dist/tests [netbsd-9]: Makefile src/external/bsd/dhcpcd/dist/tests/crypt [netbsd-9]: .gitignore GNUmakefile Makefile README.md run-test.c test.h test_hmac_md5.c src/external/bsd/dhcpcd/dist/tests/eloop-bench [netbsd-9]: .gitignore Makefile README.md eloop-bench.c Log Message: Pull up the following revisions, requested by roy in ticket #302: external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c up to 1.1.1.2 external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h up to 1.1.1.2 external/bsd/dhcpcd/NetBSD-upgrade up to 1.2 external/bsd/dhcpcd/dist/compat/crypt/sha256.c delete external/bsd/dhcpcd/dist/compat/crypt/hmac.c delete external/bsd/dhcpcd/dist/compat/crypt/hmac.h delete external/bsd/dhcpcd/dist/compat/crypt/md5.c delete external/bsd/dhcpcd/dist/compat/crypt/md5.h delete external/bsd/dhcpcd/dist/compat/crypt/sha256.h delete external/bsd/dhcpcd/dist/compat/_strtoi.h delete external/bsd/dhcpcd/dist/compat/arc4random.c delete external/bsd/dhcpcd/dist/compat/arc4random.h delete external/bsd/dhcpcd/dist/compat/arc4random_uniform.c delete external/bsd/dhcpcd/dist/compat/arc4random_uniform.h delete external/bsd/dhcpcd/dist/compat/bitops.h delete external/bsd/dhcpcd/dist/compat/consttime_memequal.h delete external/bsd/dhcpcd/dist/compat/dprintf.c delete external/bsd/dhcpcd/dist/compat/dprintf.h delete external/bsd/dhcpcd/dist/compat/endian.h delete external/bsd/dhcpcd/dist/compat/pidfile.c delete external/bsd/dhcpcd/dist/compat/pidfile.h delete external/bsd/dhcpcd/dist/compat/queue.h delete external/bsd/dhcpcd/dist/compat/rb.c delete external/bsd/dhcpcd/dist/compat/rbtree.h delete external/bsd/dhcpcd/dist/compat/reallocarray.c delete external/bsd/dhcpcd/dist/compat/reallocarray.h delete external/bsd/dhcpcd/dist/compat/strlcpy.c delete external/bsd/dhcpcd/dist/compat/strlcpy.h delete external/bsd/dhcpcd/dist/compat/strtoi.c delete external/bsd/dhcpcd/dist/compat/strtoi.h delete external/bsd/dhcpcd/dist/compat/strtou.c delete external/bsd/dhcpcd/dist/.gitignore delete external/bsd/dhcpcd/dist/BUILDING.md delete external/bsd/dhcpcd/dist/Makefile delete external/bsd/dhcpcd/dist/Makefile.inc delete external/bsd/dhcpcd/dist/config-null.mk delete external/bsd/dhcpcd/dist/configure delete external/bsd/dhcpcd/dist/iconfig.mk delete external/bsd/dhcpcd/dist/hooks/Makefile delete external/bsd/dhcpcd/dist/hooks/50-dhcpcd-compat delete external/bsd/dhcpcd/dist/hooks/50-yp.conf delete external/bsd/dhcpcd/dist/src/Makefile delete external/bsd/dhcpcd/dist/src/GNUmakefile delete external/bsd/dhcpcd/dist/src/dev.c delete external/bsd/dhcpcd/dist/src/dhcpcd-definitions-small.conf delete external/bsd/dhcpcd/dist/src/dhcpcd-definitions.conf delete external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c.in delete external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h.in delete external/bsd/dhcpcd/dist/src/genembedc delete external/bsd/dhcpcd/dist/src/genembedh delete external/bsd/dhcpcd/dist/src/if-linux-wext.c delete external/bsd/dhcpcd/dist/src/if-linux.c delete external/bsd/dhcpcd/dist/src/if-sun.c delete external/bsd/dhcpcd/dist/src/dev/Makefile delete external/bsd/dhcpcd/dist/src/dev/udev.c delete external/bsd/dhcpcd/dist/tests/crypt/.gitignore delete external/bsd/dhcpcd/dist/tests/crypt/GNUmakefile delete external/bsd/dhcpcd/dist/tests/crypt/Makefile delete external/bsd/dhcpcd/dist/tests/crypt/README.md delete external/bsd/dhcpcd/dist/tests/crypt/run-test.c delete external/bsd/dhcpcd/dist/tests/crypt/test.h delete external/bsd/dhcpcd/dist/tests/crypt/test_hmac_md5.c delete external/bsd/dhcpcd/dist/tests/Makefile delete external/bsd/dhcpcd/dist/tests/eloop-bench/.gitignore delete external/bsd/dhcpcd/dist/tests/eloop-bench/Makefile delete external/bsd/dhcpcd/dist/tests/eloop-bench/README.md delete external/bsd/dhcpcd/dist/tests/eloop-bench/eloop-bench.c delete external/bsd/dhcpcd/dist/src/arp.c up to 1.1.1.12 external/bsd/dhcpcd/dist/src/bpf.c up to 1.13 external/bsd/dhcpcd/dist/src/bpf.h up to 1.1.1.7 external/bsd/dhcpcd/dist/src/common.c up to 1.1.1.9 external/bsd/dhcpcd/dist/src/common.h up to 1.1.1.9 external/bsd/dhcpcd/dist/src/control.h up to 1.1.1.6 external/bsd/dhcpcd/dist/src/defs.h up to 1.1.1.30 external/bsd/dhcpcd/dist/src/dhcp-common.c up to 1.1.1.9 external/bsd/dhcpcd/dist/src/dhcp-common.h up to 1.1.1.5 external/bsd/dhcpcd/dist/src/dhcp.c up to 1.28 external/bsd/dhcpcd/dist/src/dhcp.h up to 1.1.1.11 external/bsd/dhcpcd/dist/src/dhcp6.c up to 1.13 external/bsd/dhcpcd/dist/src/dhcpcd.8.in up to 1.4 external/bsd/dhcpcd/dist/src/dhcpcd.c up to 1.27 external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in up to 1.1.1.15 external/bsd/dhcpcd/dist/src/if-bsd.c up to 1.14 external/bsd/dhcpcd/dist/src/if-options.c up to 1.18 external/bsd/dhcpcd/dist/src/if.c up to 1.1.1.17 external/bsd/dhcpcd/dist/src/if.h up to 1.1.1.12 external/bsd/dhcpcd/dist/src/ipv4.c up to 1.1.1.18 external/bsd/dhcpcd/dist/src/ipv4.h up to 1.1.1.11 external/bsd/dhcpcd/dist/src/ipv4ll.c up to 1.1.1.10 external/bsd/dhcpcd/dist/src/ipv4ll.h up to 1.1.1.8 external/bsd/dhcpcd/dist/src/ipv6.c up to 1.5 external/bsd/dhcpcd/dist/src/ipv6.h up to 1.6 external/bsd/dhcpcd/dist/src/ipv6nd.c up to 1.12 external/bsd/dhcpcd/dist/src/route.c up to 1.1.1.15 external/bsd/dhcpcd/sbin/dhcpcd/Makefile up to 1.49 doc/3RDPARTY modified manually Import dhcpcd-8.1.0 with the following changes: * Fix carrier status after a route socket overflow * Allow domain spaced options * DHCP: Allow not sending Force Renew Nonce or Reconf Accept * IPv4LL: Now passes Apple Bonjour test versions 1.4 and 1.5 * ARP: Fix a typo and remove pragma (thus working with old gcc) * DHCP6: Fix a cosmetic issue with infinite leases * DHCP6: SLA 0 and Prefix Len 0 will now add a delegatd /64 address * Ignore some virtual interfaces such as Tap and Bridge by default * BPF: Move validation logic out of BPF and back into dhcpcd To generate a diff of this commit: cvs rdiff -u -r1.1640.2.3 -r1.1640.2.4 src/doc/3RDPARTY cvs rdiff -u -r0 -r1.2.2.2 src/external/bsd/dhcpcd/NetBSD-upgrade cvs rdiff -u -r1.4 -r0 src/external/bsd/dhcpcd/dist/.gitignore cvs rdiff -u -r1.1.1.4.2.1 -r0 src/external/bsd/dhcpcd/dist/BUILDING.md cvs rdiff -u -r1.1.1.6.2.1 -r0 src/external/bsd/dhcpcd/dist/Makefile cvs rdiff -u -r1.1.1.2.8.1 -r0 src/external/bsd/dhcpcd/dist/Makefile.inc cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/dhcpcd/dist/config-null.mk cvs rdiff -u -r1.1.1.14.2.1 -r0 src/external/bsd/dhcpcd/dist/configure cvs rdiff -u -r1.1.1.2 -r0 src/external/bsd/dhcpcd/dist/iconfig.mk cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/dhcpcd/dist/compat/_strtoi.h \ src/external/bsd/dhcpcd/dist/compat/arc4random.c \ src/external/bsd/dhcpcd/dist/compat/arc4random.h \ src/external/bsd/dhcpcd/dist/compat/arc4random_uniform.c \ src/external/bsd/dhcpcd/dist/compat/arc4random_uniform.h \ src/external/bsd/dhcpcd/dist/compat/bitops.h \ src/external/bsd/dhcpcd/dist/compat/consttime_memequal.h \ src/external/bsd/dhcpcd/dist/compat/endian.h \ src/external/bsd/dhcpcd/dist/compat/pidfile.c \ src/external/bsd/dhcpcd/dist/compat/pidfile.h \ src/external/bsd/dhcpcd/dist/compat/queue.h \ src/external/bsd/dhcpcd/dist/compat/reallocarray.c \ src/external/bsd/dhcpcd/dist/compat/reallocarray.h \ src/external/bsd/dhcpcd/dist/compat/strlcpy.c \ src/external/bsd/dhcpcd/dist/compat/strlcpy.h \ src/external/bsd/dhcpcd/dist/compat/strtoi.c \ src/external/bsd/dhcpcd/dist/compat/strtoi.h \ src/external/bsd/dhcpcd/dist/compat/strtou.c cvs rdiff -u -r1.1.1.2 -r0 src/external/bsd/dhcpcd/dist/compat/dprintf.c \ src/external/bsd/dhcpcd/dist/compat/dprintf.h cvs rdiff -u -r1.1.1.1.2.1 -r0 src/external/bsd/dhcpcd/dist/compat/rb.c \ src/external/bsd/dhcpcd/dist/compat/rbtree.h cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/dhcpcd/dist/compat/crypt/hmac.c \ src/external/bsd/dhcpcd/dist/compat/crypt/hmac.h \ src/external/bsd/dhcpcd/dist/compat/crypt/md5.c \ src/external/bsd/dhcpcd/dist/compat/crypt/sha256.h cvs rdiff -u -r1.1.1.2 -r0 src/external/bsd/dhcpcd/dist/compat/crypt/md5.h \ src/external/bsd/dhcpcd/dist/compat/crypt/sha256.c cvs rdiff -u -r1.1.1.1 -r0 \ src/external/bsd/dhcpcd/dist/hooks/50-dhcpcd-compat cvs rdiff -u -r1.2 -r0 src/external/bsd/dhcpcd/dist/hooks/50-yp.conf cvs rdiff -u -r1.1.1.1.20.1 -r0 src/external/bsd/dhcpcd/dist/hooks/Makefile cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/dhcpcd/dist/src/GNUmakefile \ src/external/bsd/dhcpcd/dist/src/genembedc \ src/external/bsd/dhcpcd/dist/src/genembedh cvs rdiff -u -r1.1.1.5.2.1 -r0 src/external/bsd/dhcpcd/dist/src/Makefile cvs rdiff -u -r1.1.1.11 -r1.1.1.11.2.1 src/external/bsd/dhcpcd/dist/src/arp.c cvs rdiff -u -r1.11.2.1 -r1.11.2.2 src/external/bsd/dhcpcd/dist/src/bpf.c \ src/external/bsd/dhcpcd/dist/src/dhcp6.c cvs rdiff -u -r1.1.1.6 -r1.1.1.6.2.1 src/external/bsd/dhcpcd/dist/src/bpf.h cvs rdiff -u -r1.1.1.8 -r1.1.1.8.2.1 \ src/external/bsd/dhcpcd/dist/src/common.c \ src/external/bsd/dhcpcd/dist/src/common.h cvs rdiff -u -r1.1.1.4.2.1 -r1.1.1.4.2.2 \ src/external/bsd/dhcpcd/dist/src/control.h cvs rdiff -u -r1.1.1.25.2.1 -r1.1.1.25.2.2 \ src/external/bsd/dhcpcd/dist/src/defs.h cvs rdiff -u -r1.1.1.5 -r0 src/external/bsd/dhcpcd/dist/src/dev.c cvs rdiff -u -r1.1.1.6.2.1 -r1.1.1.6.2.2 \ src/external/bsd/dhcpcd/dist/src/dhcp-common.c cvs rdiff -u -r1.1.1.4 -r1.1.1.4.2.1 \ src/external/bsd/dhcpcd/dist/src/dhcp-common.h cvs rdiff -u -r1.23.2.1 -r1.23.2.2 src/external/bsd/dhcpcd/dist/src/dhcp.c \ src/external/bsd/dhcpcd/dist/src/dhcpcd.c cvs rdiff -u -r1.1.1.10 -r1.1.1.10.2.1 \ src/external/bsd/dhcpcd/dist/src/dhcp.h cvs rdiff -u -r1.1.1.2 -r0 \ src/external/bsd/dhcpcd/dist/src/dhcpcd-definitions-small.conf \ src/external/bsd/dhcpcd/dist/src/dhcpcd-definitions.conf cvs rdiff -u -r0 -r1.1.1.2.2.2 \ src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c \ src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h cvs rdiff -u -r1.1.1.3 -r0 \ src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c.in \ src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h.in cvs rdiff -u -r1.2.2.1 -r1.2.2.2 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in cvs rdiff -u -r1.1.1.13.2.1 -r1.1.1.13.2.2 \ src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in cvs rdiff -u -r1.10.2.1 -r1.10.2.2 src/external/bsd/dhcpcd/dist/src/if-bsd.c \ src/external/bsd/dhcpcd/dist/src/ipv6nd.c cvs rdiff -u -r1.1.1.4 -r0 src/external/bsd/dhcpcd/dist/src/if-linux-wext.c cvs rdiff -u -r1.1.1.14.2.1 -r0 src/external/bsd/dhcpcd/dist/src/if-linux.c cvs rdiff -u -r1.16.2.1 -r1.16.2.2 \ src/external/bsd/dhcpcd/dist/src/if-options.c cvs rdiff -u -r1.1.1.10.2.1 -r0 src/external/bsd/dhcpcd/dist/src/if-sun.c cvs rdiff -u -r1.1.1.14.2.1 -r1.1.1.14.2.2 \ src/external/bsd/dhcpcd/dist/src/if.c cvs rdiff -u -r1.1.1.10.2.1 -r1.1.1.10.2.2 \ src/external/bsd/dhcpcd/dist/src/if.h cvs rdiff -u -r1.1.1.16.2.1 -r1.1.1.16.2.2 \ src/external/bsd/dhcpcd/dist/src/ipv4.c cvs rdiff -u -r1.1.1.9.2.1 -r1.1.1.9.2.2 \ src/external/bsd/dhcpcd/dist/src/ipv4.h cvs rdiff -u -r1.1.1.9 -r1.1.1.9.2.1 \ src/external/bsd/dhcpcd/dist/src/ipv4ll.c cvs rdiff -u -r1.1.1.7 -r1.1.1.7.2.1 \ src/external/bsd/dhcpcd/dist/src/ipv4ll.h cvs rdiff -u -r1.3.2.1 -r1.3.2.2 src/external/bsd/dhcpcd/dist/src/ipv6.c \ src/external/bsd/dhcpcd/dist/src/ipv6.h cvs rdiff -u -r1.1.1.12.2.1 -r1.1.1.12.2.2 \ src/external/bsd/dhcpcd/dist/src/route.c cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/dhcpcd/dist/src/dev/Makefile cvs rdiff -u -r1.1.1.4 -r0 src/external/bsd/dhcpcd/dist/src/dev/udev.c cvs rdiff -u -r1.1.1.2 -r0 src/external/bsd/dhcpcd/dist/tests/Makefile cvs rdiff -u -r1.1.1.1 -r0 \ src/external/bsd/dhcpcd/dist/tests/crypt/.gitignore \ src/external/bsd/dhcpcd/dist/tests/crypt/GNUmakefile \ src/external/bsd/dhcpcd/dist/tests/crypt/README.md cvs rdiff -u -r1.1.1.2 -r0 src/external/bsd/dhcpcd/dist/tests/crypt/Makefile \ src/external/bsd/dhcpcd/dist/tests/crypt/run-test.c \ src/external/bsd/dhcpcd/dist/tests/crypt/test.h cvs rdiff -u -r1.1.1.3 -r0 \ src/external/bsd/dhcpcd/dist/tests/crypt/test_hmac_md5.c cvs rdiff -u -r1.1.1.1 -r0 \ src/external/bsd/dhcpcd/dist/tests/eloop-bench/.gitignore \ src/external/bsd/dhcpcd/dist/tests/eloop-bench/README.md cvs rdiff -u -r1.1.1.2 -r0 \ src/external/bsd/dhcpcd/dist/tests/eloop-bench/Makefile cvs rdiff -u -r1.1.1.3 -r0 \ src/external/bsd/dhcpcd/dist/tests/eloop-bench/eloop-bench.c cvs rdiff -u -r1.48 -r1.48.2.1 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/doc/3RDPARTY diff -u src/doc/3RDPARTY:1.1640.2.3 src/doc/3RDPARTY:1.1640.2.4 --- src/doc/3RDPARTY:1.1640.2.3 Tue Sep 17 19:51:12 2019 +++ src/doc/3RDPARTY Sat Oct 12 14:44:31 2019 @@ -1,4 +1,4 @@ -# $NetBSD: 3RDPARTY,v 1.1640.2.3 2019/09/17 19:51:12 martin Exp $ +# $NetBSD: 3RDPARTY,v 1.1640.2.4 2019/10/12 14:44:31 martin Exp $ # # This file contains a list of the software that has been integrated into # NetBSD where we are not the primary maintainer. @@ -341,12 +341,12 @@ Notes: Use the dhcp2netbsd script. Package: dhcpcd -Version: 8.0.2 -Current Vers: 8.0.2 +Version: 8.1.0 +Current Vers: 8.1.0 Maintainer: roy Archive Site: ftp://roy.marples.name/pub/dhcpcd/ Home Page: http://roy.marples.name/projects/dhcpcd/ -Date: 2019-07-30 +Date: 2019-10-12 Mailing List: dhcpcd-disc...@marples.name License: BSD (2-clause) Location: external/bsd/dhcpcd/dist Index: src/external/bsd/dhcpcd/dist/src/arp.c diff -u src/external/bsd/dhcpcd/dist/src/arp.c:1.1.1.11 src/external/bsd/dhcpcd/dist/src/arp.c:1.1.1.11.2.1 --- src/external/bsd/dhcpcd/dist/src/arp.c:1.1.1.11 Wed Jul 24 09:54:49 2019 +++ src/external/bsd/dhcpcd/dist/src/arp.c Sat Oct 12 14:44:32 2019 @@ -129,12 +129,11 @@ arp_report_conflicted(const struct arp_s inet_ntoa(astate->addr)); } - static void arp_found(struct arp_state *astate, const struct arp_msg *amsg) { struct interface *ifp; - struct ivp4_addr *ia; + struct ipv4_addr *ia; #ifndef KERNEL_RFC5227 struct timespec now, defend; #endif @@ -142,11 +141,8 @@ arp_found(struct arp_state *astate, cons arp_report_conflicted(astate, amsg); ifp = astate->iface; -#pragma GCC diagnostic push /* GCC is clearly wrong about this warning. */ -#pragma GCC diagnostic ignored "-Wincompatible-pointer-types" /* If we haven't added the address we're doing a probe. */ ia = ipv4_iffindaddr(ifp, &astate->addr, NULL); -#pragma GCC diagnostic pop if (ia == NULL) { if (astate->found_cb != NULL) astate->found_cb(astate, amsg); @@ -182,6 +178,35 @@ arp_found(struct arp_state *astate, cons astate->defend_failed_cb(astate); } +static bool +arp_validate(const struct interface *ifp, struct arphdr *arp) +{ + + /* Families must match */ + if (arp->ar_hrd != htons(ifp->family)) + return false; + + /* Protocol must be IP. */ + if (arp->ar_pro != htons(ETHERTYPE_IP)) + return false; + + /* lladdr length matches */ + if (arp->ar_hln != ifp->hwlen) + return false; + + /* Protocol length must match in_addr_t */ + if (arp->ar_pln != sizeof(in_addr_t)) + return false; + + /* Only these types are recognised */ + if (arp->ar_op != htons(ARPOP_REPLY) && + arp->ar_op != htons(ARPOP_REQUEST)) + return false; + + return true; +} + + static void arp_packet(struct interface *ifp, uint8_t *data, size_t len) { @@ -197,25 +222,12 @@ arp_packet(struct interface *ifp, uint8_ return; memcpy(&ar, data, sizeof(ar)); - /* These checks are enforced in the BPF filter. */ -#if 0 - /* Families must match */ - if (ar.ar_hrd != htons(ifp->family)) - return; - /* Protocol must be IP. */ - if (ar.ar_pro != htons(ETHERTYPE_IP)) - continue; - /* lladdr length matches */ - if (ar.ar_hln != ifp->hwlen) - continue; - /* Protocol length must match in_addr_t */ - if (ar.ar_pln != sizeof(arm.sip.s_addr)) - return; - /* Only these types are recognised */ - if (ar.ar_op != htons(ARPOP_REPLY) && - ar.ar_op != htons(ARPOP_REQUEST)) - continue; + if (!arp_validate(ifp, &ar)) { +#ifdef BPF_DEBUG + logerrx("%s: ARP BPF validation failure", ifp->name); #endif + return; + } /* Get pointers to the hardware addresses */ hw_s = data + sizeof(ar); @@ -329,10 +341,8 @@ arp_open(struct interface *ifp) state = ARP_STATE(ifp); if (state->bpf_fd == -1) { state->bpf_fd = bpf_open(ifp, bpf_arp); - if (state->bpf_fd == -1) { - logerr("%s: %s", __func__, ifp->name); + if (state->bpf_fd == -1) return -1; - } eloop_event_add(ifp->ctx->eloop, state->bpf_fd, arp_read, ifp); } return state->bpf_fd; @@ -428,6 +438,7 @@ arp_announce1(void *arg) { struct arp_state *astate = arg; struct interface *ifp = astate->iface; + struct ipv4_addr *ia; if (++astate->claims < ANNOUNCE_NUM) logdebugx("%s: ARP announcing %s (%d of %d), " @@ -438,24 +449,31 @@ arp_announce1(void *arg) logdebugx("%s: ARP announcing %s (%d of %d)", ifp->name, inet_ntoa(astate->addr), astate->claims, ANNOUNCE_NUM); + + /* The kernel will send a Gratuitous ARP for newly added addresses. + * So we can avoid sending the same. + * Linux is special and doesn't send one. */ + ia = ipv4_iffindaddr(ifp, &astate->addr, NULL); +#ifndef __linux__ + if (astate->claims == 1 && ia != NULL && ia->flags & IPV4_AF_NEW) + goto skip_request; +#endif + if (arp_request(ifp, &astate->addr, &astate->addr) == -1) logerr(__func__); + +#ifndef __linux__ +skip_request: +#endif + /* No longer a new address. */ + if (ia != NULL) + ia->flags |= ~IPV4_AF_NEW; + eloop_timeout_add_sec(ifp->ctx->eloop, ANNOUNCE_WAIT, astate->claims < ANNOUNCE_NUM ? arp_announce1 : arp_announced, astate); } -/* - * XXX FIXME - * Kernels supporting RFC5227 will announce the address when it's - * added. - * dhcpcd should not announce when this happens, nor need to open - * a BPF socket for it. - * Also, an address might be added to a non preferred inteface when - * the same address exists on a preferred one so we need to instruct - * the kernel not to announce the address somehow. - */ - void arp_announce(struct arp_state *astate) { @@ -501,6 +519,9 @@ arp_ifannounceaddr(struct interface *ifp { struct arp_state *astate; + if (ifp->flags & IFF_NOARP) + return; + astate = arp_find(ifp, ia); if (astate == NULL) { astate = arp_new(ifp, ia); Index: src/external/bsd/dhcpcd/dist/src/bpf.c diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.11.2.1 src/external/bsd/dhcpcd/dist/src/bpf.c:1.11.2.2 --- src/external/bsd/dhcpcd/dist/src/bpf.c:1.11.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/bpf.c Sat Oct 12 14:44:32 2019 @@ -410,13 +410,7 @@ bpf_cmp_hwaddr(struct bpf_insn *bpf, siz #endif #ifdef ARP - static const struct bpf_insn bpf_arp_ether [] = { - /* Ensure packet is at least correct size. */ - BPF_STMT(BPF_LD + BPF_W + BPF_LEN, 0), - BPF_JUMP(BPF_JMP + BPF_JGE + BPF_K, sizeof(struct ether_arp), 1, 0), - BPF_STMT(BPF_RET + BPF_K, 0), - /* Check this is an ARP packet. */ BPF_STMT(BPF_LD + BPF_H + BPF_ABS, offsetof(struct ether_header, ether_type)), @@ -552,17 +546,8 @@ bpf_arp(struct interface *ifp, int fd) } #endif -#define BPF_M_FHLEN 0 -#define BPF_M_IPHLEN 1 -#define BPF_M_IPLEN 2 -#define BPF_M_UDP 3 -#define BPF_M_UDPLEN 4 - #ifdef ARPHRD_NONE static const struct bpf_insn bpf_bootp_none[] = { - /* Set the frame header length to zero. */ - BPF_STMT(BPF_LD + BPF_IMM, 0), - BPF_STMT(BPF_ST, BPF_M_FHLEN), }; #define BPF_BOOTP_NONE_LEN __arraycount(bpf_bootp_none) #endif @@ -574,13 +559,14 @@ static const struct bpf_insn bpf_bootp_e BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 1, 0), BPF_STMT(BPF_RET + BPF_K, 0), - /* Load frame header length into X. */ - BPF_STMT(BPF_LDX + BPF_W + BPF_IMM, sizeof(struct ether_header)), - /* Copy frame header length to memory */ - BPF_STMT(BPF_STX, BPF_M_FHLEN), + /* Advance to the IP header. */ + BPF_STMT(BPF_LDX + BPF_K, sizeof(struct ether_header)), }; #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_filter[] = { /* Make sure it's an IPv4 packet. */ BPF_STMT(BPF_LD + BPF_B + BPF_IND, 0), @@ -588,15 +574,6 @@ static const struct bpf_insn bpf_bootp_f BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0x40, 1, 0), BPF_STMT(BPF_RET + BPF_K, 0), - /* Ensure IP header length is big enough and - * store the IP header length in memory. */ - BPF_STMT(BPF_LD + BPF_B + BPF_IND, 0), - BPF_STMT(BPF_ALU + BPF_AND + BPF_K, 0x0f), - BPF_STMT(BPF_ALU + BPF_MUL + BPF_K, 4), - BPF_JUMP(BPF_JMP + BPF_JGE + BPF_K, sizeof(struct ip), 1, 0), - BPF_STMT(BPF_RET + BPF_K, 0), - BPF_STMT(BPF_ST, BPF_M_IPHLEN), - /* Make sure it's a UDP packet. */ BPF_STMT(BPF_LD + BPF_B + BPF_IND, offsetof(struct ip, ip_p)), BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_UDP, 1, 0), @@ -607,49 +584,17 @@ static const struct bpf_insn bpf_bootp_f BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, 0x1fff, 0, 1), BPF_STMT(BPF_RET + BPF_K, 0), - /* Store IP length. */ - BPF_STMT(BPF_LD + BPF_H + BPF_IND, offsetof(struct ip, ip_len)), - BPF_STMT(BPF_ST, BPF_M_IPLEN), - /* Advance to the UDP header. */ - BPF_STMT(BPF_LD + BPF_MEM, BPF_M_IPHLEN), + BPF_STMT(BPF_LD + BPF_B + BPF_IND, 0), + BPF_STMT(BPF_ALU + BPF_AND + BPF_K, 0x0f), + BPF_STMT(BPF_ALU + BPF_MUL + BPF_K, 4), BPF_STMT(BPF_ALU + BPF_ADD + BPF_X, 0), BPF_STMT(BPF_MISC + BPF_TAX, 0), - /* Store UDP location */ - BPF_STMT(BPF_STX, BPF_M_UDP), - /* Make sure it's from and to the right port. */ BPF_STMT(BPF_LD + BPF_W + BPF_IND, 0), BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, (BOOTPS << 16) + BOOTPC, 1, 0), BPF_STMT(BPF_RET + BPF_K, 0), - - /* Store UDP length. */ - BPF_STMT(BPF_LD + BPF_H + BPF_IND, offsetof(struct udphdr, uh_ulen)), - BPF_STMT(BPF_ST, BPF_M_UDPLEN), - - /* Ensure that UDP length + IP header length == IP length */ - /* Copy IP header length to X. */ - BPF_STMT(BPF_LDX + BPF_MEM, BPF_M_IPHLEN), - /* Add UDP length (A) to IP header length (X). */ - BPF_STMT(BPF_ALU + BPF_ADD + BPF_X, 0), - /* Store result in X. */ - BPF_STMT(BPF_MISC + BPF_TAX, 0), - /* Copy IP length to A. */ - BPF_STMT(BPF_LD + BPF_MEM, BPF_M_IPLEN), - /* Ensure X == A. */ - BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_X, 0, 1, 0), - BPF_STMT(BPF_RET + BPF_K, 0), - - /* Advance to the BOOTP packet. */ - BPF_STMT(BPF_LD + BPF_MEM, BPF_M_UDP), - BPF_STMT(BPF_ALU + BPF_ADD + BPF_K, sizeof(struct udphdr)), - BPF_STMT(BPF_MISC + BPF_TAX, 0), - - /* Make sure it's BOOTREPLY. */ - BPF_STMT(BPF_LD + BPF_B + BPF_IND, offsetof(struct bootp, op)), - BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, BOOTREPLY, 1, 0), - BPF_STMT(BPF_RET + BPF_K, 0), }; #define BPF_BOOTP_FILTER_LEN __arraycount(bpf_bootp_filter) @@ -729,14 +674,8 @@ bpf_bootp(struct interface *ifp, int fd) } #endif - /* All passed, return the packet - frame length + ip length */ - BPF_SET_STMT(bp, BPF_LD + BPF_MEM, BPF_M_FHLEN); - bp++; - BPF_SET_STMT(bp, BPF_LDX + BPF_MEM, BPF_M_IPLEN); - bp++; - BPF_SET_STMT(bp, BPF_ALU + BPF_ADD + BPF_X, 0); - bp++; - BPF_SET_STMT(bp, BPF_RET + BPF_A, 0); + /* All passed, return the packet. */ + BPF_SET_STMT(bp, BPF_RET + BPF_K, BPF_WHOLEPACKET); bp++; return bpf_attach(fd, bpf, (unsigned int)(bp - bpf)); Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.11.2.1 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.11.2.2 --- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.11.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcp6.c Sat Oct 12 14:44:32 2019 @@ -532,13 +532,6 @@ dhcp6_delegateaddr(struct in6_addr *addr asla.prefix_len = 0; asla.sla_set = 0; sla = &asla; - } else if (sla->sla == 0 && sla->prefix_len == 0) { - /* An SLA of 0 was set with no prefix length specified. - * This means we delegate the whole prefix. */ - asla.sla = sla->sla; - asla.prefix_len = prefix->prefix_len; - asla.sla_set = 0; - sla = &asla; } else if (sla->prefix_len == 0) { /* An SLA was given, but prefix length was not. * We need to work out a suitable prefix length for @@ -680,27 +673,21 @@ dhcp6_makemessage(struct interface *ifp) break; } if (n < ifo->dhcp6_override_len) - continue; - if (!(opt->type & OT_NOREQ) && - (opt->type & OT_REQUEST || - has_option_mask(ifo->requestmask6, opt->option))) - { - n_options++; - len += sizeof(o.len); - } + continue; + if (!DHC_REQOPT(opt, ifo->requestmask6, ifo->nomask6)) + continue; + n_options++; + len += sizeof(o.len); } #ifndef SMALL for (l = 0, opt = ifo->dhcp6_override; l < ifo->dhcp6_override_len; l++, opt++) { - if (!(opt->type & OT_NOREQ) && - (opt->type & OT_REQUEST || - has_option_mask(ifo->requestmask6, opt->option))) - { - n_options++; - len += sizeof(o.len); - } + if (!DHC_REQOPT(opt, ifo->requestmask6, ifo->nomask6)) + continue; + n_options++; + len += sizeof(o.len); } if (dhcp6_findselfsla(ifp)) { n_options++; @@ -1037,7 +1024,8 @@ dhcp6_makemessage(struct interface *ifp) #ifdef AUTH if ((ifo->auth.options & DHCPCD_AUTH_SENDREQUIRE) != - DHCPCD_AUTH_SENDREQUIRE) + DHCPCD_AUTH_SENDREQUIRE && + !has_option_mask(ifo->nomask6, D6_OPTION_RECONF_ACCEPT)) COPYIN1(D6_OPTION_RECONF_ACCEPT, 0); #endif @@ -1060,34 +1048,26 @@ dhcp6_makemessage(struct interface *ifp) if (n < ifo->dhcp6_override_len) continue; #endif - if (!(opt->type & OT_NOREQ) && - (opt->type & OT_REQUEST || - has_option_mask(ifo->requestmask6, - opt->option))) - { - o.code = htons((uint16_t)opt->option); - memcpy(p, &o.code, sizeof(o.code)); - p += sizeof(o.code); - o.len = (uint16_t) - (o.len + sizeof(o.code)); - } + if (!DHC_REQOPT(opt, ifo->requestmask6, + ifo->nomask6)) + continue; + o.code = htons((uint16_t)opt->option); + memcpy(p, &o.code, sizeof(o.code)); + p += sizeof(o.code); + o.len = (uint16_t)(o.len + sizeof(o.code)); } #ifndef SMALL for (l = 0, opt = ifo->dhcp6_override; l < ifo->dhcp6_override_len; l++, opt++) { - if (!(opt->type & OT_NOREQ) && - (opt->type & OT_REQUEST || - has_option_mask(ifo->requestmask6, - opt->option))) - { - o.code = htons((uint16_t)opt->option); - memcpy(p, &o.code, sizeof(o.code)); - p += sizeof(o.code); - o.len = (uint16_t) - (o.len + sizeof(o.code)); - } + if (!DHC_REQOPT(opt, ifo->requestmask6, + ifo->nomask6)) + continue; + o.code = htons((uint16_t)opt->option); + memcpy(p, &o.code, sizeof(o.code)); + p += sizeof(o.code); + o.len = (uint16_t)(o.len + sizeof(o.code)); } if (dhcp6_findselfsla(ifp)) { o.code = htons(D6_OPTION_PD_EXCLUDE); @@ -3008,7 +2988,9 @@ dhcp6_bind(struct interface *ifp, const TAILQ_FOREACH(ia, &state->addrs, next) { if (ia->flags & IPV6_AF_STALE) continue; - if (ia->prefix_vltime <= state->renew) + if (!(state->renew == ND6_INFINITE_LIFETIME && + ia->prefix_vltime == ND6_INFINITE_LIFETIME) + && ia->prefix_vltime <= state->renew) logwarnx( "%s: %s will expire before renewal", ifp->name, ia->saddr); @@ -3152,6 +3134,8 @@ dhcp6_bind(struct interface *ifp, const if (state->state == DH6S_INFORMED) lognewinfo("%s: refresh in %"PRIu32" seconds", ifp->name, state->renew); + else if (state->renew == ND6_INFINITE_LIFETIME) + lognewinfo("%s: leased for infinity", ifp->name); else if (state->renew || state->rebind) lognewinfo("%s: renew in %"PRIu32", " "rebind in %"PRIu32", " Index: src/external/bsd/dhcpcd/dist/src/bpf.h diff -u src/external/bsd/dhcpcd/dist/src/bpf.h:1.1.1.6 src/external/bsd/dhcpcd/dist/src/bpf.h:1.1.1.6.2.1 --- src/external/bsd/dhcpcd/dist/src/bpf.h:1.1.1.6 Wed Jul 24 09:54:49 2019 +++ src/external/bsd/dhcpcd/dist/src/bpf.h Sat Oct 12 14:44:32 2019 @@ -34,6 +34,25 @@ #define BPF_PARTIALCSUM (1U << 2) #define BPF_BCAST (1U << 3) +/* + * Even though we program the BPF filter should we trust it? + * On Linux at least there is a window between opening the socket, + * binding the interface and setting the filter where we receive data. + * This data is NOT checked OR flushed and IS returned when reading. + * We have no way of flushing it other than reading these packets! + * But we don't know if they passed the filter or not ..... so we need + * to validate each and every packet that comes through ourselves as well. + * Even if Linux does fix this sorry state, who is to say other kernels + * don't have bugs causing a similar effect? + * + * As such, let's strive to keep the filters just for pattern matching + * to avoid waking dhcpcd up. + * + * If you want to be notified of any packet failing the BPF filter, + * define BPF_DEBUG below. + */ +//#define BPF_DEBUG + #include "dhcpcd.h" extern const char *bpf_name; Index: src/external/bsd/dhcpcd/dist/src/common.c diff -u src/external/bsd/dhcpcd/dist/src/common.c:1.1.1.8 src/external/bsd/dhcpcd/dist/src/common.c:1.1.1.8.2.1 --- src/external/bsd/dhcpcd/dist/src/common.c:1.1.1.8 Wed Jul 24 09:54:49 2019 +++ src/external/bsd/dhcpcd/dist/src/common.c Sat Oct 12 14:44:32 2019 @@ -26,28 +26,12 @@ * SUCH DAMAGE. */ -#include <sys/param.h> -#include <sys/time.h> -#ifdef __sun -#include <sys/sysmacros.h> -#endif +#include <sys/statvfs.h> -#include <assert.h> #include <ctype.h> -#include <err.h> #include <errno.h> -#include <fcntl.h> -#include <limits.h> -#ifdef BSD -# include <paths.h> -#endif -#include <stdarg.h> -#include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> -#include <time.h> -#include <unistd.h> #include "common.h" #include "dhcpcd.h" @@ -153,3 +137,18 @@ read_hwaddr_aton(uint8_t **data, const c fclose(fp); return len; } + +int +is_root_local(void) +{ +#ifdef ST_LOCAL + struct statvfs vfs; + + if (statvfs("/", &vfs) == -1) + return -1; + return vfs.f_flag & ST_LOCAL ? 1 : 0; +#else + errno = ENOTSUP; + return -1; +#endif +} Index: src/external/bsd/dhcpcd/dist/src/common.h diff -u src/external/bsd/dhcpcd/dist/src/common.h:1.1.1.8 src/external/bsd/dhcpcd/dist/src/common.h:1.1.1.8.2.1 --- src/external/bsd/dhcpcd/dist/src/common.h:1.1.1.8 Wed Jul 24 09:54:49 2019 +++ src/external/bsd/dhcpcd/dist/src/common.h Sat Oct 12 14:44:32 2019 @@ -197,4 +197,5 @@ int get_monotonic(struct timespec *); const char *hwaddr_ntoa(const void *, size_t, char *, size_t); size_t hwaddr_aton(uint8_t *, const char *); size_t read_hwaddr_aton(uint8_t **, const char *); +int is_root_local(void); #endif Index: src/external/bsd/dhcpcd/dist/src/control.h diff -u src/external/bsd/dhcpcd/dist/src/control.h:1.1.1.4.2.1 src/external/bsd/dhcpcd/dist/src/control.h:1.1.1.4.2.2 --- src/external/bsd/dhcpcd/dist/src/control.h:1.1.1.4.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/control.h Sat Oct 12 14:44:32 2019 @@ -29,6 +29,8 @@ #ifndef CONTROL_H #define CONTROL_H +#include <stdbool.h> + #include "dhcpcd.h" #if !defined(CTL_FREE_LIST) Index: src/external/bsd/dhcpcd/dist/src/defs.h diff -u src/external/bsd/dhcpcd/dist/src/defs.h:1.1.1.25.2.1 src/external/bsd/dhcpcd/dist/src/defs.h:1.1.1.25.2.2 --- src/external/bsd/dhcpcd/dist/src/defs.h:1.1.1.25.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/defs.h Sat Oct 12 14:44:32 2019 @@ -29,7 +29,7 @@ #define CONFIG_H #define PACKAGE "dhcpcd" -#define VERSION "8.0.4" +#define VERSION "8.1.0" #ifndef CONFIG # define CONFIG SYSCONFDIR "/" PACKAGE ".conf" Index: src/external/bsd/dhcpcd/dist/src/dhcp-common.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp-common.c:1.1.1.6.2.1 src/external/bsd/dhcpcd/dist/src/dhcp-common.c:1.1.1.6.2.2 --- src/external/bsd/dhcpcd/dist/src/dhcp-common.c:1.1.1.6.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcp-common.c Sat Oct 12 14:44:32 2019 @@ -200,6 +200,10 @@ make_option_mask(const struct dhcp_opt * while ((token = strsep(&p, ", "))) { if (*token == '\0') continue; + if (strncmp(token, "dhcp6_", 6) == 0) + token += 6; + if (strncmp(token, "nd6_", 4) == 0) + token += 4; match = 0; for (i = 0, opt = odopts; i < odopts_len; i++, opt++) { if (opt->var == NULL || opt->option == 0) Index: src/external/bsd/dhcpcd/dist/src/dhcp-common.h diff -u src/external/bsd/dhcpcd/dist/src/dhcp-common.h:1.1.1.4 src/external/bsd/dhcpcd/dist/src/dhcp-common.h:1.1.1.4.2.1 --- src/external/bsd/dhcpcd/dist/src/dhcp-common.h:1.1.1.4 Wed Jul 24 09:54:49 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcp-common.h Sat Oct 12 14:44:32 2019 @@ -81,6 +81,11 @@ #define OT_BITFLAG (1 << 27) #define OT_RESERVED (1 << 28) +#define DHC_REQOPT(o, r, n) \ + (!((o)->type & OT_NOREQ) && \ + ((o)->type & OT_REQUEST || has_option_mask((r), (o)->option)) && \ + !has_option_mask((n), (o)->option)) + struct dhcp_opt { uint32_t option; /* Also used for IANA Enterpise Number */ int type; Index: src/external/bsd/dhcpcd/dist/src/dhcp.c diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.23.2.1 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.23.2.2 --- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.23.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcp.c Sat Oct 12 14:44:32 2019 @@ -988,7 +988,8 @@ make_message(struct bootp **bootpm, cons #ifdef AUTH if ((ifo->auth.options & DHCPCD_AUTH_SENDREQUIRE) != - DHCPCD_AUTH_SENDREQUIRE) + DHCPCD_AUTH_SENDREQUIRE && + !has_option_mask(ifo->nomask, DHO_FORCERENEW_NONCE)) { /* We support HMAC-MD5 */ AREA_CHECK(1); @@ -1032,10 +1033,7 @@ make_message(struct bootp **bootpm, cons i < ifp->ctx->dhcp_opts_len; i++, opt++) { - if (!(opt->type & OT_REQUEST || - has_option_mask(ifo->requestmask, opt->option))) - continue; - if (opt->type & OT_NOREQ) + if (!DHC_REQOPT(opt, ifo->requestmask, ifo->nomask)) continue; if (type == DHCP_INFORM && (opt->option == DHO_RENEWALTIME || @@ -1054,10 +1052,7 @@ make_message(struct bootp **bootpm, cons break; if (lp < p) continue; - if (!(opt->type & OT_REQUEST || - has_option_mask(ifo->requestmask, opt->option))) - continue; - if (opt->type & OT_NOREQ) + if (!DHC_REQOPT(opt, ifo->requestmask, ifo->nomask)) continue; if (type == DHCP_INFORM && (opt->option == DHO_RENEWALTIME || @@ -1738,15 +1733,32 @@ send_message(struct interface *ifp, uint if (r == -1) goto fail; len = (size_t)r; - from.s_addr = bootp->ciaddr; - if (from.s_addr != INADDR_ANY) + + if (ipv4_iffindaddr(ifp, &state->lease.addr, NULL) != NULL) + from.s_addr = state->lease.addr.s_addr; + else + from.s_addr = INADDR_ANY; + if (from.s_addr != INADDR_ANY && + state->lease.server.s_addr != INADDR_ANY) to.s_addr = state->lease.server.s_addr; else - to.s_addr = INADDR_ANY; + to.s_addr = INADDR_BROADCAST; - /* If unicasting, try and avoid sending by BPF so we don't - * use a L2 broadcast. */ - if (to.s_addr != INADDR_ANY && to.s_addr != INADDR_BROADCAST) { + /* + * If not listening on the unspecified address we can + * only receive broadcast messages via BPF. + * Sockets bound to an address cannot receive broadcast messages + * even if they are setup to send them. + * Broadcasting from UDP is only an optimisation for rebinding + * and on BSD, at least, is reliant on the subnet route being + * correctly configured to recieve the unicast reply. + * As such, we always broadcast and receive the reply to it via BPF. + * This also guarantees we have a DHCP server attached to the + * interface we want to configure because we can't dictate the + * interface via IP_PKTINFO unlike for IPv6. + */ + if (to.s_addr != INADDR_BROADCAST) + { if (dhcp_sendudp(ifp, &to, bootp, len) != -1) goto out; logerr("%s: dhcp_sendudp", ifp->name); @@ -2001,30 +2013,44 @@ dhcp_finish_dad(struct interface *ifp, s } -static void +static bool dhcp_addr_duplicated(struct interface *ifp, struct in_addr *ia) { struct dhcp_state *state = D_STATE(ifp); + unsigned long long opts = ifp->options->options; + struct dhcpcd_ctx *ctx = ifp->ctx; + bool deleted = false; #ifdef IN_IFF_DUPLICATED struct ipv4_addr *iap; #endif if ((state->offer == NULL || state->offer->yiaddr != ia->s_addr) && !IN_ARE_ADDR_EQUAL(ia, &state->lease.addr)) - return; + return deleted; /* RFC 2131 3.1.5, Client-server interaction */ logerrx("%s: DAD detected %s", ifp->name, inet_ntoa(*ia)); unlink(state->leasefile); - if (!(ifp->options->options & DHCPCD_STATIC) && !state->lease.frominfo) + if (!(opts & DHCPCD_STATIC) && !state->lease.frominfo) dhcp_decline(ifp); #ifdef IN_IFF_DUPLICATED - if ((iap = ipv4_iffindaddr(ifp, ia, NULL)) != NULL) + if ((iap = ipv4_iffindaddr(ifp, ia, NULL)) != NULL) { ipv4_deladdr(iap, 0); + deleted = true; + } #endif - eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); + eloop_timeout_delete(ctx->eloop, NULL, ifp); + if (opts & (DHCPCD_STATIC | DHCPCD_INFORM)) { + state->reason = "EXPIRE"; + script_runreason(ifp, state->reason); +#define NOT_ONLY_SELF (DHCPCD_MASTER | DHCPCD_IPV6RS | DHCPCD_DHCP6) + if (!(ctx->options & NOT_ONLY_SELF)) + eloop_exit(ifp->ctx->eloop, EXIT_FAILURE); + return deleted; + } eloop_timeout_add_sec(ifp->ctx->eloop, DHCP_RAND_MAX, dhcp_discover, ifp); + return deleted; } #endif @@ -2362,7 +2388,9 @@ dhcp_arp_address(struct interface *ifp) /* Add the address now, let the kernel handle DAD. */ ipv4_addaddr(ifp, &l.addr, &l.mask, &l.brd, l.leasetime, l.rebindtime); - } else + } else if (ia->addr_flags & IN_IFF_DUPLICATED) + dhcp_addr_duplicated(ifp, &ia->addr); + else loginfox("%s: waiting for DAD on %s", ifp->name, inet_ntoa(addr)); return 0; @@ -2841,14 +2869,18 @@ dhcp_handledhcp(struct interface *ifp, s #define LOGDHCP(l, m) \ log_dhcp((l), (m), ifp, bootp, bootp_len, from, 1) +#define IS_STATE_ACTIVE(s) ((s)-state != DHS_NONE && \ + (s)->state != DHS_INIT && (s)->state != DHS_BOUND) + if (bootp->op != BOOTREPLY) { - logdebugx("%s: op (%d) is not BOOTREPLY", - ifp->name, bootp->op); + if (IS_STATE_ACTIVE(state)) + logdebugx("%s: op (%d) is not BOOTREPLY", + ifp->name, bootp->op); return; } if (state->xid != ntohl(bootp->xid)) { - if (state->state != DHS_BOUND && state->state != DHS_NONE) + if (IS_STATE_ACTIVE(state)) logdebugx("%s: wrong xid 0x%x (expecting 0x%x) from %s", ifp->name, ntohl(bootp->xid), state->xid, inet_ntoa(*from)); @@ -2859,12 +2891,14 @@ dhcp_handledhcp(struct interface *ifp, s if (ifp->hwlen <= sizeof(bootp->chaddr) && memcmp(bootp->chaddr, ifp->hwaddr, ifp->hwlen)) { - char buf[sizeof(bootp->chaddr) * 3]; + if (IS_STATE_ACTIVE(state)) { + char buf[sizeof(bootp->chaddr) * 3]; - logdebugx("%s: xid 0x%x is for hwaddr %s", - ifp->name, ntohl(bootp->xid), - hwaddr_ntoa(bootp->chaddr, sizeof(bootp->chaddr), - buf, sizeof(buf))); + logdebugx("%s: xid 0x%x is for hwaddr %s", + ifp->name, ntohl(bootp->xid), + hwaddr_ntoa(bootp->chaddr, sizeof(bootp->chaddr), + buf, sizeof(buf))); + } dhcp_redirect_dhcp(ifp, bootp, bootp_len, from); return; } @@ -2959,10 +2993,7 @@ dhcp_handledhcp(struct interface *ifp, s } if (state->state == DHS_BOUND) { - /* Before we supported FORCERENEW we closed off the raw - * port so we effectively ignored all messages. - * As such we'll not log by default here. */ - //LOGDHCP(logdebugx, "bound, ignoring"); + LOGDHCP(logdebugx, "bound, ignoring"); return; } @@ -3239,9 +3270,40 @@ get_udp_data(void *packet, size_t *len) return p; } -static int -valid_udp_packet(void *packet, size_t plen, struct in_addr *from, - unsigned int flags) +static bool +is_packet_udp_bootp(void *packet, size_t plen) +{ + struct ip *ip = packet; + size_t ip_hlen; + struct udphdr *udp; + + if (sizeof(*ip) > plen) + return false; + + if (ip->ip_v != IPVERSION || ip->ip_p != IPPROTO_UDP) + return false; + + /* Sanity. */ + if (ntohs(ip->ip_len) != plen) + return false; + + ip_hlen = (size_t)ip->ip_hl * 4; + /* Check we have a UDP header and BOOTP. */ + if (ip_hlen + sizeof(*udp) + offsetof(struct bootp, vend) > plen) + return false; + + /* Check it's to and from the right ports. */ + udp = (struct udphdr *)(void *)((char *)ip + ip_hlen); + if (udp->uh_dport != htons(BOOTPC) || udp->uh_sport != htons(BOOTPS)) + return false; + + return true; +} + +/* Lengths have already been checked. */ +static bool +checksums_valid(void *packet, + struct in_addr *from, unsigned int flags) { struct ip *ip = packet; struct ip pseudo_ip = { @@ -3250,59 +3312,34 @@ valid_udp_packet(void *packet, size_t pl .ip_dst = ip->ip_dst }; size_t ip_hlen; - uint16_t ip_len, uh_sum; + uint16_t udp_len, uh_sum; struct udphdr *udp; uint32_t csum; - if (plen < sizeof(*ip)) { - if (from != NULL) - from->s_addr = INADDR_ANY; - errno = ERANGE; - return -1; - } - if (from != NULL) from->s_addr = ip->ip_src.s_addr; ip_hlen = (size_t)ip->ip_hl * 4; - if (in_cksum(ip, ip_hlen, NULL) != 0) { - errno = EINVAL; - return -1; - } - - /* Check we have a payload */ - ip_len = ntohs(ip->ip_len); - if (ip_len <= ip_hlen + sizeof(*udp)) { - errno = ERANGE; - return -1; - } - /* Check we don't go beyond the payload */ - if (ip_len > plen) { - errno = ENOBUFS; - return -1; - } + if (in_cksum(ip, ip_hlen, NULL) != 0) + return false; if (flags & BPF_PARTIALCSUM) return 0; - /* UDP checksum is based on a pseudo IP header alongside - * the UDP header and payload. */ udp = (struct udphdr *)(void *)((char *)ip + ip_hlen); if (udp->uh_sum == 0) return 0; + /* UDP checksum is based on a pseudo IP header alongside + * the UDP header and payload. */ + udp_len = ntohs(udp->uh_ulen); uh_sum = udp->uh_sum; udp->uh_sum = 0; pseudo_ip.ip_len = udp->uh_ulen; csum = 0; in_cksum(&pseudo_ip, sizeof(pseudo_ip), &csum); - csum = in_cksum(udp, ntohs(udp->uh_ulen), &csum); - if (csum != uh_sum) { - errno = EINVAL; - return -1; - } - - return 0; + csum = in_cksum(udp, udp_len, &csum); + return csum == uh_sum; } static void @@ -3311,13 +3348,12 @@ dhcp_handlebootp(struct interface *ifp, { size_t v; - /* udp_len must be correct because the values are checked in - * valid_udp_packet(). */ if (len < offsetof(struct bootp, vend)) { logerrx("%s: truncated packet (%zu) from %s", ifp->name, len, inet_ntoa(*from)); return; } + /* To make our IS_DHCP macro easy, ensure the vendor * area has at least 4 octets. */ v = len - offsetof(struct bootp, vend); @@ -3330,20 +3366,24 @@ dhcp_handlebootp(struct interface *ifp, } static void -dhcp_handlepacket(struct interface *ifp, uint8_t *data, size_t len) +dhcp_handlebpf(struct interface *ifp, uint8_t *data, size_t len) { struct bootp *bootp; struct in_addr from; size_t udp_len; const struct dhcp_state *state = D_CSTATE(ifp); - if (valid_udp_packet(data, len, &from, state->bpf_flags) == -1) { - if (errno == EINVAL) - logerrx("%s: checksum failure from %s", - ifp->name, inet_ntoa(from)); - else - logerr("%s: invalid UDP packet from %s", - ifp->name, inet_ntoa(from)); + /* Validate filter. */ + if (!is_packet_udp_bootp(data, len)) { +#ifdef BPF_DEBUG + logerrx("%s: DHCP BPF validation failure", ifp->name); +#endif + return; + } + + if (!checksums_valid(data, &from, state->bpf_flags)) { + logerrx("%s: checksum failure from %s", + ifp->name, inet_ntoa(from)); return; } @@ -3359,7 +3399,7 @@ dhcp_handlepacket(struct interface *ifp, } static void -dhcp_readpacket(void *arg) +dhcp_readbpf(void *arg) { struct interface *ifp = arg; uint8_t buf[MTU_MAX]; @@ -3381,7 +3421,7 @@ dhcp_readpacket(void *arg) } break; } - dhcp_handlepacket(ifp, buf, (size_t)bytes); + dhcp_handlebpf(ifp, buf, (size_t)bytes); /* Check we still have a state after processing. */ if ((state = D_STATE(ifp)) == NULL) break; @@ -3494,7 +3534,7 @@ dhcp_openbpf(struct interface *ifp) } eloop_event_add(ifp->ctx->eloop, - state->bpf_fd, dhcp_readpacket, ifp); + state->bpf_fd, dhcp_readbpf, ifp); return 0; } @@ -3926,7 +3966,7 @@ dhcp_abort(struct interface *ifp) } } -void +struct ipv4_addr * dhcp_handleifa(int cmd, struct ipv4_addr *ia, pid_t pid) { struct interface *ifp; @@ -3937,7 +3977,7 @@ dhcp_handleifa(int cmd, struct ipv4_addr ifp = ia->iface; state = D_STATE(ifp); if (state == NULL || state->state == DHS_NONE) - return; + return ia; if (cmd == RTM_DELADDR) { if (state->addr == ia) { @@ -3948,37 +3988,37 @@ dhcp_handleifa(int cmd, struct ipv4_addr * to drop the lease. */ dhcp_drop(ifp, "EXPIRE"); dhcp_start1(ifp); + return NULL; } - return; } if (cmd != RTM_NEWADDR) - return; + return ia; #ifdef IN_IFF_NOTUSEABLE if (!(ia->addr_flags & IN_IFF_NOTUSEABLE)) dhcp_finish_dad(ifp, &ia->addr); else if (ia->addr_flags & IN_IFF_DUPLICATED) - dhcp_addr_duplicated(ifp, &ia->addr); + return dhcp_addr_duplicated(ifp, &ia->addr) ? NULL : ia; #endif ifo = ifp->options; if (ifo->options & DHCPCD_INFORM) { if (state->state != DHS_INFORM) dhcp_inform(ifp); - return; + return ia; } if (!(ifo->options & DHCPCD_STATIC)) - return; + return ia; if (ifo->req_addr.s_addr != INADDR_ANY) - return; + return ia; free(state->old); state->old = state->new; state->new_len = dhcp_message_new(&state->new, &ia->addr, &ia->mask); if (state->new == NULL) - return; + return ia; if (ifp->flags & IFF_POINTOPOINT) { for (i = 1; i < 255; i++) if (i != DHO_ROUTER && has_option_mask(ifo->dstmask,i)) @@ -3994,4 +4034,6 @@ dhcp_handleifa(int cmd, struct ipv4_addr state->addr = ia; dhcp_inform(ifp); } + + return ia; } Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.23.2.1 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.23.2.2 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.23.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Sat Oct 12 14:44:32 2019 @@ -590,6 +590,12 @@ configure_interface1(struct interface *i } } #endif + + /* If root is network mounted, we don't want to kill the connection + * if the DHCP server goes the way of the dodo OR dhcpcd is rebooting + * and the lease file has expired. */ + if (is_root_local() == 0) + ifo->options |= DHCPCD_LASTLEASE_EXTEND; } int @@ -1088,8 +1094,13 @@ static void dhcpcd_checkcarrier(void *arg) { struct interface *ifp = arg; + int carrier; - dhcpcd_handlecarrier(ifp->ctx, LINK_UNKNOWN, ifp->flags, ifp->name); + /* Check carrier here rather than setting LINK_UNKNOWN. + * This is because we force LINK_UNKNOWN as down for wireless which + * we do not want when dealing with a route socket overflow. */ + carrier = if_carrier(ifp); + dhcpcd_handlecarrier(ifp->ctx, carrier, ifp->flags, ifp->name); } #ifndef SMALL Index: src/external/bsd/dhcpcd/dist/src/dhcp.h diff -u src/external/bsd/dhcpcd/dist/src/dhcp.h:1.1.1.10 src/external/bsd/dhcpcd/dist/src/dhcp.h:1.1.1.10.2.1 --- src/external/bsd/dhcpcd/dist/src/dhcp.h:1.1.1.10 Wed Jul 24 09:54:50 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcp.h Sat Oct 12 14:44:32 2019 @@ -260,7 +260,7 @@ int dhcp_get_routes(rb_tree_t *, struct ssize_t dhcp_env(FILE *, const char *, const struct interface *, const struct bootp *, size_t); -void dhcp_handleifa(int, struct ipv4_addr *, pid_t pid); +struct ipv4_addr *dhcp_handleifa(int, struct ipv4_addr *, pid_t pid); void dhcp_drop(struct interface *, const char *); void dhcp_start(struct interface *); void dhcp_abort(struct interface *); Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.2.2.1 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.2.2.2 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.2.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in Sat Oct 12 14:44:32 2019 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 28, 2019 +.Dd October 9, 2019 .Dt DHCPCD 8 .Os .Sh NAME @@ -203,6 +203,15 @@ changes the routes to use the interface metric. See options below for controlling which interfaces we allow and deny through the use of patterns. +.Pp +Non-ethernet interfaces and some virtual ethernet interfaces +such as TAP and bridge are ignored by default, +as is the FireWire interface. +To work with these devices they either need to be specified on the command line, +be listed in +.Fl Fl allowinterfaces +or have an interface directive in +.Pa @SYSCONFDIR@/dhcpcd.conf . .Ss Hooking into events .Nm runs Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in:1.1.1.13.2.1 src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in:1.1.1.13.2.2 --- src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in:1.1.1.13.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in Sat Oct 12 14:44:32 2019 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 28, 2019 +.Dd September 8, 2019 .Dt DHCPCD.CONF 5 .Os .Sh NAME @@ -454,7 +454,7 @@ Metrics are used to prefer an interface will supply a default metric of 200 + .Xr if_nametoindex 3 . An extra 100 will be added for wireless interfaces. -.It Ic mudurl Ar url +.It Ic mudurl Ar url Specifies the URL for a Manufacturer Usage Description (MUD). The description is used by upstream network devices to instantiate any desired access lists. @@ -725,7 +725,7 @@ DHCP, ND and DHCPv6 allow for the use of options for DHCP can also be supplied. Each option needs to be started with the .Ic define , -.Ic definend, +.Ic definend , .Ic define6 or .Ic vendopt Index: src/external/bsd/dhcpcd/dist/src/if-bsd.c diff -u src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.10.2.1 src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.10.2.2 --- src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.10.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/if-bsd.c Sat Oct 12 14:44:32 2019 @@ -101,6 +101,14 @@ #define RT_ADVANCE(x, n) (x += RT_ROUNDUP((n)->sa_len)) #endif +/* Ignore these interface names which look like ethernet but are virtual. */ +static const char * const ifnames_ignore[] = { + "bridge", + "fwe", /* Firewire */ + "tap", + NULL +}; + #ifdef INET6 static void ifa_setscope(struct sockaddr_in6 *, unsigned int); static unsigned int ifa_getscope(const struct sockaddr_in6 *); @@ -208,6 +216,61 @@ if_closesockets_os(struct dhcpcd_ctx *ct close(priv->pf_inet6_fd); } +static bool +if_ignore1(const char *drvname) +{ + const char * const *p; + + for (p = ifnames_ignore; *p; p++) { + if (strcmp(*p, drvname) == 0) + return true; + } + return false; +} + +bool +if_ignore(struct dhcpcd_ctx *ctx, const char *ifname) +{ + struct if_spec spec; + + if (if_nametospec(ifname, &spec) != 0) + return false; + + if (if_ignore1(spec.drvname)) + return true; + +#ifdef SIOCGIFGROUP + struct ifgroupreq ifgr = { .ifgr_len = 0 }; + struct ifg_req *ifg; + size_t ifg_len; + + /* Sadly it is possible to remove the device name + * from the interface groups, but hopefully this + * will be very unlikely.... */ + + strlcpy(ifgr.ifgr_name, ifname, sizeof(ifgr.ifgr_name)); + if (ioctl(ctx->pf_inet_fd, SIOCGIFGROUP, &ifgr) == -1 || + (ifgr.ifgr_groups = malloc(ifgr.ifgr_len)) == NULL || + ioctl(ctx->pf_inet_fd, SIOCGIFGROUP, &ifgr) == -1) + { + logerr(__func__); + return false; + } + + for (ifg = ifgr.ifgr_groups, ifg_len = ifgr.ifgr_len; + ifg && ifg_len >= sizeof(*ifg); + ifg++, ifg_len -= sizeof(*ifg)) + { + if (if_ignore1(ifg->ifgrq_group)) + return true; + } +#else + UNUSED(ctx); +#endif + + return false; +} + int if_carrier(struct interface *ifp) { @@ -653,6 +716,12 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct return -1; } #endif +#ifdef RTF_WASCLONED + if (rtm->rtm_flags & RTF_WASCLONED) { + errno = ENOTSUP; + return -1; + } +#endif #ifdef RTF_LOCAL if (rtm->rtm_flags & RTF_LOCAL) { errno = ENOTSUP; Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.10.2.1 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.10.2.2 --- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.10.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c Sat Oct 12 14:44:32 2019 @@ -1290,7 +1290,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, } } - if (new_data && !has_address && rap->lifetime && !ipv6_ifanyglobal(ifp)) + if (new_data && !has_address && rap->lifetime && !ipv6_anyglobal(ifp)) logwarnx("%s: no global addresses for default route", ifp->name); Index: src/external/bsd/dhcpcd/dist/src/if-options.c diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.16.2.1 src/external/bsd/dhcpcd/dist/src/if-options.c:1.16.2.2 --- src/external/bsd/dhcpcd/dist/src/if-options.c:1.16.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/if-options.c Sat Oct 12 14:44:32 2019 @@ -520,7 +520,7 @@ parse_addr(__unused struct in_addr *addr } #endif -static const char * +static void set_option_space(struct dhcpcd_ctx *ctx, const char *arg, const struct dhcp_opt **d, size_t *dl, @@ -543,7 +543,7 @@ set_option_space(struct dhcpcd_ctx *ctx, *require = ifo->requiremasknd; *no = ifo->nomasknd; *reject = ifo->rejectmasknd; - return arg + strlen("nd_"); + return; } #ifdef DHCP6 @@ -556,7 +556,7 @@ set_option_space(struct dhcpcd_ctx *ctx, *require = ifo->requiremask6; *no = ifo->nomask6; *reject = ifo->rejectmask6; - return arg + strlen("dhcp6_"); + return; } #endif #endif @@ -576,7 +576,6 @@ set_option_space(struct dhcpcd_ctx *ctx, *require = ifo->requiremask; *no = ifo->nomask; *reject = ifo->rejectmask; - return arg; } void @@ -806,7 +805,7 @@ parse_option(struct dhcpcd_ctx *ctx, con break; case 'o': ARG_REQUIRED; - arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, + set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, &request, &require, &no, &reject); if (make_option_mask(d, dl, od, odl, request, arg, 1) != 0 || make_option_mask(d, dl, od, odl, no, arg, -1) != 0 || @@ -818,7 +817,7 @@ parse_option(struct dhcpcd_ctx *ctx, con break; case O_REJECT: ARG_REQUIRED; - arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, + set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, &request, &require, &no, &reject); if (make_option_mask(d, dl, od, odl, reject, arg, 1) != 0 || make_option_mask(d, dl, od, odl, request, arg, -1) != 0 || @@ -1053,7 +1052,7 @@ parse_option(struct dhcpcd_ctx *ctx, con break; case 'O': ARG_REQUIRED; - arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, + set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, &request, &require, &no, &reject); if (make_option_mask(d, dl, od, odl, request, arg, -1) != 0 || make_option_mask(d, dl, od, odl, require, arg, -1) != 0 || @@ -1065,7 +1064,7 @@ parse_option(struct dhcpcd_ctx *ctx, con break; case 'Q': ARG_REQUIRED; - arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, + set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, &request, &require, &no, &reject); if (make_option_mask(d, dl, od, odl, require, arg, 1) != 0 || make_option_mask(d, dl, od, odl, request, arg, 1) != 0 || @@ -1253,7 +1252,7 @@ parse_option(struct dhcpcd_ctx *ctx, con break; case O_DESTINATION: ARG_REQUIRED; - arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, + set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, &request, &require, &no, &reject); if (make_option_mask(d, dl, od, odl, ifo->dstmask, arg, 2) != 0) Index: src/external/bsd/dhcpcd/dist/src/if.c diff -u src/external/bsd/dhcpcd/dist/src/if.c:1.1.1.14.2.1 src/external/bsd/dhcpcd/dist/src/if.c:1.1.1.14.2.2 --- src/external/bsd/dhcpcd/dist/src/if.c:1.1.1.14.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/if.c Sat Oct 12 14:44:32 2019 @@ -312,6 +312,7 @@ if_discover(struct dhcpcd_ctx *ctx, stru struct if_head *ifs; struct interface *ifp; struct if_spec spec; + bool if_noconf; #ifdef AF_LINK const struct sockaddr_dl *sdl; #ifdef IFLR_ACTIVE @@ -405,13 +406,6 @@ if_discover(struct dhcpcd_ctx *ctx, stru continue; #endif - /* Don't allow loopback or pointopoint unless explicit */ - if (ifa->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) { - if ((argc == 0 || argc == -1) && - ctx->ifac == 0 && !if_hasconf(ctx, spec.devname)) - active = IF_INACTIVE; - } - if (if_vimaster(ctx, spec.devname) == 1) { logfunc_t *logfunc = argc != 0 ? logerrx : logdebugx; logfunc("%s: is a Virtual Interface Master, skipping", @@ -419,6 +413,17 @@ if_discover(struct dhcpcd_ctx *ctx, stru continue; } + if_noconf = ((argc == 0 || argc == -1) && ctx->ifac == 0 && + !if_hasconf(ctx, spec.devname)); + + /* Don't allow loopback or pointopoint unless explicit. + * Don't allow some reserved interface names unless explicit. */ + if (if_noconf) { + if (ifa->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT) || + if_ignore(ctx, spec.devname)) + active = IF_INACTIVE; + } + ifp = calloc(1, sizeof(*ifp)); if (ifp == NULL) { logerr(__func__); @@ -453,27 +458,23 @@ if_discover(struct dhcpcd_ctx *ctx, stru #ifdef IFT_BRIDGE case IFT_BRIDGE: /* FALLTHROUGH */ #endif -#ifdef IFT_PPP - case IFT_PPP: /* FALLTHROUGH */ -#endif #ifdef IFT_PROPVIRTUAL - case IFT_PROPVIRTUAL: + case IFT_PROPVIRTUAL: /* FALLTHROUGH */ #endif -#if defined(IFT_BRIDGE) || defined(IFT_PPP) || defined(IFT_PROPVIRTUAL) +#ifdef IFT_TUNNEL + case IFT_TUNNEL: /* FALLTHROUGH */ +#endif + case IFT_PPP: /* Don't allow unless explicit */ - if ((argc == 0 || argc == -1) && - ctx->ifac == 0 && active && - !if_hasconf(ctx, ifp->name)) - { + if (if_noconf) { logdebugx("%s: ignoring due to" " interface type and" " no config", ifp->name); active = IF_INACTIVE; } - __fallthrough; /* Appease gcc-7 */ + __fallthrough; /* appease gcc */ /* FALLTHROUGH */ -#endif #ifdef IFT_L2VLAN case IFT_L2VLAN: /* FALLTHROUGH */ #endif @@ -495,13 +496,11 @@ if_discover(struct dhcpcd_ctx *ctx, stru #endif default: /* Don't allow unless explicit */ - if ((argc == 0 || argc == -1) && - ctx->ifac == 0 && - !if_hasconf(ctx, ifp->name)) + if (if_noconf) active = IF_INACTIVE; if (active) logwarnx("%s: unsupported" - " interface type %.2x", + " interface type 0x%.2x", ifp->name, sdl->sdl_type); /* Pretend it's ethernet */ ifp->family = ARPHRD_ETHER; @@ -564,7 +563,7 @@ if_discover(struct dhcpcd_ctx *ctx, stru default: if (active) logwarnx("%s: unsupported" - " interface family %.2x", + " interface family 0x%.2x", ifp->name, ifp->family); break; #endif Index: src/external/bsd/dhcpcd/dist/src/if.h diff -u src/external/bsd/dhcpcd/dist/src/if.h:1.1.1.10.2.1 src/external/bsd/dhcpcd/dist/src/if.h:1.1.1.10.2.2 --- src/external/bsd/dhcpcd/dist/src/if.h:1.1.1.10.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/if.h Sat Oct 12 14:44:32 2019 @@ -152,6 +152,7 @@ int if_nametospec(const char *, struct i int if_conf(struct interface *); int if_init(struct interface *); int if_getssid(struct interface *); +bool if_ignore(struct dhcpcd_ctx *, const char *); int if_vimaster(const struct dhcpcd_ctx *ctx, const char *); unsigned short if_vlanid(const struct interface *); int if_opensockets(struct dhcpcd_ctx *); Index: src/external/bsd/dhcpcd/dist/src/ipv4.c diff -u src/external/bsd/dhcpcd/dist/src/ipv4.c:1.1.1.16.2.1 src/external/bsd/dhcpcd/dist/src/ipv4.c:1.1.1.16.2.2 --- src/external/bsd/dhcpcd/dist/src/ipv4.c:1.1.1.16.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/ipv4.c Sat Oct 12 14:44:32 2019 @@ -145,7 +145,7 @@ ipv4_iffindlladdr(struct interface *ifp) state = IPV4_STATE(ifp); if (state) { TAILQ_FOREACH(ap, &state->addrs, next) { - if (IN_LINKLOCAL(htonl(ap->addr.s_addr))) + if (IN_LINKLOCAL(ntohl(ap->addr.s_addr))) return ap; } } @@ -622,7 +622,6 @@ ipv4_addaddr(struct interface *ifp, cons { struct ipv4_state *state; struct ipv4_addr *ia; - bool is_new = false; #ifdef ALIAS_ADDR int replaced, blank; struct ipv4_addr *replaced_ia; @@ -653,8 +652,9 @@ ipv4_addaddr(struct interface *ifp, cons #ifdef IN_IFF_TENTATIVE ia->addr_flags = IN_IFF_TENTATIVE; #endif - is_new = true; - } + ia->flags = IPV4_AF_NEW; + } else + ia->flags |= ~IPV4_AF_NEW; ia->mask = *mask; ia->brd = *bcast; @@ -698,7 +698,7 @@ ipv4_addaddr(struct interface *ifp, cons } #endif - if (is_new) + if (ia->flags & IPV4_AF_NEW) TAILQ_INSERT_TAIL(&state->addrs, ia, next); return ia; } @@ -743,8 +743,7 @@ ipv4_applyaddr(void *arg) #ifdef ARP /* Announce the preferred address to * kick ARP caches. */ - if (!(ifp->flags & IFF_NOARP)) - arp_announceaddr(ifp->ctx,&lease->addr); + arp_announceaddr(ifp->ctx,&lease->addr); #endif } script_runreason(ifp, state->reason); @@ -806,8 +805,7 @@ ipv4_applyaddr(void *arg) rt_build(ifp->ctx, AF_INET); #ifdef ARP - if (!(ifp->flags & IFF_NOARP)) - arp_announceaddr(ifp->ctx, &state->addr->addr); + arp_announceaddr(ifp->ctx, &state->addr->addr); #endif if (state->state == DHS_BOUND) { @@ -936,13 +934,14 @@ ipv4_handleifa(struct dhcpcd_ctx *ctx, } if (addr->s_addr != INADDR_ANY && addr->s_addr != INADDR_BROADCAST) { - dhcp_handleifa(cmd, ia, pid); + ia = dhcp_handleifa(cmd, ia, pid); #ifdef IPV4LL - ipv4ll_handleifa(cmd, ia, pid); + if (ia != NULL) + ipv4ll_handleifa(cmd, ia, pid); #endif } - if (cmd == RTM_DELADDR) + if (cmd == RTM_DELADDR && ia != NULL) free(ia); } Index: src/external/bsd/dhcpcd/dist/src/ipv4.h diff -u src/external/bsd/dhcpcd/dist/src/ipv4.h:1.1.1.9.2.1 src/external/bsd/dhcpcd/dist/src/ipv4.h:1.1.1.9.2.2 --- src/external/bsd/dhcpcd/dist/src/ipv4.h:1.1.1.9.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/ipv4.h Sat Oct 12 14:44:32 2019 @@ -100,6 +100,7 @@ struct ipv4_addr { TAILQ_HEAD(ipv4_addrhead, ipv4_addr); #define IPV4_AF_STALE (1U << 0) +#define IPV4_AF_NEW (1U << 1) #define IPV4_ADDR_EQ(a1, a2) ((a1) && (a1)->addr.s_addr == (a2)->addr.s_addr) #define IPV4_MASK1_EQ(a1, a2) ((a1) && (a1)->mask.s_addr == (a2)->mask.s_addr) Index: src/external/bsd/dhcpcd/dist/src/ipv4ll.c diff -u src/external/bsd/dhcpcd/dist/src/ipv4ll.c:1.1.1.9 src/external/bsd/dhcpcd/dist/src/ipv4ll.c:1.1.1.9.2.1 --- src/external/bsd/dhcpcd/dist/src/ipv4ll.c:1.1.1.9 Thu Jul 25 08:53:59 2019 +++ src/external/bsd/dhcpcd/dist/src/ipv4ll.c Sat Oct 12 14:44:32 2019 @@ -198,12 +198,16 @@ ipv4ll_not_found(struct interface *ifp) struct ipv4_addr *ia; #ifdef KERNEL_RFC5227 struct arp_state *astate; + bool new_addr; #endif state = IPV4LL_STATE(ifp); assert(state != NULL); ia = ipv4_iffindaddr(ifp, &state->pickedaddr, &inaddr_llmask); +#ifdef KERNEL_RFC5227 + new_addr = ia == NULL; +#endif #ifdef IN_IFF_NOTREADY if (ia == NULL || ia->addr_flags & IN_IFF_NOTREADY) #endif @@ -233,11 +237,13 @@ test: } rt_build(ifp->ctx, AF_INET); #ifdef KERNEL_RFC5227 - astate = arp_new(ifp, &ia->addr); - if (astate != NULL) { - astate->announced_cb = ipv4ll_announced_arp; - astate->free_cb = ipv4ll_arpfree; - arp_announce(astate); + if (!new_addr) { + astate = arp_new(ifp, &ia->addr); + if (astate != NULL) { + astate->announced_cb = ipv4ll_announced_arp; + astate->free_cb = ipv4ll_arpfree; + arp_announce(astate); + } } #else arp_announce(state->arp); @@ -261,10 +267,12 @@ ipv4ll_found(struct interface *ifp) { struct ipv4ll_state *state = IPV4LL_STATE(ifp); - arp_cancel(state->arp); + if (state->arp != NULL) + arp_cancel(state->arp); if (++state->conflicts == MAX_CONFLICTS) - logerr("%s: failed to acquire an IPv4LL address", + logerrx("%s: failed to acquire an IPv4LL address", ifp->name); + state->pickedaddr.s_addr = ipv4ll_pickaddr(ifp); eloop_timeout_add_sec(ifp->ctx->eloop, state->conflicts >= MAX_CONFLICTS ? RATE_LIMIT_INTERVAL : PROBE_WAIT, @@ -276,11 +284,14 @@ ipv4ll_defend_failed(struct interface *i { struct ipv4ll_state *state = IPV4LL_STATE(ifp); + if (state->arp != NULL) + arp_cancel(state->arp); ipv4_deladdr(state->addr, 1); state->down = true; state->addr = NULL; rt_build(ifp->ctx, AF_INET); script_runreason(ifp, "IPV4LL"); + state->pickedaddr.s_addr = ipv4ll_pickaddr(ifp); ipv4ll_start1(ifp, state->arp); } @@ -544,7 +555,7 @@ ipv4ll_recvrt(__unused int cmd, const st } #endif -void +struct ipv4_addr * ipv4ll_handleifa(int cmd, struct ipv4_addr *ia, pid_t pid) { struct interface *ifp; @@ -553,7 +564,7 @@ ipv4ll_handleifa(int cmd, struct ipv4_ad ifp = ia->iface; state = IPV4LL_STATE(ifp); if (state == NULL) - return; + return ia; if (cmd == RTM_DELADDR && state->addr != NULL && @@ -562,20 +573,28 @@ ipv4ll_handleifa(int cmd, struct ipv4_ad loginfox("%s: pid %d deleted IP address %s", ifp->name, pid, ia->saddr); ipv4ll_defend_failed(ifp); - return; + return ia; } #ifdef IN_IFF_DUPLICATED if (cmd != RTM_NEWADDR) - return; + return ia; if (!IN_ARE_ADDR_EQUAL(&state->pickedaddr, &ia->addr)) - return; + return ia; if (!(ia->addr_flags & IN_IFF_NOTUSEABLE)) ipv4ll_not_found(ifp); else if (ia->addr_flags & IN_IFF_DUPLICATED) { logerrx("%s: DAD detected %s", ifp->name, ia->saddr); - ipv4_deladdr(state->addr, 1); +#ifdef KERNEL_RFC5227 + arp_freeaddr(ifp, &ia->addr); +#endif + ipv4_deladdr(ia, 1); + state->addr = NULL; + rt_build(ifp->ctx, AF_INET); ipv4ll_found(ifp); + return NULL; } #endif + + return ia; } Index: src/external/bsd/dhcpcd/dist/src/ipv4ll.h diff -u src/external/bsd/dhcpcd/dist/src/ipv4ll.h:1.1.1.7 src/external/bsd/dhcpcd/dist/src/ipv4ll.h:1.1.1.7.2.1 --- src/external/bsd/dhcpcd/dist/src/ipv4ll.h:1.1.1.7 Wed Jul 24 09:54:54 2019 +++ src/external/bsd/dhcpcd/dist/src/ipv4ll.h Sat Oct 12 14:44:32 2019 @@ -64,7 +64,7 @@ ssize_t ipv4ll_env(FILE *, const char *, void ipv4ll_start(void *); void ipv4ll_claimed(void *); void ipv4ll_handle_failure(void *); -void ipv4ll_handleifa(int, struct ipv4_addr *, pid_t pid); +struct ipv4_addr *ipv4ll_handleifa(int, struct ipv4_addr *, pid_t pid); #ifdef HAVE_ROUTE_METRIC int ipv4ll_recvrt(int, const struct rt *); #endif Index: src/external/bsd/dhcpcd/dist/src/ipv6.c diff -u src/external/bsd/dhcpcd/dist/src/ipv6.c:1.3.2.1 src/external/bsd/dhcpcd/dist/src/ipv6.c:1.3.2.2 --- src/external/bsd/dhcpcd/dist/src/ipv6.c:1.3.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/ipv6.c Sat Oct 12 14:44:32 2019 @@ -1065,28 +1065,31 @@ ipv6_getstate(struct interface *ifp) } struct ipv6_addr * -ipv6_ifanyglobal(struct interface *ifp) +ipv6_anyglobal(struct interface *sifp) { + struct interface *ifp; struct ipv6_state *state; struct ipv6_addr *ia; - if (ifp->carrier == LINK_DOWN) - return NULL; - - state = IPV6_STATE(ifp); - if (state == NULL) - return NULL; + TAILQ_FOREACH(ifp, sifp->ctx->ifaces, next) { + if (ifp != sifp && ip6_forwarding(ifp->name) != 1) + continue; - TAILQ_FOREACH(ia, &state->addrs, next) { - if (IN6_IS_ADDR_LINKLOCAL(&ia->addr)) + state = IPV6_STATE(ifp); + if (state == NULL) continue; - /* Let's be optimistic. - * Any decent OS won't forward or accept traffic - * from/to tentative or detached addresses. */ - if (!(ia->addr_flags & IN6_IFF_DUPLICATED)) - break; + + TAILQ_FOREACH(ia, &state->addrs, next) { + if (IN6_IS_ADDR_LINKLOCAL(&ia->addr)) + continue; + /* Let's be optimistic. + * Any decent OS won't forward or accept traffic + * from/to tentative or detached addresses. */ + if (!(ia->addr_flags & IN6_IFF_DUPLICATED)) + return ia; + } } - return ia; + return NULL; } void @@ -1133,7 +1136,7 @@ ipv6_handleifa(struct dhcpcd_ctx *ctx, return; if ((state = ipv6_getstate(ifp)) == NULL) return; - anyglobal = ipv6_ifanyglobal(ifp) != NULL; + anyglobal = ipv6_anyglobal(ifp) != NULL; TAILQ_FOREACH(ia, &state->addrs, next) { if (IN6_ARE_ADDR_EQUAL(&ia->addr, addr)) @@ -1252,7 +1255,7 @@ out: * call rt_build to add/remove the default route. */ if (ifp->active && ifp->options->options & DHCPCD_IPV6 && !(ctx->options & DHCPCD_RTBUILD) && - (ipv6_ifanyglobal(ifp) != NULL) != anyglobal) + (ipv6_anyglobal(ifp) != NULL) != anyglobal) rt_build(ctx, AF_INET6); } @@ -2335,7 +2338,7 @@ inet6_raroutes(rb_tree_t *routes, struct } if (rap->lifetime == 0) continue; - if (ipv6_ifanyglobal(rap->iface) == NULL) + if (ipv6_anyglobal(rap->iface) == NULL) continue; rt = inet6_makerouter(rap); if (rt == NULL) Index: src/external/bsd/dhcpcd/dist/src/ipv6.h diff -u src/external/bsd/dhcpcd/dist/src/ipv6.h:1.3.2.1 src/external/bsd/dhcpcd/dist/src/ipv6.h:1.3.2.2 --- src/external/bsd/dhcpcd/dist/src/ipv6.h:1.3.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/ipv6.h Sat Oct 12 14:44:32 2019 @@ -273,7 +273,7 @@ int ipv6_handleifa_addrs(int, struct ipv struct ipv6_addr *ipv6_iffindaddr(struct interface *, const struct in6_addr *, int); int ipv6_hasaddr(const struct interface *); -struct ipv6_addr *ipv6_ifanyglobal(struct interface *); +struct ipv6_addr *ipv6_anyglobal(struct interface *); int ipv6_findaddrmatch(const struct ipv6_addr *, const struct in6_addr *, unsigned int); struct ipv6_addr *ipv6_findaddr(struct dhcpcd_ctx *, Index: src/external/bsd/dhcpcd/dist/src/route.c diff -u src/external/bsd/dhcpcd/dist/src/route.c:1.1.1.12.2.1 src/external/bsd/dhcpcd/dist/src/route.c:1.1.1.12.2.2 --- src/external/bsd/dhcpcd/dist/src/route.c:1.1.1.12.2.1 Thu Sep 5 08:56:55 2019 +++ src/external/bsd/dhcpcd/dist/src/route.c Sat Oct 12 14:44:32 2019 @@ -594,7 +594,9 @@ rt_add(rb_tree_t *kroutes, struct rt *nr } #endif - if (if_route(RTM_ADD, nrt) != -1) { + /* Shouldn't need to check for EEXIST, but some kernels don't + * dump the subnet route just after we added the address. */ + if (if_route(RTM_ADD, nrt) != -1 || errno == EEXIST) { result = true; goto out; } Index: src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.48 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.48.2.1 --- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.48 Fri Jul 26 10:49:06 2019 +++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile Sat Oct 12 14:44:33 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.48 2019/07/26 10:49:06 roy Exp $ +# $NetBSD: Makefile,v 1.48.2.1 2019/10/12 14:44:33 martin Exp $ # WARNS?= 6 @@ -13,18 +13,13 @@ SRCS+= if.c if-options.c route.c sa.c s SRCS+= dhcp-common.c dhcpcd-embedded.c SRCS+= if-bsd.c -# Need to generate this for dependencies -DPSRCS+= dhcpcd-embedded.h dhcpcd-embedded.c - CPPFLAGS+= -DHAVE_CONFIG_H -D_OPENBSD_SOURCE USE_INET?= yes .if defined(SMALLPROG) CPPFLAGS+= -DSMALL -DHCPCD_DEFS= dhcpcd-definitions-small.conf .else -DHCPCD_DEFS= dhcpcd-definitions.conf CPPFLAGS+= -DAUTH SRCS+= auth.c .endif @@ -50,7 +45,7 @@ CPPFLAGS+= -DDHCP6 SRCS+= dhcp6.c .endif -CPPFLAGS+= -I${SRCDIR}/include -I${DIST}/src -I${.OBJDIR} +CPPFLAGS+= -I${SRCDIR}/include -I${DIST}/src DPADD+= ${LIBUTIL} LDADD+= -lutil @@ -64,14 +59,6 @@ FILESMODE_dhcpcd.conf= 644 # -rw-r--r-- MAN= dhcpcd.conf.5 dhcpcd.8 CLEANFILES= dhcpcd.conf.5 dhcpcd.8 -dhcpcd-embedded.h: genembedh ${DHCPCD_DEFS} dhcpcd-embedded.h.in - ${HOST_SH} ${.ALLSRC} $^ > $@ - -dhcpcd-embedded.c: genembedc ${DHCPCD_DEFS} dhcpcd-embedded.c.in - ${HOST_SH} ${.ALLSRC} $^ > $@ - -CLEANFILES+= dhcpcd-embedded.c dhcpcd-embedded.h - .for f in dhcpcd.conf.5 dhcpcd.8 ${f}: ${f}.in ${TOOL_SED} ${SED_SYS} ${DIST}/src/${f}.in > $@ Added files: Index: src/external/bsd/dhcpcd/NetBSD-upgrade diff -u /dev/null src/external/bsd/dhcpcd/NetBSD-upgrade:1.2.2.2 --- /dev/null Sat Oct 12 14:44:33 2019 +++ src/external/bsd/dhcpcd/NetBSD-upgrade Sat Oct 12 14:44:31 2019 @@ -0,0 +1,18 @@ +$NetBSD: NetBSD-upgrade,v 1.2.2.2 2019/10/12 14:44:31 martin Exp $ + +dhcpcd releases can be found at https://roy.marples.name/downloads/dhcpcd/ + +For the import there is a handy autoamated approach + tar -xf dhcpcd-X.Y.Z.tar.xz + cd dhcpcd-X.Y.Z + ./configure + make import-src + cd /tmp/dhcpcd-X.Y.Z + cvs import src/external/bsd/dhcpcd/dist ROY dhcpcd-X_Y_Z + +To make local changes to dhcpcd, simply patch and commit +to the main branch (aka HEAD). Never make local changes on the +vendor (ROY) branch. + +All local changes should be submitted to Roy Marples for inclusion in +the next vendor release. Index: src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c diff -u /dev/null src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c:1.1.1.2.2.2 --- /dev/null Sat Oct 12 14:44:33 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c Sat Oct 12 14:44:32 2019 @@ -0,0 +1,490 @@ +/* + * DO NOT EDIT! + * Automatically generated from dhcpcd-embedded.conf + * Ths allows us to simply generate DHCP structure without any C programming. + */ + +/* + * dhcpcd - DHCP client daemon + * Copyright (c) 2006-2019 Roy Marples <r...@marples.name> + * All rights reserved + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <unistd.h> + +const char * const dhcpcd_embedded_conf[] = { +#ifdef SMALL +"define 1 request ipaddress subnet_mask", +"define 121 rfc3442 classless_static_routes", +"define 249 rfc3442 ms_classless_static_routes", +"define 33 request array ipaddress static_routes", +"define 3 request array ipaddress routers", +"define 6 array ipaddress domain_name_servers", +"define 12 dname host_name", +"define 15 array dname domain_name", +"define 26 uint16 interface_mtu", +"define 28 request ipaddress broadcast_address", +"define 50 ipaddress dhcp_requested_address", +"define 51 request uint32 dhcp_lease_time", +"define 52 byte dhcp_option_overload", +"define 53 byte dhcp_message_type", +"define 54 ipaddress dhcp_server_identifier", +"define 55 array byte dhcp_parameter_request_list", +"define 56 string dhcp_message", +"define 57 uint16 dhcp_max_message_size", +"define 58 request uint32 dhcp_renewal_time", +"define 59 request uint32 dhcp_rebinding_time", +"define 60 string vendor_class_identifier", +"define 61 binhex dhcp_client_identifier", +"define 80 norequest flag rapid_commit", +"define 81 embed fqdn", +"embed bitflags=0000NEOS flags", +"embed byte rcode1", +"embed byte rcode2", +"embed optional domain fqdn", +"define 119 array domain domain_search", +"definend 1 binhex source_address", +"definend 2 binhex target_address", +"definend 3 index embed prefix_information", +"embed byte length", +"embed bitflags=LA flags", +"embed uint32 vltime", +"embed uint32 pltime", +"embed uint32 reserved", +"embed array ip6address prefix", +"definend 5 embed mtu", +"embed uint16 reserved", +"embed uint32 mtu", +"definend 25 index embed rdnss", +"embed uint16 reserved", +"embed uint32 lifetime", +"embed array ip6address servers", +"definend 31 index embed dnssl", +"embed uint16 reserved", +"embed uint32 lifetime", +"embed domain search", +"define6 1 binhex client_id", +"define6 2 binhex server_id", +"define6 3 norequest index embed ia_na", +"embed binhex:4 iaid", +"embed uint32 t1", +"embed uint32 t2", +"encap 5 option", +"encap 13 option", +"define6 4 norequest index embed ia_ta", +"embed uint32 iaid", +"encap 5 option", +"encap 13 option", +"define6 5 norequest index embed ia_addr", +"embed ip6address ia_addr", +"embed uint32 pltime", +"embed uint32 vltime", +"encap 13 option", +"define6 12 ip6address unicast", +"define6 13 norequest embed status_code", +"embed uint16 status_code", +"embed optional string message", +"define6 18 binhex interface_id", +"define6 19 byte reconfigure_msg", +"define6 20 flag reconfigure_accept", +"define6 23 array ip6address name_servers", +"define6 24 array domain domain_search", +"define6 39 embed fqdn", +"embed bitflags=00000NOS flags", +"embed optional domain fqdn", +"define6 82 request uint32 sol_max_rt", +"define6 83 request uint32 inf_max_rt", +#else +"define 1 request ipaddress subnet_mask", +"define 121 rfc3442 classless_static_routes", +"define 249 rfc3442 ms_classless_static_routes", +"define 33 request array ipaddress static_routes", +"define 3 request array ipaddress routers", +"define 2 uint32 time_offset", +"define 4 array ipaddress time_servers", +"define 5 array ipaddress ien116_name_servers", +"define 6 array ipaddress domain_name_servers", +"define 7 array ipaddress log_servers", +"define 8 array ipaddress cookie_servers", +"define 9 array ipaddress lpr_servers", +"define 10 array ipaddress impress_servers", +"define 11 array ipaddress resource_location_servers", +"define 12 dname host_name", +"define 13 uint16 boot_size", +"define 14 string merit_dump", +"define 15 array dname domain_name", +"define 16 ipaddress swap_server", +"define 17 string root_path", +"define 18 string extensions_path", +"define 19 byte ip_forwarding", +"define 20 byte non_local_source_routing", +"define 21 array ipaddress policy_filter", +"define 22 uint16 max_dgram_reassembly", +"define 23 byte default_ip_ttl", +"define 24 uint32 path_mtu_aging_timeout", +"define 25 array uint16 path_mtu_plateau_table", +"define 26 uint16 interface_mtu", +"define 27 byte all_subnets_local", +"define 28 request ipaddress broadcast_address", +"define 29 byte perform_mask_discovery", +"define 30 byte mask_supplier", +"define 31 byte router_discovery", +"define 32 ipaddress router_solicitation_address", +"define 34 byte trailer_encapsulation", +"define 35 uint32 arp_cache_timeout", +"define 36 uint16 ieee802_3_encapsulation", +"define 37 byte default_tcp_ttl", +"define 38 uint32 tcp_keepalive_interval", +"define 39 byte tcp_keepalive_garbage", +"define 40 string nis_domain", +"define 41 array ipaddress nis_servers", +"define 42 array ipaddress ntp_servers", +"define 43 binhex vendor_encapsulated_options", +"define 44 array ipaddress netbios_name_servers", +"define 45 ipaddress netbios_dd_server", +"define 46 byte netbios_node_type", +"define 47 string netbios_scope", +"define 48 array ipaddress font_servers", +"define 49 array ipaddress x_display_manager", +"define 50 ipaddress dhcp_requested_address", +"define 51 request uint32 dhcp_lease_time", +"define 52 byte dhcp_option_overload", +"define 53 byte dhcp_message_type", +"define 54 ipaddress dhcp_server_identifier", +"define 55 array byte dhcp_parameter_request_list", +"define 56 string dhcp_message", +"define 57 uint16 dhcp_max_message_size", +"define 58 request uint32 dhcp_renewal_time", +"define 59 request uint32 dhcp_rebinding_time", +"define 60 string vendor_class_identifier", +"define 61 binhex dhcp_client_identifier", +"define 64 string nisplus_domain", +"define 65 array ipaddress nisplus_servers", +"define 66 dname tftp_server_name", +"define 67 string bootfile_name", +"define 68 array ipaddress mobile_ip_home_agent", +"define 69 array ipaddress smtp_server", +"define 70 array ipaddress pop_server", +"define 71 array ipaddress nntp_server", +"define 72 array ipaddress www_server", +"define 73 array ipaddress finger_server", +"define 74 array ipaddress irc_server", +"define 75 array ipaddress streettalk_server", +"define 76 array ipaddress streettalk_directory_assistance_server", +"define 77 binhex user_class", +"define 78 embed slp_agent", +"embed byte mandatory", +"embed array ipaddress address", +"define 79 embed slp_service", +"embed byte mandatory", +"embed ascii scope_list", +"define 80 norequest flag rapid_commit", +"define 81 embed fqdn", +"embed bitflags=0000NEOS flags", +"embed byte rcode1", +"embed byte rcode2", +"embed optional domain fqdn", +"define 83 embed isns", +"embed byte reserved1", +"embed bitflags=00000SAE functions", +"embed byte reserved2", +"embed bitflags=00fFsSCE dd", +"embed byte reserved3", +"embed bitflags=0000DMHE admin", +"embed uint16 reserved4", +"embed byte reserved5", +"embed bitflags=0TXPAMSE server_security", +"embed array ipaddress servers", +"define 85 array ipaddress nds_servers", +"define 86 raw nds_tree_name", +"define 87 raw nds_context", +"define 88 array domain bcms_controller_names", +"define 89 array ipaddress bcms_controller_address", +"define 90 embed auth", +"embed byte protocol", +"embed byte algorithm", +"embed byte rdm", +"embed binhex:8 replay", +"embed binhex information", +"define 91 uint32 client_last_transaction_time", +"define 92 array ipaddress associated_ip", +"define 98 string uap_servers", +"define 99 encap geoconf_civic", +"embed byte what", +"embed uint16 country_code", +"define 100 string posix_timezone", +"define 101 string tzdb_timezone", +"define 116 byte auto_configure", +"define 117 array uint16 name_service_search", +"define 118 ipaddress subnet_selection", +"define 119 array domain domain_search", +"define 120 rfc3361 sip_server", +"define 122 encap tsp", +"encap 1 ipaddress dhcp_server", +"encap 2 ipaddress dhcp_secondary_server", +"encap 3 rfc3361 provisioning_server", +"encap 4 embed as_req_as_rep_backoff", +"embed uint32 nominal", +"embed uint32 maximum", +"embed uint32 retry", +"encap 5 embed ap_req_ap_rep_backoff", +"embed uint32 nominal", +"embed uint32 maximum", +"embed uint32 retry", +"encap 6 domain kerberos_realm", +"encap 7 byte ticket_granting_server_utilization", +"encap 8 byte provisioning_timer", +"define 123 binhex geoconf", +"define 124 binhex vivco", +"define 125 embed vivso", +"embed uint32 enterprise_number", +"define 136 array ipaddress pana_agent", +"define 137 domain lost_server", +"define 138 array ipaddress capwap_ac", +"define 139 encap mos_ip", +"encap 1 array ipaddress is", +"encap 2 array ipaddress cs", +"encap 3 array ipaddress es", +"define 140 encap mos_domain", +"encap 1 domain is", +"encap 2 domain cs", +"encap 3 domain es", +"define 141 array domain sip_ua_cs_list", +"define 142 array ipaddress andsf", +"define 143 array ip6address andsf6", +"define 144 binhex geoloc", +"define 145 array byte forcerenew_nonce_capable", +"define 146 embed rdnss_selection", +"embed byte prf", +"embed ipaddress primary", +"embed ipaddress secondary", +"embed array domain domains", +"define 150 array ipaddress tftp_servers", +"define 161 string mudurl", +"define 208 binhex pxelinux_magic", +"define 209 string config_file", +"define 210 string path_prefix", +"define 211 uint32 reboot_time", +"define 212 embed sixrd", +"embed byte mask_len", +"embed byte prefix_len", +"embed ip6address prefix", +"embed array ipaddress brip_address", +"define 213 domain access_domain", +"define 221 encap vss", +"encap 0 string nvt", +"encap 1 binhex vpn_id", +"encap 255 flag global", +"define 252 string wpad_url", +"definend 1 binhex source_address", +"definend 2 binhex target_address", +"definend 3 index embed prefix_information", +"embed byte length", +"embed bitflags=LA flags", +"embed uint32 vltime", +"embed uint32 pltime", +"embed uint32 reserved", +"embed array ip6address prefix", +"definend 5 embed mtu", +"embed uint16 reserved", +"embed uint32 mtu", +"definend 25 index embed rdnss", +"embed uint16 reserved", +"embed uint32 lifetime", +"embed array ip6address servers", +"definend 31 index embed dnssl", +"embed uint16 reserved", +"embed uint32 lifetime", +"embed domain search", +"define6 1 binhex client_id", +"define6 2 binhex server_id", +"define6 3 norequest index embed ia_na", +"embed binhex:4 iaid", +"embed uint32 t1", +"embed uint32 t2", +"encap 5 option", +"encap 13 option", +"define6 4 norequest index embed ia_ta", +"embed uint32 iaid", +"encap 5 option", +"encap 13 option", +"define6 5 norequest index embed ia_addr", +"embed ip6address ia_addr", +"embed uint32 pltime", +"embed uint32 vltime", +"encap 13 option", +"define6 6 array uint16 option_request", +"define6 7 byte preference", +"define6 8 uint16 elased_time", +"define6 9 binhex dhcp_relay_msg", +"define6 11 embed auth", +"embed byte protocol", +"embed byte algorithm", +"embed byte rdm", +"embed binhex:8 replay", +"embed binhex information", +"define6 12 ip6address unicast", +"define6 13 norequest embed status_code", +"embed uint16 status_code", +"embed optional string message", +"define6 14 norequest flag rapid_commit", +"define6 15 binhex user_class", +"define6 16 binhex vivco", +"define6 17 embed vivso", +"embed uint32 enterprise_number", +"define6 18 binhex interface_id", +"define6 19 byte reconfigure_msg", +"define6 20 flag reconfigure_accept", +"define6 21 array domain sip_servers_names", +"define6 22 array ip6address sip_servers_addresses", +"define6 23 array ip6address name_servers", +"define6 24 array domain domain_search", +"define6 25 norequest index embed ia_pd", +"embed binhex:4 iaid", +"embed uint32 t1", +"embed uint32 t2", +"encap 26 option", +"define6 26 index embed prefix", +"embed uint32 pltime", +"embed uint32 vltime", +"embed byte length", +"embed ip6address prefix", +"encap 13 option", +"encap 67 option", +"define6 27 array ip6address nis_servers", +"define6 28 array ip6address nisp_servers", +"define6 29 string nis_domain_name", +"define6 30 string nisp_domain_name", +"define6 31 array ip6address sntp_servers", +"define6 32 uint32 info_refresh_time", +"define6 33 array domain bcms_server_d", +"define6 34 array ip6address bcms_server_a", +"define6 36 encap geoconf_civic", +"embed byte what", +"embed uint16 country_code", +"define6 37 embed remote_id", +"embed uint32 enterprise_number", +"embed binhex remote_id", +"define6 38 binhex subscriber_id", +"define6 39 embed fqdn", +"embed bitflags=00000NOS flags", +"embed optional domain fqdn", +"define6 40 array ip6address pana_agent", +"define6 41 string posix_timezone", +"define6 42 string tzdb_timezone", +"define6 43 array uint16 ero", +"define6 49 domain mip6_hnidf", +"define6 50 encap mip6_vdinf", +"encap 71 option", +"encap 72 option", +"encap 73 option", +"define6 51 domain lost_server", +"define6 52 array ip6address capwap_ac", +"define6 53 binhex relay_id", +"define6 54 encap mos_ip", +"encap 1 array ip6address is", +"encap 2 array ip6address cs", +"encap 3 array ip6address es", +"define6 55 encap mos_domain", +"encap 1 domain is", +"encap 2 domain cs", +"encap 3 domain es", +"define6 56 encap ntp_server", +"encap 1 ip6address addr", +"encap 2 ip6address mcast_addr", +"encap 3 ip6address fqdn", +"define6 57 domain access_domain", +"define6 58 array domain sip_ua_cs_list", +"define6 59 string bootfile_url", +"define6 60 binhex bootfile_param", +"define6 61 array uint16 architecture_types", +"define6 62 embed nii", +"embed byte type", +"embed byte major", +"embed byte minor", +"define6 63 binhex geoloc", +"define6 64 domain aftr_name", +"define6 67 embed pd_exclude", +"embed byte prefix_len", +"embed binhex subnetID", +"define6 69 encap mip6_idinf", +"encap 71 option", +"encap 72 option", +"encap 73 option", +"define6 70 encap mip6_udinf", +"encap 71 option", +"encap 72 option", +"encap 73 option", +"define6 71 embed mip6_hnp", +"embed byte prefix_len", +"embed ip6address prefix", +"define6 72 ip6address mip6_haa", +"define6 73 domain mip6_haf", +"define6 74 embed rdnss_selection", +"embed ip6address server", +"embed byte prf", +"embed array domain domains", +"define6 75 string krb_principal_name", +"define6 76 string krb_realm_name", +"define6 78 embed krb_kdc", +"embed uint16 priority", +"embed uint16 weight", +"embed byte transport_type", +"embed uint16 port", +"embed ip6address address", +"embed string realm_name", +"define6 80 ip6address link_address", +"define6 82 request uint32 sol_max_rt", +"define6 83 request uint32 inf_max_rt", +"define6 89 embed s46_rule", +"embed bitflags=0000000F flags", +"embed byte ea_len", +"embed byte prefix4_len", +"embed ipaddress ipv4_prefix", +"embed ip6address ipv6_prefix", +"define6 90 ip6address s64_br", +"define6 91 embed s46_dmr", +"embed byte prefix_len", +"embed binhex prefix", +"define6 92 embed s46_v4v6bind", +"embed ipaddress ipv4_address", +"embed byte ipv6_prefix_len", +"embed binhex ipv6_prefix_and_options", +"define6 93 embed s46_portparams", +"embed byte offset", +"embed byte psid_len", +"embed uint16 psid", +"define6 94 embed s46_cont_mape", +"encap 89 option", +"encap 90 option", +"define6 95 embed s46_cont_mapt", +"encap 89 option", +"encap 91 option", +"define6 96 embed s46_cont_lw", +"encap 90 option", +"encap 92 option", +"define6 112 string mudurl", +#endif +NULL +}; Index: src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h diff -u /dev/null src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h:1.1.1.2.2.2 --- /dev/null Sat Oct 12 14:44:33 2019 +++ src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h Sat Oct 12 14:44:32 2019 @@ -0,0 +1,38 @@ +/* + * dhcpcd - DHCP client daemon + * Copyright (c) 2006-2019 Roy Marples <r...@marples.name> + * All rights reserved + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef SMALL +#define INITDEFINES 25 +#define INITDEFINENDS 6 +#define INITDEFINE6S 14 +#else +#define INITDEFINES 124 +#define INITDEFINENDS 6 +#define INITDEFINE6S 69 +#endif + +extern const char * const dhcpcd_embedded_conf[];