diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/Makefile.in | 1 | ||||
-rw-r--r-- | client/dhc6.c | 26 | ||||
-rw-r--r-- | client/dhclient.8 | 27 | ||||
-rw-r--r-- | client/dhclient.c | 62 | ||||
-rw-r--r-- | client/tests/Makefile.in | 1 |
5 files changed, 92 insertions, 25 deletions
diff --git a/client/Makefile.in b/client/Makefile.in index e9f872c2..a6590829 100644 --- a/client/Makefile.in +++ b/client/Makefile.in @@ -272,6 +272,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDAP_CFLAGS = @LDAP_CFLAGS@ +LDAP_LIBS = @LDAP_LIBS@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ diff --git a/client/dhc6.c b/client/dhc6.c index 04a8fa00..37ce7394 100644 --- a/client/dhc6.c +++ b/client/dhc6.c @@ -1,7 +1,7 @@ /* dhc6.c - DHCPv6 client routines. */ /* - * Copyright (c) 2012-2014 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2012-2015 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 2006-2010 by Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and distribute this software for any @@ -418,6 +418,12 @@ valid_reply(struct packet *packet, struct client_state *client) rval = ISC_FALSE; } + /* clean up pointers to the strings */ + if (sid.data != NULL) + data_string_forget(&sid, MDL); + if (cid.data != NULL) + data_string_forget(&cid, MDL); + return rval; } @@ -469,6 +475,10 @@ dhc6_dup_ia(struct dhc6_ia *ia, const char *file, int line) struct dhc6_addr **insert_addr, *addr; copy = dmalloc(sizeof(*ia), file, line); + if (copy == NULL) { + log_error("Out of memory for v6 duplicate IA structure."); + return NULL; + } memcpy(copy->iaid, ia->iaid, sizeof(copy->iaid)); @@ -2798,6 +2808,12 @@ init_handler(struct packet *packet, struct client_state *client) lease = dhc6_leaseify(packet); + /* Out of memory or corrupt packet condition...hopefully a temporary + * problem. Returning now makes us try to retransmit later. + */ + if (lease == NULL) + return; + if (dhc6_check_advertise(lease) != ISC_R_SUCCESS) { log_debug("PRC: Lease failed to satisfy."); dhc6_lease_destroy(&lease, MDL); @@ -2915,7 +2931,7 @@ rapid_commit_handler(struct packet *packet, struct client_state *client) lease = dhc6_leaseify(packet); - /* This is an out of memory condition...hopefully a temporary + /* Out of memory or corrupt packet condition...hopefully a temporary * problem. Returning now makes us try to retransmit later. */ if (lease == NULL) @@ -3729,7 +3745,7 @@ reply_handler(struct packet *packet, struct client_state *client) lease = dhc6_leaseify(packet); - /* This is an out of memory condition...hopefully a temporary + /* Out of memory or corrupt packet condition...hopefully a temporary * problem. Returning now makes us try to retransmit later. */ if (lease == NULL) @@ -4259,6 +4275,10 @@ start_bound(struct client_state *client) oldia = NULL; for (addr = ia->addrs ; addr != NULL ; addr = addr->next) { + /* Don't try to use the address if it's already expired */ + if (addr->flags & DHC6_ADDR_EXPIRED) + continue; + if (oldia != NULL) { if (ia->ia_type != D6O_IA_PD) oldaddr = find_addr(oldia->addrs, diff --git a/client/dhclient.8 b/client/dhclient.8 index f2f93c19..5b056981 100644 --- a/client/dhclient.8 +++ b/client/dhclient.8 @@ -1,6 +1,6 @@ .\" $Id: dhclient.8,v 1.36 2011/04/15 21:58:12 sar Exp $ .\" -.\" Copyright (c) 2004,2007-2014 by Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (c) 2004,2007-2015 by Internet Systems Consortium, Inc. ("ISC") .\" Copyright (c) 1996-2003 by Internet Software Consortium .\" .\" Permission to use, copy, modify, and distribute this software for any @@ -427,8 +427,33 @@ Path to the network configuration script invoked by when it gets a lease. If unspecified, the default .B CLIENTBINDIR/dhclient-script is used. See \fBdhclient-script(8)\fR for a description of this file. +.PP +.SH PORTS +During operations the client may use multiple UDP ports +to provide different functions. Which ports are opened depends +on both the way you compiled your code and the configuration you +supply. The following should provide you an idea of what +ports may be in use. + +Normally a DHCPv4 client will open a raw UDP socket to receive +and send most DHCPv4 packets. It also opens a fallback UDP socket +for use in sending unicast packets. Normally these will both +use the well known port number for BOOTPC. + +For DHCPv6 the client opens a UDP socket on the well known +client port and a fallback UDP socket on a random port for +use in sending unicast messages. Unlike DHCPv4 the well +known socket doesn't need to be opened in raw mode. +If you have included an omapi port statement in your configuration +file then the client will open a TCP socket on that port to +listen for OMPAI connections. When something connects another +port will be used for the established connection. +When DDNS is enabled at compile time (see includes/site.h) +the client will open both a v4 and a v6 UDP socket on +random ports. These ports are opened even if DDNS is disabled +in the configuration file. .PP .SH CONFIGURATION The syntax of the \fBdhclient.conf(5)\fR file is discussed separately. diff --git a/client/dhclient.c b/client/dhclient.c index 2adf98d8..3a0c0611 100644 --- a/client/dhclient.c +++ b/client/dhclient.c @@ -37,6 +37,7 @@ #include <sys/time.h> #include <sys/wait.h> #include <limits.h> +#include <isc/file.h> #include <dns/result.h> TIME default_lease_time = 43200; /* 12 hours... */ @@ -89,6 +90,8 @@ int wanted_ia_ta = 0; int wanted_ia_pd = 0; char *mockup_relay = NULL; +char *progname = NULL; + void run_stateless(int exit_mode); static void usage(void); @@ -101,6 +104,9 @@ static int check_domain_name_list(const char *ptr, size_t len, int dots); static int check_option_values(struct universe *universe, unsigned int opt, const char *ptr, size_t len); +static void dhclient_ddns_cb_free(dhcp_ddns_cb_t *ddns_cb, + char* file, int line); + #ifndef UNIT_TEST int main(int argc, char **argv) { @@ -126,6 +132,12 @@ main(int argc, char **argv) { #endif /* DHCPv6 */ char *s; +#ifdef OLD_LOG_NAME + progname = "dhclient"; +#else + progname = argv[0]; +#endif + /* Initialize client globals. */ memset(&default_duid, 0, sizeof(default_duid)); @@ -142,7 +154,7 @@ main(int argc, char **argv) { else if (fd != -1) close(fd); - openlog("dhclient", DHCP_LOG_OPTIONS, LOG_DAEMON); + openlog(isc_file_basename(progname), DHCP_LOG_OPTIONS, LOG_DAEMON); #if !(defined(DEBUG) || defined(__CYGWIN32__)) setlogmask(LOG_UPTO(LOG_INFO)); @@ -747,7 +759,7 @@ static void usage() log_info(url); - log_fatal("Usage: dhclient " + log_fatal("Usage: %s " #ifdef DHCPv6 "[-4|-6] [-SNTPI1dvrxi] [-nw] [-p <port>] [-D LL|LLT] \n" #else /* DHCPv6 */ @@ -756,7 +768,8 @@ static void usage() " [-s server-addr] [-cf config-file]\n" " [-df duid-file] [-lf lease-file]\n" " [-pf pid-file] [--no-pid] [-e VAR=val]\n" - " [-sf script-file] [interface]"); + " [-sf script-file] [interface]", + isc_file_basename(progname)); } void run_stateless(int exit_mode) @@ -867,11 +880,9 @@ void classify (packet, class) { } -int unbill_class (lease, class) +void unbill_class (lease) struct lease *lease; - struct class *class; { - return 0; } int find_subnet (struct subnet **sp, @@ -1241,7 +1252,7 @@ void bind_lease (client) /* Run the client script with the new parameters. */ script_init(client, (client->state == S_REQUESTING ? "BOUND" : - (client->state == S_RENEWING ? "RENEW" : + (client->state == S_RENEWING ? "RENEW" : (client->state == S_REBOOTING ? "REBOOT" : "REBIND"))), client->new->medium); @@ -1694,7 +1705,7 @@ struct client_lease *packet_to_lease (packet, client) 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) { @@ -2448,7 +2459,7 @@ make_client_options(struct client_state *client, struct client_lease *lease, /* Client-identifier type : 1 byte */ *client_identifier.buffer->data = 255; - + /* IAID : 4 bytes * we use the low 4 bytes from the interface address */ @@ -2462,7 +2473,7 @@ make_client_options(struct client_state *client, struct client_lease *lease, memcpy(&client_identifier.buffer->data + 5 - hw_len, client->interface->hw_address.hbuf + hw_idx, hw_len); - + /* Add the default duid */ memcpy(&client_identifier.buffer->data+(1+4), default_duid.data, default_duid.len); @@ -3965,7 +3976,7 @@ client_dns_remove_action(dhcp_ddns_cb_t *ddns_cb, } /* If we are done or have an error clean up */ - ddns_cb_free(ddns_cb, MDL); + dhclient_ddns_cb_free(ddns_cb, MDL); return; } @@ -3981,7 +3992,7 @@ client_dns_remove(struct client_state *client, ddns_cancel(client->ddns_cb, MDL); client->ddns_cb = NULL; } - + ddns_cb = ddns_cb_alloc(MDL); if (ddns_cb != NULL) { ddns_cb->address = *addr; @@ -3994,7 +4005,7 @@ client_dns_remove(struct client_state *client, result = client_dns_update(client, ddns_cb); if (result != ISC_R_TIMEDOUT) { - ddns_cb_free(ddns_cb, MDL); + dhclient_ddns_cb_free(ddns_cb, MDL); } } } @@ -4091,10 +4102,7 @@ client_dns_update_timeout (void *cp) * the control block and should free it. */ if (status != ISC_R_TIMEDOUT) { - if (client != NULL) { - client->ddns_cb = NULL; - } - ddns_cb_free(ddns_cb, MDL); + dhclient_ddns_cb_free(ddns_cb, MDL); } } @@ -4183,7 +4191,7 @@ client_dns_update_action(dhcp_ddns_cb_t *ddns_cb, return; } - ddns_cb_free(ddns_cb, MDL); + dhclient_ddns_cb_free(ddns_cb, MDL); return; } @@ -4263,7 +4271,7 @@ client_dns_update(struct client_state *client, dhcp_ddns_cb_t *ddns_cb) } if (client->active_lease != NULL) { /* V6 request, get the client identifier, then - * construct the dhcid for either standard + * construct the dhcid for either standard * or interim */ if (((oc = lookup_option(&dhcpv6_universe, client->sent_options, @@ -4380,7 +4388,6 @@ dhclient_schedule_updates(struct client_state *client, ddns_cb->flags = DDNS_UPDATE_ADDR | DDNS_INCLUDE_RRSET; client->ddns_cb = ddns_cb; - tv.tv_sec = cur_tv.tv_sec + offset; tv.tv_usec = cur_tv.tv_usec; add_timeout(&tv, client_dns_update_timeout, @@ -4560,7 +4567,7 @@ static int check_option_values(struct universe *universe, static void add_reject(struct packet *packet) { struct iaddrmatchlist *list; - + list = dmalloc(sizeof(struct iaddrmatchlist), MDL); if (!list) log_fatal ("no memory for reject list!"); @@ -4585,3 +4592,16 @@ add_reject(struct packet *packet) { log_info("Server added to list of rejected servers."); } +/* Wrapper function around common ddns_cb_free function that ensures + * we set the client_state pointer to the control block to NULL. */ +static void +dhclient_ddns_cb_free(dhcp_ddns_cb_t *ddns_cb, char* file, int line) { + if (ddns_cb) { + struct client_state *client = (struct client_state *)ddns_cb->lease; + if (client != NULL) { + client->ddns_cb = NULL; + } + + ddns_cb_free(ddns_cb, file, line); + } +} diff --git a/client/tests/Makefile.in b/client/tests/Makefile.in index 57c5d6bc..82daa79a 100644 --- a/client/tests/Makefile.in +++ b/client/tests/Makefile.in @@ -244,6 +244,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDAP_CFLAGS = @LDAP_CFLAGS@ +LDAP_LIBS = @LDAP_LIBS@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ |