mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-29 05:17:57 +00:00
[master] Added --prefix-len-hint command line argument to dhclient
Merges in rt43792
This commit is contained in:
parent
3e985dbf1f
commit
c0e9661e70
5
RELNOTES
5
RELNOTES
@ -183,6 +183,11 @@ dhcp-users@lists.isc.org.
|
|||||||
they are received.
|
they are received.
|
||||||
[ISC-Bugs #39669]
|
[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)
|
Changes since 4.3.0 (bug fixes)
|
||||||
|
|
||||||
- Tidy up several small tickets.
|
- Tidy up several small tickets.
|
||||||
|
@ -146,6 +146,8 @@ static int dhc6_score_lease(struct client_state *client,
|
|||||||
|
|
||||||
extern int onetry;
|
extern int onetry;
|
||||||
extern int stateless;
|
extern int stateless;
|
||||||
|
extern int prefix_len_hint;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assign DHCPv6 port numbers as a client.
|
* Assign DHCPv6 port numbers as a client.
|
||||||
@ -1708,7 +1710,7 @@ dhc6_create_iaid(struct client_state *client,
|
|||||||
int start_idx, copy_len;
|
int start_idx, copy_len;
|
||||||
|
|
||||||
memset(ia, 0, sizeof(*ia));
|
memset(ia, 0, sizeof(*ia));
|
||||||
if (!buffer_allocate(&ia->buffer, 12, MDL)) {
|
if (!buffer_allocate(&ia->buffer, len, MDL)) {
|
||||||
return (ISC_R_NOMEMORY);
|
return (ISC_R_NOMEMORY);
|
||||||
}
|
}
|
||||||
ia->data = ia->buffer->data;
|
ia->data = ia->buffer->data;
|
||||||
@ -1771,18 +1773,22 @@ dhc6_bare_ia_xx(struct client_state *client,
|
|||||||
case D6O_IA_NA:
|
case D6O_IA_NA:
|
||||||
type_string = "IA_NA";
|
type_string = "IA_NA";
|
||||||
type_option = ia_na_option;
|
type_option = ia_na_option;
|
||||||
len = 12;
|
len = IA_NA_OFFSET;
|
||||||
break;
|
break;
|
||||||
case D6O_IA_TA:
|
case D6O_IA_TA:
|
||||||
type_string = "IA_TA";
|
type_string = "IA_TA";
|
||||||
type_option = ia_ta_option;
|
type_option = ia_ta_option;
|
||||||
len = 4;
|
len = IA_TA_OFFSET;
|
||||||
break;
|
break;
|
||||||
case D6O_IA_PD:
|
case D6O_IA_PD:
|
||||||
type_string = "IA_PD";
|
type_string = "IA_PD";
|
||||||
type_option = ia_pd_option;
|
type_option = ia_pd_option;
|
||||||
len = 12;
|
len = IA_PD_OFFSET;
|
||||||
|
if (prefix_len_hint > 0) {
|
||||||
|
len += IASUBOPT_PD_LEN;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return (ISC_R_FAILURE);
|
return (ISC_R_FAILURE);
|
||||||
}
|
}
|
||||||
@ -1811,7 +1817,7 @@ dhc6_bare_ia_xx(struct client_state *client,
|
|||||||
/* If we are requesting an NA or a PD we also want to add
|
/* If we are requesting an NA or a PD we also want to add
|
||||||
* the renew and rebind times we are requesting.
|
* the renew and rebind times we are requesting.
|
||||||
*/
|
*/
|
||||||
if (len == 12) {
|
if (ia_type != D6O_IA_TA) {
|
||||||
t1 = client->config->requested_lease / 2;
|
t1 = client->config->requested_lease / 2;
|
||||||
t2 = t1 + (t1 / 2);
|
t2 = t1 + (t1 / 2);
|
||||||
putULong(ia.buffer->data + 4, t1);
|
putULong(ia.buffer->data + 4, t1);
|
||||||
@ -1823,6 +1829,18 @@ dhc6_bare_ia_xx(struct client_state *client,
|
|||||||
(unsigned)t2);
|
(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 */
|
/* and append it to the packet */
|
||||||
append_option(packet, &dhcpv6_universe, type_option, &ia);
|
append_option(packet, &dhcpv6_universe, type_option, &ia);
|
||||||
data_string_forget(&ia, MDL);
|
data_string_forget(&ia, MDL);
|
||||||
@ -2128,6 +2146,25 @@ do_init6(void *input)
|
|||||||
|
|
||||||
data_string_forget(&addr, 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);
|
append_option(&ds, &dhcpv6_universe, ia_pd_option, &ia);
|
||||||
|
@ -138,6 +138,10 @@ dhclient - Dynamic Host Configuration Protocol Client
|
|||||||
.I seconds
|
.I seconds
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
|
.B --prefix-len-hint
|
||||||
|
.I length
|
||||||
|
]
|
||||||
|
[
|
||||||
.B -v
|
.B -v
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
@ -168,7 +172,7 @@ so on.
|
|||||||
There are two versions of the DHCP protocol DHCPv4 and DHCPv6. At
|
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
|
startup the client may be started for one or the other via the
|
||||||
.B -4
|
.B -4
|
||||||
or
|
or
|
||||||
.B -6
|
.B -6
|
||||||
options.
|
options.
|
||||||
.PP
|
.PP
|
||||||
@ -301,15 +305,15 @@ combination with the
|
|||||||
flag.
|
flag.
|
||||||
.TP
|
.TP
|
||||||
.BI \-e \ VAR=value
|
.BI \-e \ VAR=value
|
||||||
Define additional environment variables for the environment where
|
Define additional environment variables for the environment where
|
||||||
.B dhclient-script
|
.B dhclient-script
|
||||||
executes. You may specify multiple
|
executes. You may specify multiple
|
||||||
.B \-e
|
.B \-e
|
||||||
options on the command line.
|
options on the command line.
|
||||||
.TP
|
.TP
|
||||||
.BI \-r
|
.BI \-r
|
||||||
Release the current lease and stop the running DHCP client as previously
|
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
|
.B dhclient-script
|
||||||
will be executed with the specific reason for calling the script set.
|
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
|
The client normally doesn't release the current lease as this is not
|
||||||
@ -321,7 +325,7 @@ to notify the server if they wish to release an assigned IP address.
|
|||||||
.BI \-x
|
.BI \-x
|
||||||
Stop the running DHCP client without releasing the current lease.
|
Stop the running DHCP client without releasing the current lease.
|
||||||
Kills existing \fBdhclient\fR process as previously recorded in the
|
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
|
.B dhclient-script
|
||||||
will be executed with the specific reason for calling the script set.
|
will be executed with the specific reason for calling the script set.
|
||||||
.TP
|
.TP
|
||||||
@ -336,7 +340,7 @@ one less than the specified port.
|
|||||||
.TP
|
.TP
|
||||||
.BI \-s \ server-addr
|
.BI \-s \ server-addr
|
||||||
Specify the server IP address or fully qualified domain name to use as
|
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
|
.B dhclient
|
||||||
has acquired an IP address. Normally,
|
has acquired an IP address. Normally,
|
||||||
.B dhclient
|
.B dhclient
|
||||||
@ -359,7 +363,7 @@ setting a client id in the configuration file. Overridding the
|
|||||||
client id in this fashion is discouraged.
|
client id in this fashion is discouraged.
|
||||||
.TP
|
.TP
|
||||||
.BI \-I
|
.BI \-I
|
||||||
Use the standard DDNS scheme from RFCs 4701 & 4702.
|
Use the standard DDNS scheme from RFCs 4701 & 4702.
|
||||||
.TP
|
.TP
|
||||||
.BI \--version
|
.BI \--version
|
||||||
Print version number and exit.
|
Print version number and exit.
|
||||||
@ -423,6 +427,11 @@ variable. If any of the IPv6 addresses on the interface are tentative
|
|||||||
seconds for DAD to complete. If the script ignores this variable the
|
seconds for DAD to complete. If the script ignores this variable the
|
||||||
parameter has no effect.
|
parameter has no effect.
|
||||||
.PP
|
.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:
|
.I Modifying default file locations:
|
||||||
The following options can be used to modify the locations a client uses
|
The following options can be used to modify the locations a client uses
|
||||||
for its files. They can be particularly useful if, for example,
|
for its files. They can be particularly useful if, for example,
|
||||||
@ -504,7 +513,7 @@ The DHCP client provides some ability to control it while it is
|
|||||||
running, without stopping it. This capability is provided using OMAPI,
|
running, without stopping it. This capability is provided using OMAPI,
|
||||||
an API for manipulating remote objects. OMAPI clients connect to the
|
an API for manipulating remote objects. OMAPI clients connect to the
|
||||||
client using TCP/IP, authenticate, and can then examine the client's
|
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
|
.PP
|
||||||
Rather than implementing the underlying OMAPI protocol directly, user
|
Rather than implementing the underlying OMAPI protocol directly, user
|
||||||
programs should use the dhcpctl API or OMAPI itself. Dhcpctl is a
|
programs should use the dhcpctl API or OMAPI itself. Dhcpctl is a
|
||||||
|
@ -98,7 +98,11 @@ int wanted_ia_pd = 0;
|
|||||||
int require_all_ias = 0; /* If the user requires all of the IAs to
|
int require_all_ias = 0; /* If the user requires all of the IAs to
|
||||||
be available before accepting a lease
|
be available before accepting a lease
|
||||||
0 = no, 1 = requries */
|
0 = no, 1 = requries */
|
||||||
|
#if defined(DHCPv6)
|
||||||
int dad_wait_time = 0;
|
int dad_wait_time = 0;
|
||||||
|
int prefix_len_hint = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
char *mockup_relay = NULL;
|
char *mockup_relay = NULL;
|
||||||
|
|
||||||
char *progname = NULL;
|
char *progname = NULL;
|
||||||
@ -156,11 +160,12 @@ static const char use_v6command[] = "Command not used for DHCPv4: %s";
|
|||||||
#ifdef DHCP4o6
|
#ifdef DHCP4o6
|
||||||
#define DHCLIENT_USAGE0 \
|
#define DHCLIENT_USAGE0 \
|
||||||
"[-4|-6] [-SNTPRI1dvrxi] [-nw] -4o6 <port>] [-p <port>]\n" \
|
"[-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 */
|
#else /* DHCP4o6 */
|
||||||
#define DHCLIENT_USAGE0 \
|
#define DHCLIENT_USAGE0 \
|
||||||
"[-4|-6] [-SNTPRI1dvrxi] [-nw] [-p <port>] [-D LL|LLT]\n" \
|
"[-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
|
#endif
|
||||||
#else /* DHCPv6 */
|
#else /* DHCPv6 */
|
||||||
#define DHCLIENT_USAGE0 \
|
#define DHCLIENT_USAGE0 \
|
||||||
@ -490,7 +495,17 @@ main(int argc, char **argv) {
|
|||||||
if (errno || (*s != '\0') || (dad_wait_time < 0)) {
|
if (errno || (*s != '\0') || (dad_wait_time < 0)) {
|
||||||
usage("Invalid value for --dad-wait-time: %s", argv[i]);
|
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 */
|
#endif /* DHCPv6 */
|
||||||
} else if (!strcmp(argv[i], "-D")) {
|
} else if (!strcmp(argv[i], "-D")) {
|
||||||
duid_v4 = 1;
|
duid_v4 = 1;
|
||||||
|
@ -280,3 +280,15 @@ struct dhcpv4_over_dhcpv6_packet {
|
|||||||
#define EUI_64_ID_LEN 12 /* 2 for duid-type, 2 for hardware type, 8 for ID */
|
#define EUI_64_ID_LEN 12 /* 2 for duid-type, 2 for hardware type, 8 for ID */
|
||||||
#define IAID_LEN 4
|
#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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user