mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-31 22:35:25 +00:00
[master] Some small client changes
18933 - add an extra server by name call 26735 - when requested via a command line option have client exit afer 1 failure per the docs 33098 - expose next-server option to dhclient script
This commit is contained in:
15
RELNOTES
15
RELNOTES
@@ -108,6 +108,21 @@ by Eric Young (eay@cryptsoft.com).
|
|||||||
[ISC-Bugs #16970]
|
[ISC-Bugs #16970]
|
||||||
[ISC-Bugs #17258]
|
[ISC-Bugs #17258]
|
||||||
|
|
||||||
|
- Some minor cleanups in the client code
|
||||||
|
In addition to checking for dhcpc check for bootpc in the services list
|
||||||
|
[ISC-Bugs #18933]
|
||||||
|
Correct the client code to only try to get a lease once when the
|
||||||
|
given the "-1" argument.
|
||||||
|
Thanks to Jiri Popelka at Red Hat for the bug and fix.
|
||||||
|
[ISC-Bugs #26735]
|
||||||
|
When asked for the version don't send the output to syslog.
|
||||||
|
[ISC-Bugs #29772]
|
||||||
|
Add the next server information to the environment variables for
|
||||||
|
use by the client script. In order to avoid changing the client
|
||||||
|
lease file the next server information isn't written to it.
|
||||||
|
Thanks to Tomas Hozza at Red Hat for the suggestion and a prototype fix.
|
||||||
|
[ISC-Bugs #33098]
|
||||||
|
|
||||||
Changes since 4.3.0rc1
|
Changes since 4.3.0rc1
|
||||||
|
|
||||||
- None
|
- None
|
||||||
|
@@ -311,7 +311,13 @@ main(int argc, char **argv) {
|
|||||||
} else if (!strcmp(argv[i], "-v")) {
|
} else if (!strcmp(argv[i], "-v")) {
|
||||||
quiet = 0;
|
quiet = 0;
|
||||||
} else if (!strcmp(argv[i], "--version")) {
|
} else if (!strcmp(argv[i], "--version")) {
|
||||||
log_info("isc-dhclient-%s", PACKAGE_VERSION);
|
const char vstring[] = "isc-dhclient-";
|
||||||
|
IGNORE_RET(write(STDERR_FILENO, vstring,
|
||||||
|
strlen(vstring)));
|
||||||
|
IGNORE_RET(write(STDERR_FILENO,
|
||||||
|
PACKAGE_VERSION,
|
||||||
|
strlen(PACKAGE_VERSION)));
|
||||||
|
IGNORE_RET(write(STDERR_FILENO, "\n", 1));
|
||||||
exit(0);
|
exit(0);
|
||||||
} else if (argv[i][0] == '-') {
|
} else if (argv[i][0] == '-') {
|
||||||
usage();
|
usage();
|
||||||
@@ -1211,33 +1217,38 @@ void bind_lease (client)
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
/* Remember the medium. */
|
/* Remember the medium. */
|
||||||
client -> new -> medium = client -> medium;
|
client->new->medium = client->medium;
|
||||||
|
|
||||||
/* Run the client script with the new parameters. */
|
/* Run the client script with the new parameters. */
|
||||||
script_init (client, (client -> state == S_REQUESTING
|
script_init(client, (client->state == S_REQUESTING ? "BOUND" :
|
||||||
? "BOUND"
|
(client->state == S_RENEWING ? "RENEW" :
|
||||||
: (client -> state == S_RENEWING
|
(client->state == S_REBOOTING ? "REBOOT" :
|
||||||
? "RENEW"
|
"REBIND"))),
|
||||||
: (client -> state == S_REBOOTING
|
client->new->medium);
|
||||||
? "REBOOT" : "REBIND"))),
|
if (client->active && client->state != S_REBOOTING)
|
||||||
client -> new -> medium);
|
script_write_params(client, "old_", client->active);
|
||||||
if (client -> active && client -> state != S_REBOOTING)
|
script_write_params (client, "new_", client->new);
|
||||||
script_write_params (client, "old_", client -> active);
|
|
||||||
script_write_params (client, "new_", client -> new);
|
|
||||||
script_write_requested(client);
|
script_write_requested(client);
|
||||||
if (client -> alias)
|
if (client->alias)
|
||||||
script_write_params (client, "alias_", client -> alias);
|
script_write_params(client, "alias_", client->alias);
|
||||||
|
|
||||||
/* If the BOUND/RENEW code detects another machine using the
|
/* If the BOUND/RENEW code detects another machine using the
|
||||||
offered address, it exits nonzero. We need to send a
|
offered address, it exits nonzero. We need to send a
|
||||||
DHCPDECLINE and toss the lease. */
|
DHCPDECLINE and toss the lease. */
|
||||||
if (script_go (client)) {
|
if (script_go(client)) {
|
||||||
make_decline (client, client -> new);
|
make_decline(client, client->new);
|
||||||
send_decline (client);
|
send_decline(client);
|
||||||
destroy_client_lease (client -> new);
|
destroy_client_lease(client->new);
|
||||||
client -> new = (struct client_lease *)0;
|
client->new = NULL;
|
||||||
state_init (client);
|
if (onetry) {
|
||||||
return;
|
if (!quiet)
|
||||||
|
log_info("Unable to obtain a lease on first "
|
||||||
|
"try (declined). Exiting.");
|
||||||
|
exit(2);
|
||||||
|
} else {
|
||||||
|
state_init(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write out the new lease if it has been long enough. */
|
/* Write out the new lease if it has been long enough. */
|
||||||
@@ -1246,10 +1257,10 @@ void bind_lease (client)
|
|||||||
write_client_lease(client, client->new, 0, 0);
|
write_client_lease(client, client->new, 0, 0);
|
||||||
|
|
||||||
/* Replace the old active lease with the new one. */
|
/* Replace the old active lease with the new one. */
|
||||||
if (client -> active)
|
if (client->active)
|
||||||
destroy_client_lease (client -> active);
|
destroy_client_lease(client->active);
|
||||||
client -> active = client -> new;
|
client->active = client->new;
|
||||||
client -> new = (struct client_lease *)0;
|
client->new = NULL;
|
||||||
|
|
||||||
/* Set up a timeout to start the renewal process. */
|
/* Set up a timeout to start the renewal process. */
|
||||||
tv.tv_sec = client->active->renewal;
|
tv.tv_sec = client->active->renewal;
|
||||||
@@ -1257,12 +1268,12 @@ void bind_lease (client)
|
|||||||
random() % 1000000 : cur_tv.tv_usec;
|
random() % 1000000 : cur_tv.tv_usec;
|
||||||
add_timeout(&tv, state_bound, client, 0, 0);
|
add_timeout(&tv, state_bound, client, 0, 0);
|
||||||
|
|
||||||
log_info ("bound to %s -- renewal in %ld seconds.",
|
log_info("bound to %s -- renewal in %ld seconds.",
|
||||||
piaddr (client -> active -> address),
|
piaddr(client->active->address),
|
||||||
(long)(client -> active -> renewal - cur_time));
|
(long)(client->active->renewal - cur_time));
|
||||||
client -> state = S_BOUND;
|
client->state = S_BOUND;
|
||||||
reinitialize_interfaces ();
|
reinitialize_interfaces();
|
||||||
go_daemon ();
|
go_daemon();
|
||||||
#if defined (NSUPDATE)
|
#if defined (NSUPDATE)
|
||||||
if (client->config->do_forward_update)
|
if (client->config->do_forward_update)
|
||||||
dhclient_schedule_updates(client, &client->active->address, 1);
|
dhclient_schedule_updates(client, &client->active->address, 1);
|
||||||
@@ -1647,20 +1658,24 @@ struct client_lease *packet_to_lease (packet, client)
|
|||||||
lease = (struct client_lease *)new_client_lease (MDL);
|
lease = (struct client_lease *)new_client_lease (MDL);
|
||||||
|
|
||||||
if (!lease) {
|
if (!lease) {
|
||||||
log_error ("packet_to_lease: no memory to record lease.\n");
|
log_error("packet_to_lease: no memory to record lease.\n");
|
||||||
return (struct client_lease *)0;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (lease, 0, sizeof *lease);
|
memset(lease, 0, sizeof(*lease));
|
||||||
|
|
||||||
/* Copy the lease options. */
|
/* Copy the lease options. */
|
||||||
option_state_reference (&lease -> options, packet -> options, MDL);
|
option_state_reference(&lease->options, packet->options, MDL);
|
||||||
|
|
||||||
lease -> address.len = sizeof (packet -> raw -> yiaddr);
|
lease->address.len = sizeof(packet->raw->yiaddr);
|
||||||
memcpy (lease -> address.iabuf, &packet -> raw -> yiaddr,
|
memcpy(lease->address.iabuf, &packet->raw->yiaddr,
|
||||||
lease -> address.len);
|
lease->address.len);
|
||||||
|
|
||||||
memset (&data, 0, sizeof data);
|
lease->next_srv_addr.len = sizeof(packet->raw->siaddr);
|
||||||
|
memcpy(lease->next_srv_addr.iabuf, &packet->raw->siaddr,
|
||||||
|
lease->next_srv_addr.len);
|
||||||
|
|
||||||
|
memset(&data, 0, sizeof(data));
|
||||||
|
|
||||||
if (client -> config -> vendor_space_name) {
|
if (client -> config -> vendor_space_name) {
|
||||||
i = DHO_VENDOR_ENCAPSULATED_OPTIONS;
|
i = DHO_VENDOR_ENCAPSULATED_OPTIONS;
|
||||||
@@ -3312,6 +3327,13 @@ void script_write_params (client, prefix, lease)
|
|||||||
client_envadd (client,
|
client_envadd (client,
|
||||||
prefix, "ip_address", "%s", piaddr (lease -> address));
|
prefix, "ip_address", "%s", piaddr (lease -> address));
|
||||||
|
|
||||||
|
/* If we've set the next server address in the lease structure
|
||||||
|
put it into an environment variable for the script */
|
||||||
|
if (lease->next_srv_addr.len != 0) {
|
||||||
|
client_envadd(client, prefix, "next_server", "%s",
|
||||||
|
piaddr(lease->next_srv_addr));
|
||||||
|
}
|
||||||
|
|
||||||
/* For the benefit of Linux (and operating systems which may
|
/* For the benefit of Linux (and operating systems which may
|
||||||
have similar needs), compute the network address based on
|
have similar needs), compute the network address based on
|
||||||
the supplied ip address and netmask, if provided. Also
|
the supplied ip address and netmask, if provided. Also
|
||||||
@@ -4353,14 +4375,16 @@ dhcpv4_client_assignments(void)
|
|||||||
if (!local_port) {
|
if (!local_port) {
|
||||||
/* If we're faking a relay agent, and we're not using loopback,
|
/* If we're faking a relay agent, and we're not using loopback,
|
||||||
use the server port, not the client port. */
|
use the server port, not the client port. */
|
||||||
if (mockup_relay && giaddr.s_addr != htonl (INADDR_LOOPBACK)) {
|
if (mockup_relay && giaddr.s_addr != htonl(INADDR_LOOPBACK)) {
|
||||||
local_port = htons(67);
|
local_port = htons(67);
|
||||||
} else {
|
} else {
|
||||||
ent = getservbyname ("dhcpc", "udp");
|
ent = getservbyname("dhcpc", "udp");
|
||||||
if (!ent)
|
if (ent == NULL)
|
||||||
local_port = htons (68);
|
ent = getservbyname("bootpc", "udp");
|
||||||
|
if (ent == NULL)
|
||||||
|
local_port = htons(68);
|
||||||
else
|
else
|
||||||
local_port = ent -> s_port;
|
local_port = ent->s_port;
|
||||||
#ifndef __CYGWIN32__
|
#ifndef __CYGWIN32__
|
||||||
endservent ();
|
endservent ();
|
||||||
#endif
|
#endif
|
||||||
@@ -4369,10 +4393,10 @@ dhcpv4_client_assignments(void)
|
|||||||
|
|
||||||
/* If we're faking a relay agent, and we're not using loopback,
|
/* If we're faking a relay agent, and we're not using loopback,
|
||||||
we're using the server port, not the client port. */
|
we're using the server port, not the client port. */
|
||||||
if (mockup_relay && giaddr.s_addr != htonl (INADDR_LOOPBACK)) {
|
if (mockup_relay && giaddr.s_addr != htonl(INADDR_LOOPBACK)) {
|
||||||
remote_port = local_port;
|
remote_port = local_port;
|
||||||
} else
|
} else
|
||||||
remote_port = htons (ntohs (local_port) - 1); /* XXX */
|
remote_port = htons(ntohs(local_port) - 1); /* XXX */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1026,6 +1026,7 @@ struct client_lease {
|
|||||||
unsigned int is_bootp: 1; /* If set, lease was acquired with BOOTP. */
|
unsigned int is_bootp: 1; /* If set, lease was acquired with BOOTP. */
|
||||||
|
|
||||||
struct option_state *options; /* Options supplied with lease. */
|
struct option_state *options; /* Options supplied with lease. */
|
||||||
|
struct iaddr next_srv_addr; /* Address of the next server to use */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* DHCPv6 lease structures */
|
/* DHCPv6 lease structures */
|
||||||
|
Reference in New Issue
Block a user