CVS commit: src/external/bsd/dhcp/dist/client
Module Name:src Committed By: christos Date: Tue Feb 4 22:34:39 UTC 2014 Modified Files: src/external/bsd/dhcp/dist/client: dhclient.c Log Message: Wait for all the interfaces specified on the command line to be configured before daemonizing, not just the first one. Perhaps we should introduce a separate flag for this behavior? To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcp/dist/client/dhclient.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/dhcp/dist/client/dhclient.c diff -u src/external/bsd/dhcp/dist/client/dhclient.c:1.7 src/external/bsd/dhcp/dist/client/dhclient.c:1.8 --- src/external/bsd/dhcp/dist/client/dhclient.c:1.7 Thu Jun 20 11:14:03 2013 +++ src/external/bsd/dhcp/dist/client/dhclient.c Tue Feb 4 17:34:39 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: dhclient.c,v 1.7 2013/06/20 15:14:03 christos Exp $ */ +/* $NetBSD: dhclient.c,v 1.8 2014/02/04 22:34:39 christos Exp $ */ /* dhclient.c @@ -33,7 +33,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: dhclient.c,v 1.7 2013/06/20 15:14:03 christos Exp $); +__RCSID($NetBSD: dhclient.c,v 1.8 2014/02/04 22:34:39 christos Exp $); #include dhcpd.h #include syslog.h @@ -60,6 +60,7 @@ isc_boolean_t hw_mismatch_drop = ISC_TRU int dhcp_max_agent_option_packet_length = 0; int interfaces_requested = 0; +int interfaces_left = 0; struct iaddr iaddr_broadcast = { 4, { 255, 255, 255, 255 } }; struct iaddr iaddr_any = { 4, { 0, 0, 0, 0 } }; @@ -367,8 +368,10 @@ main(int argc, char **argv) { */ go_daemon(); setup(); - if (interfaces_requested 0) + if (interfaces_requested 0) { add_interfaces(ifaces, interfaces_requested); + interfaces_left = interfaces_requested; + } free(ifaces); if (wanted_ia_na 0) { wanted_ia_na = 1; @@ -894,7 +897,7 @@ int find_subnet (struct subnet **sp, */ #include sys/cdefs.h -__RCSID($NetBSD: dhclient.c,v 1.7 2013/06/20 15:14:03 christos Exp $); +__RCSID($NetBSD: dhclient.c,v 1.8 2014/02/04 22:34:39 christos Exp $); void state_reboot (cpp) void *cpp; @@ -3486,6 +3489,9 @@ void finish_daemon (void) if (no_daemon) return; + if (interfaces_left --interfaces_left) + return; + /* Only do it once. */ if (state) return;
CVS commit: src/external/bsd/dhcp/dist/client
Module Name:src Committed By: christos Date: Thu Jun 20 12:15:38 UTC 2013 Modified Files: src/external/bsd/dhcp/dist/client: dhclient.8 Log Message: document -m flag To generate a diff of this commit: cvs rdiff -u -r1.1.1.2 -r1.2 src/external/bsd/dhcp/dist/client/dhclient.8 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/dhcp/dist/client/dhclient.8 diff -u src/external/bsd/dhcp/dist/client/dhclient.8:1.1.1.2 src/external/bsd/dhcp/dist/client/dhclient.8:1.2 --- src/external/bsd/dhcp/dist/client/dhclient.8:1.1.1.2 Sun Mar 24 18:50:27 2013 +++ src/external/bsd/dhcp/dist/client/dhclient.8 Thu Jun 20 08:15:38 2013 @@ -1,4 +1,4 @@ -.\ $NetBSD: dhclient.8,v 1.1.1.2 2013/03/24 22:50:27 christos Exp $ +.\ $NetBSD: dhclient.8,v 1.2 2013/06/20 12:15:38 christos Exp $ .\ .\ Id: dhclient.8,v 1.32.24.4 2011/04/15 22:12:50 sar Exp .\ @@ -76,6 +76,9 @@ dhclient - Dynamic Host Configuration Pr .B -q ] [ +.B -m +] +[ .B -1 ] [ @@ -249,6 +252,10 @@ inittab on System V systems. This impli Become a daemon immediately (nowait) rather than waiting until an an IP address has been acquired. .TP +.BI \-m +Don't require that the responding ethernet address of the dhcp server +matches the one we expect. +.TP .BI \-q Be quiet at startup, this is the default. .TP
CVS commit: src/external/bsd/dhcp/dist/client
Module Name:src Committed By: christos Date: Thu Jun 20 12:24:08 UTC 2013 Modified Files: src/external/bsd/dhcp/dist/client: dhc6.c dhclient.c Log Message: 1. don't try to open the pid file if the path is NULL 2. daemonize in two stages: always fork() first and wait for the child to tell us when the interface is ready, so that we don't lose track of the file descriptors since we are threaded. 3. Add an option (-m) not to match the hardware address of the responding dhcp server. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcp/dist/client/dhc6.c cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcp/dist/client/dhclient.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/dhcp/dist/client/dhc6.c diff -u src/external/bsd/dhcp/dist/client/dhc6.c:1.4 src/external/bsd/dhcp/dist/client/dhc6.c:1.5 --- src/external/bsd/dhcp/dist/client/dhc6.c:1.4 Tue Mar 26 20:38:07 2013 +++ src/external/bsd/dhcp/dist/client/dhc6.c Thu Jun 20 08:24:08 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: dhc6.c,v 1.4 2013/03/27 00:38:07 christos Exp $ */ +/* $NetBSD: dhc6.c,v 1.5 2013/06/20 12:24:08 christos Exp $ */ /* dhc6.c - DHCPv6 client routines. */ @@ -26,7 +26,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: dhc6.c,v 1.4 2013/03/27 00:38:07 christos Exp $); +__RCSID($NetBSD: dhc6.c,v 1.5 2013/06/20 12:24:08 christos Exp $); #include dhcpd.h @@ -1371,7 +1371,7 @@ start_init6(struct client_state *client) add_timeout(tv, do_init6, client, NULL, NULL); if (nowait) - go_daemon(); + finish_daemon(); } /* Index: src/external/bsd/dhcp/dist/client/dhclient.c diff -u src/external/bsd/dhcp/dist/client/dhclient.c:1.5 src/external/bsd/dhcp/dist/client/dhclient.c:1.6 --- src/external/bsd/dhcp/dist/client/dhclient.c:1.5 Sun Jun 16 19:49:50 2013 +++ src/external/bsd/dhcp/dist/client/dhclient.c Thu Jun 20 08:24:08 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: dhclient.c,v 1.5 2013/06/16 23:49:50 christos Exp $ */ +/* $NetBSD: dhclient.c,v 1.6 2013/06/20 12:24:08 christos Exp $ */ /* dhclient.c @@ -33,7 +33,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: dhclient.c,v 1.5 2013/06/16 23:49:50 christos Exp $); +__RCSID($NetBSD: dhclient.c,v 1.6 2013/06/20 12:24:08 christos Exp $); #include dhcpd.h #include syslog.h @@ -55,6 +55,7 @@ char *path_dhclient_script = path_dhclie /* False (default) = we write and use a pid file */ isc_boolean_t no_pid_file = ISC_FALSE; +isc_boolean_t hw_mismatch_drop = ISC_TRUE; int dhcp_max_agent_option_packet_length = 0; @@ -344,6 +345,8 @@ main(int argc, char **argv) { usage(); } #endif /* DHCPv6 */ + } else if (!strcmp(argv[i], -m)) { + hw_mismatch_drop = ISC_FALSE; } else if (!strcmp(argv[i], -v)) { quiet = 0; } else if (!strcmp(argv[i], --version)) { @@ -362,8 +365,7 @@ main(int argc, char **argv) { * Do this before setup, otherwise if we are using threads things * are not going to work */ - if (nowait) - go_daemon(); + go_daemon(); setup(); if (interfaces_requested 0) add_interfaces(ifaces, interfaces_requested); @@ -431,7 +433,8 @@ main(int argc, char **argv) { * to write a pid file - we assume they are controlling * the process in some other fashion. */ - if ((release_mode || exit_mode) (no_pid_file == ISC_FALSE)) { + if (path_dhclient_pid != NULL + (release_mode || exit_mode) (no_pid_file == ISC_FALSE)) { FILE *pidfd; pid_t oldpid; long temp; @@ -712,8 +715,6 @@ main(int argc, char **argv) { dmalloc_longterm = dmalloc_outstanding; dmalloc_outstanding = 0; #endif - - /* If we're not going to daemonize, write the pid file now. */ if (no_daemon || nowait) @@ -736,9 +737,9 @@ static void usage() log_fatal(Usage: dhclient #ifdef DHCPv6 - [-4|-6] [-SNTP1dvrx] [-nw] [-p port] [-D LL|LLT]\n + [-4|-6] [-SNTP1dvrx] [-nw] [-m] [-p port] [-D LL|LLT]\n #else /* DHCPv6 */ - [-1dvrx] [-nw] [-p port]\n + [-1dvrx] [-nw] [-m] [-p port]\n #endif /* DHCPv6 */ [-s server-addr] [-cf config-file] [-lf lease-file]\n @@ -815,7 +816,7 @@ void run_stateless(int exit_mode) /* If we're not supposed to wait before getting the address, don't. */ if (nowait) - go_daemon(); + finish_daemon(); /* If we're not going to daemonize, write the pid file now. */ @@ -893,7 +894,7 @@ int find_subnet (struct subnet **sp, */ #include sys/cdefs.h -__RCSID($NetBSD: dhclient.c,v 1.5 2013/06/16 23:49:50 christos Exp $); +__RCSID($NetBSD: dhclient.c,v 1.6 2013/06/20 12:24:08 christos Exp $); void state_reboot (cpp) void *cpp; @@ -1045,6 +1046,25 @@ void state_selecting (cpp) send_request (client); } +static isc_boolean_t +compare_hw_address(const char *name, struct packet *packet) { + if (packet-interface-hw_address.hlen - 1 != packet-raw-hlen || + memcmp(packet-interface-hw_address.hbuf[1], +
CVS commit: src/external/bsd/dhcp/dist/client
Module Name:src Committed By: christos Date: Thu Jun 20 15:14:03 UTC 2013 Modified Files: src/external/bsd/dhcp/dist/client: dhclient.c Log Message: file descriptor neatness. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcp/dist/client/dhclient.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/dhcp/dist/client/dhclient.c diff -u src/external/bsd/dhcp/dist/client/dhclient.c:1.6 src/external/bsd/dhcp/dist/client/dhclient.c:1.7 --- src/external/bsd/dhcp/dist/client/dhclient.c:1.6 Thu Jun 20 08:24:08 2013 +++ src/external/bsd/dhcp/dist/client/dhclient.c Thu Jun 20 11:14:03 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: dhclient.c,v 1.6 2013/06/20 12:24:08 christos Exp $ */ +/* $NetBSD: dhclient.c,v 1.7 2013/06/20 15:14:03 christos Exp $ */ /* dhclient.c @@ -33,7 +33,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: dhclient.c,v 1.6 2013/06/20 12:24:08 christos Exp $); +__RCSID($NetBSD: dhclient.c,v 1.7 2013/06/20 15:14:03 christos Exp $); #include dhcpd.h #include syslog.h @@ -894,7 +894,7 @@ int find_subnet (struct subnet **sp, */ #include sys/cdefs.h -__RCSID($NetBSD: dhclient.c,v 1.6 2013/06/20 12:24:08 christos Exp $); +__RCSID($NetBSD: dhclient.c,v 1.7 2013/06/20 15:14:03 christos Exp $); void state_reboot (cpp) void *cpp; @@ -3532,9 +3532,11 @@ void go_daemon (void) log_fatal (Can't fork daemon: %m); else if (pid) { char c; + close(pfd[0]); read(pfd[1], c, 1); exit (0); - } + } else + close(pfd[1]); } void write_client_pid_file ()
CVS commit: src/external/bsd/dhcp/dist/client
Module Name:src Committed By: christos Date: Sun Jun 16 23:49:50 UTC 2013 Modified Files: src/external/bsd/dhcp/dist/client: dhclient.c Log Message: Become daemon before initializing anything, otherwise this does not work with threaded workers. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcp/dist/client/dhclient.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/dhcp/dist/client/dhclient.c diff -u src/external/bsd/dhcp/dist/client/dhclient.c:1.4 src/external/bsd/dhcp/dist/client/dhclient.c:1.5 --- src/external/bsd/dhcp/dist/client/dhclient.c:1.4 Tue Mar 26 20:38:07 2013 +++ src/external/bsd/dhcp/dist/client/dhclient.c Sun Jun 16 19:49:50 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: dhclient.c,v 1.4 2013/03/27 00:38:07 christos Exp $ */ +/* $NetBSD: dhclient.c,v 1.5 2013/06/16 23:49:50 christos Exp $ */ /* dhclient.c @@ -33,7 +33,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: dhclient.c,v 1.4 2013/03/27 00:38:07 christos Exp $); +__RCSID($NetBSD: dhclient.c,v 1.5 2013/06/16 23:49:50 christos Exp $); #include dhcpd.h #include syslog.h @@ -105,6 +105,55 @@ static int check_domain_name_list(const static int check_option_values(struct universe *universe, unsigned int opt, const char *ptr, size_t len); +static void +setup(void) { + isc_result_t status; + /* Set up the isc and dns library managers */ + status = dhcp_context_create(); + if (status != ISC_R_SUCCESS) + log_fatal(Can't initialize context: %s, + isc_result_totext(status)); + + /* Set up the OMAPI. */ + status = omapi_init(); + if (status != ISC_R_SUCCESS) + log_fatal(Can't initialize OMAPI: %s, + isc_result_totext(status)); + + /* Set up the OMAPI wrappers for various server database internal + objects. */ + dhcp_common_objects_setup(); + + dhcp_interface_discovery_hook = dhclient_interface_discovery_hook; + dhcp_interface_shutdown_hook = dhclient_interface_shutdown_hook; + dhcp_interface_startup_hook = dhclient_interface_startup_hook; +} + + +static void +add_interfaces(char **ifaces, int nifaces) +{ + isc_result_t status; + + for (int i = 0; i nifaces; i++) { + struct interface_info *tmp = NULL; + status = interface_allocate(tmp, MDL); + if (status != ISC_R_SUCCESS) + log_fatal(Can't record interface %s:%s, + ifaces[i], isc_result_totext(status)); + if (strlen(ifaces[i]) = sizeof(tmp-name)) + log_fatal(%s: interface name too long (is %ld), + ifaces[i], (long)strlen(ifaces[i])); + strcpy(tmp-name, ifaces[i]); + if (interfaces) { + interface_reference(tmp-next, + interfaces, MDL); + interface_dereference(interfaces, MDL); + } + interface_reference(interfaces, tmp, MDL); + tmp-flags = INTERFACE_REQUESTED; + } +} int main(int argc, char **argv) { int fd; @@ -113,7 +162,6 @@ main(int argc, char **argv) { struct client_state *client; unsigned seed; char *server = NULL; - isc_result_t status; int exit_mode = 0; int release_mode = 0; struct timeval tv; @@ -128,6 +176,7 @@ main(int argc, char **argv) { int local_family_set = 0; #endif /* DHCPv6 */ char *s; + char **ifaces; /* Initialize client globals. */ memset(default_duid, 0, sizeof(default_duid)); @@ -151,25 +200,10 @@ main(int argc, char **argv) { setlogmask(LOG_UPTO(LOG_INFO)); #endif - /* Set up the isc and dns library managers */ - status = dhcp_context_create(); - if (status != ISC_R_SUCCESS) - log_fatal(Can't initialize context: %s, - isc_result_totext(status)); - - /* Set up the OMAPI. */ - status = omapi_init(); - if (status != ISC_R_SUCCESS) - log_fatal(Can't initialize OMAPI: %s, - isc_result_totext(status)); - - /* Set up the OMAPI wrappers for various server database internal - objects. */ - dhcp_common_objects_setup(); - - dhcp_interface_discovery_hook = dhclient_interface_discovery_hook; - dhcp_interface_shutdown_hook = dhclient_interface_shutdown_hook; - dhcp_interface_startup_hook = dhclient_interface_startup_hook; + if ((ifaces = malloc(sizeof(*ifaces) * argc)) == NULL) { + log_fatal(Can't allocate memory); + return 1; + } for (i = 1; i argc; i++) { if (!strcmp(argv[i], -r)) { @@ -320,27 +354,20 @@ main(int argc, char **argv) { } else if (interfaces_requested 0) { usage(); } else { - struct interface_info *tmp = NULL; - - status = interface_allocate(tmp, MDL); - if (status != ISC_R_SUCCESS) - log_fatal(Can't record interface %s:%s, - argv[i], isc_result_totext(status)); - if (strlen(argv[i]) = sizeof(tmp-name)) - log_fatal(%s: interface name too long (is %ld), - argv[i], (long)strlen(argv[i])); - strcpy(tmp-name, argv[i]); - if (interfaces) { - interface_reference(tmp-next, - interfaces, MDL); - interface_dereference(interfaces, MDL); - } -