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);
- dhcpcd_prestartinterface(ifp);
- }
- }
+ if (ifp->active)
+ return;
+
+ ifp->active = IF_ACTIVE;
+ dhcpcd_initstate2(ifp, options);
+
+ /* It's possible we might not have been able to load
+ * a config. */
+ if (!ifp->active)
+ return;
+
+ configure_interface1(ifp);
+ run_preinit(ifp);
+ dhcpcd_prestartinterface(ifp);
}
int
@@ -1880,6 +1887,7 @@ main(int argc, char **argv, char **envp)
logopts |= LOGERR_ERR;
i = 0;
+
while ((opt = getopt_long(argc, argv,
ctx.options & DHCPCD_PRINT_PIDFILE ? NOERR_IF_OPTS : IF_OPTS,
cf_options, &oi)) != -1)
@@ -1954,6 +1962,9 @@ main(int argc, char **argv, char **envp)
}
}
+ if (optind != argc - 1)
+ ctx.options |= DHCPCD_MASTER;
+
logsetopts(logopts);
logopen(ctx.logfile);
@@ -1970,6 +1981,7 @@ main(int argc, char **argv, char **envp)
goto printpidfile;
goto exit_failure;
}
+
opt = add_options(&ctx, NULL, ifo, argc, argv);
if (opt != 1) {
if (ctx.options & DHCPCD_PRINT_PIDFILE)
@@ -2010,6 +2022,7 @@ main(int argc, char **argv, char **envp)
goto exit_success;
}
ctx.options |= ifo->options;
+
if (i == 1 || i == 3) {
if (i == 1)
ctx.options |= DHCPCD_TEST;
@@ -2527,7 +2540,7 @@ exit_failure:
i = EXIT_FAILURE;
exit1:
- if (control_stop(&ctx) == -1)
+ if (!(ctx.options & DHCPCD_TEST) && control_stop(&ctx) == -1)
logerr("%s: control_stop", __func__);
if (ifaddrs != NULL) {
#ifdef PRIVSEP_GETIFADDRS
Index: src/external/bsd/dhcpcd/dist/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.29 src/external/bsd/dhcpcd/dist/src/if-options.c:1.30
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.29 Fri Nov 20 13:24:58 2020
+++ src/external/bsd/dhcpcd/dist/src/if-options.c Sat Nov 28 14:27:20 2020
@@ -134,9 +134,9 @@ const struct option cf_options[] = {
{"noipv6", no_argument, NULL, O_NOIPV6},
{"noalias", no_argument, NULL, O_NOALIAS},
{"iaid", required_argument, NULL, O_IAID},
- {"ia_na", no_argument, NULL, O_IA_NA},
- {"ia_ta", no_argument, NULL, O_IA_TA},
- {"ia_pd", no_argument, NULL, O_IA_PD},
+ {"ia_na", optional_argument, NULL, O_IA_NA},
+ {"ia_ta", optional_argument, NULL, O_IA_TA},
+ {"ia_pd", optional_argument, NULL, O_IA_PD},
{"hostname_short", no_argument, NULL, O_HOSTNAME_SHORT},
{"dev", required_argument, NULL, O_DEV},
{"nodev", no_argument, NULL, O_NODEV},
@@ -1002,8 +1002,16 @@ parse_option(struct dhcpcd_ctx *ctx, con
else if (strcmp(arg, "uuid") == 0)
ctx->duid_type = DUID_UUID;
else {
- logwarnx("%s: invalid duid type", arg);
- ctx->duid_type = DUID_DEFAULT;
+ dl = hwaddr_aton(NULL, arg);
+ if (dl != 0) {
+ no = realloc(ctx->duid, dl);
+ if (no == NULL)
+ logerrx(__func__);
+ else {
+ ctx->duid = no;
+ ctx->duid_len = hwaddr_aton(no, arg);
+ }
+ }
}
break;
case 'E':
@@ -1344,7 +1352,7 @@ parse_option(struct dhcpcd_ctx *ctx, con
#endif
case O_IAID:
ARG_REQUIRED;
- if (!IN_CONFIG_BLOCK(ifo)) {
+ if (ctx->options & DHCPCD_MASTER && !IN_CONFIG_BLOCK(ifo)) {
logerrx("IAID must belong in an interface block");
return -1;
}
@@ -1386,7 +1394,9 @@ parse_option(struct dhcpcd_ctx *ctx, con
logwarnx("%s: IA_PD not compiled in", ifname);
return -1;
#else
- if (!IN_CONFIG_BLOCK(ifo)) {
+ if (ctx->options & DHCPCD_MASTER &&
+ !IN_CONFIG_BLOCK(ifo))
+ {
logerrx("IA PD must belong in an "
"interface block");
return -1;
@@ -1394,7 +1404,9 @@ parse_option(struct dhcpcd_ctx *ctx, con
i = D6_OPTION_IA_PD;
#endif
}
- if (!IN_CONFIG_BLOCK(ifo) && arg) {
+ if (ctx->options & DHCPCD_MASTER &&
+ !IN_CONFIG_BLOCK(ifo) && arg)
+ {
logerrx("IA with IAID must belong in an "
"interface block");
return -1;
@@ -2343,6 +2355,8 @@ default_config(struct dhcpcd_ctx *ctx)
#endif
/* Inherit some global defaults */
+ if (ctx->options & DHCPCD_CONFIGURE)
+ ifo->options |= DHCPCD_CONFIGURE;
if (ctx->options & DHCPCD_PERSISTENT)
ifo->options |= DHCPCD_PERSISTENT;
if (ctx->options & DHCPCD_SLAACPRIVATE)
@@ -2371,8 +2385,8 @@ read_config(struct dhcpcd_ctx *ctx,
if ((ifo = default_config(ctx)) == NULL)
return NULL;
if (default_options == 0) {
- default_options |= DHCPCD_DAEMONISE |
- DHCPCD_CONFIGURE | DHCPCD_GATEWAY;
+ default_options |= DHCPCD_CONFIGURE | DHCPCD_DAEMONISE |
+ DHCPCD_GATEWAY;
#ifdef INET
skip = socket(PF_INET, SOCK_DGRAM, 0);
if (skip != -1) {