they are received.
[ISC-Bugs #39669]
+- Added a new dhclient command line parameter, --prefix-len-hint <length>.
+ When used in conjunction with -P, it directs dhclient to use the given
+ length as the prefix length hint when requesting prefixes.
+ [ISC-Bugs #43792]
+
Changes since 4.3.0 (bug fixes)
- Tidy up several small tickets.
extern int onetry;
extern int stateless;
+extern int prefix_len_hint;
+
/*
* Assign DHCPv6 port numbers as a client.
int start_idx, copy_len;
memset(ia, 0, sizeof(*ia));
- if (!buffer_allocate(&ia->buffer, 12, MDL)) {
+ if (!buffer_allocate(&ia->buffer, len, MDL)) {
return (ISC_R_NOMEMORY);
}
ia->data = ia->buffer->data;
case D6O_IA_NA:
type_string = "IA_NA";
type_option = ia_na_option;
- len = 12;
+ len = IA_NA_OFFSET;
break;
case D6O_IA_TA:
type_string = "IA_TA";
type_option = ia_ta_option;
- len = 4;
+ len = IA_TA_OFFSET;
break;
case D6O_IA_PD:
type_string = "IA_PD";
type_option = ia_pd_option;
- len = 12;
+ len = IA_PD_OFFSET;
+ if (prefix_len_hint > 0) {
+ len += IASUBOPT_PD_LEN;
+ }
break;
+
default:
return (ISC_R_FAILURE);
}
/* If we are requesting an NA or a PD we also want to add
* the renew and rebind times we are requesting.
*/
- if (len == 12) {
+ if (ia_type != D6O_IA_TA) {
t1 = client->config->requested_lease / 2;
t2 = t1 + (t1 / 2);
putULong(ia.buffer->data + 4, t1);
(unsigned)t2);
}
+ if (ia_type == D6O_IA_PD && prefix_len_hint > 0) {
+ unsigned char *ptr = ia.buffer->data + IA_NA_OFFSET;
+ putUShort(ptr, D6O_IAPREFIX);
+ ptr += 2;
+ putUShort(ptr, IASUBOPT_PD_LEN);
+ ptr += 2;
+ putUChar(ptr + IASUBOPT_PD_PREFLEN_OFFSET,
+ prefix_len_hint);
+ log_debug("XMT: | | X-- Request prefix ::/%u.",
+ prefix_len_hint);
+ }
+
/* and append it to the packet */
append_option(packet, &dhcpv6_universe, type_option, &ia);
data_string_forget(&ia, MDL);
data_string_forget(&addr, MDL);
}
+ } else if (prefix_len_hint > 0) {
+ memset(&addr, 0, sizeof(addr));
+ if (!buffer_allocate(&addr.buffer, 25, MDL)) {
+ log_error("Unable to allocate memory "
+ "for IAPREFIX.");
+ data_string_forget(&ia, MDL);
+ data_string_forget(&ds, MDL);
+ return;
+ }
+
+ addr.data = addr.buffer->data;
+ addr.len = 25;
+
+ putUChar(addr.buffer->data + 8, prefix_len_hint);
+ log_debug("XMT: | | X-- Request prefix ::/%u.",
+ prefix_len_hint);
+ append_option(&ia, &dhcpv6_universe, iaprefix_option,
+ &addr);
+ data_string_forget(&addr, MDL);
}
append_option(&ds, &dhcpv6_universe, ia_pd_option, &ia);
.I seconds
]
[
+.B --prefix-len-hint
+.I length
+]
+[
.B -v
]
[
There are two versions of the DHCP protocol DHCPv4 and DHCPv6. At
startup the client may be started for one or the other via the
.B -4
-or
+or
.B -6
options.
.PP
flag.
.TP
.BI \-e \ VAR=value
-Define additional environment variables for the environment where
+Define additional environment variables for the environment where
.B dhclient-script
-executes. You may specify multiple
+executes. You may specify multiple
.B \-e
options on the command line.
.TP
.BI \-r
Release the current lease and stop the running DHCP client as previously
-recorded in the PID file. When shutdown via this method
+recorded in the PID file. When shutdown via this method
.B dhclient-script
will be executed with the specific reason for calling the script set.
The client normally doesn't release the current lease as this is not
.BI \-x
Stop the running DHCP client without releasing the current lease.
Kills existing \fBdhclient\fR process as previously recorded in the
-PID file. When shutdown via this method
+PID file. When shutdown via this method
.B dhclient-script
will be executed with the specific reason for calling the script set.
.TP
.TP
.BI \-s \ server-addr
Specify the server IP address or fully qualified domain name to use as
-a destination for DHCP protocol messages before
+a destination for DHCP protocol messages before
.B dhclient
has acquired an IP address. Normally,
.B dhclient
client id in this fashion is discouraged.
.TP
.BI \-I
-Use the standard DDNS scheme from RFCs 4701 & 4702.
+Use the standard DDNS scheme from RFCs 4701 & 4702.
.TP
.BI \--version
Print version number and exit.
seconds for DAD to complete. If the script ignores this variable the
parameter has no effect.
.PP
+.TP
+.BI \--prefix-len-hint \ length
+When used in conjunction with -P, it directs the client to use the given
+length to use a prefix hint of, "::/length", when requesting new prefixes.
+.PP
.I Modifying default file locations:
The following options can be used to modify the locations a client uses
for its files. They can be particularly useful if, for example,
running, without stopping it. This capability is provided using OMAPI,
an API for manipulating remote objects. OMAPI clients connect to the
client using TCP/IP, authenticate, and can then examine the client's
-current status and make changes to it.
+current status and make changes to it.
.PP
Rather than implementing the underlying OMAPI protocol directly, user
programs should use the dhcpctl API or OMAPI itself. Dhcpctl is a
int require_all_ias = 0; /* If the user requires all of the IAs to
be available before accepting a lease
0 = no, 1 = requries */
+#if defined(DHCPv6)
int dad_wait_time = 0;
+int prefix_len_hint = 0;
+#endif
+
char *mockup_relay = NULL;
char *progname = NULL;
#ifdef DHCP4o6
#define DHCLIENT_USAGE0 \
"[-4|-6] [-SNTPRI1dvrxi] [-nw] -4o6 <port>] [-p <port>]\n" \
-" [-D LL|LLT] [--dad-wait-time seconds]\n"
+" [-D LL|LLT] [--dad-wait-time seconds]\n" \
+" [--prefix-len-hint length]\n"
#else /* DHCP4o6 */
#define DHCLIENT_USAGE0 \
"[-4|-6] [-SNTPRI1dvrxi] [-nw] [-p <port>] [-D LL|LLT]\n" \
-" [--dad-wait-time seconds]\n"
+" [--dad-wait-time seconds] [--prefix-len-hint length]\n"
#endif
#else /* DHCPv6 */
#define DHCLIENT_USAGE0 \
if (errno || (*s != '\0') || (dad_wait_time < 0)) {
usage("Invalid value for --dad-wait-time: %s", argv[i]);
}
+ } else if (!strcmp(argv[i], "--prefix-len-hint")) {
+ if (++i == argc) {
+ usage(use_noarg, argv[i-1]);
+ }
+ errno = 0;
+ prefix_len_hint = (int)strtol(argv[i], &s, 10);
+ if (errno || (*s != '\0') || (prefix_len_hint < 0)) {
+ usage("Invalid value for --prefix-len-hint: %s",
+ argv[i]);
+ }
#endif /* DHCPv6 */
} else if (!strcmp(argv[i], "-D")) {
duid_v4 = 1;
#define EUI_64_ID_LEN 12 /* 2 for duid-type, 2 for hardware type, 8 for ID */
#define IAID_LEN 4
+/* Offsets with iasubopt wire data of data values for IA_NA and TA */
+#define IASUBOPT_NA_ADDR_OFFSET 0
+#define IASUBOPT_NA_PREF_OFFSET 16
+#define IASUBOPT_NA_VALID_OFFSET 20
+#define IASUBOPT_NA_LEN 24
+
+/* Offsets with iasubopt wire data of data values for PD */
+#define IASUBOPT_PD_PREF_OFFSET 0
+#define IASUBOPT_PD_VALID_OFFSET 4
+#define IASUBOPT_PD_PREFLEN_OFFSET 8
+#define IASUBOPT_PD_PREFIX_OFFSET 9
+#define IASUBOPT_PD_LEN 25