summaryrefslogtreecommitdiff
path: root/sbin/dhclient/dhclient.c
AgeCommit message (Collapse)Author
2017-07-22Whitespace.Kenneth R Westerback
2017-07-22Oops. Missed chunk keeping /32 netmask magic.Kenneth R Westerback
2017-07-22Rename *_add_address to *_set_address to reflect that theKenneth R Westerback
lease address replaces all current addresses. Shuffle some code from bind_lease() into set_mtu()/set_address() to shrink bind_lease().
2017-07-21s/set_interface_mtu/set_mtu/gKenneth R Westerback
2017-07-21whitespace botch.Kenneth R Westerback
2017-07-20Restore RTM_DELADDR/RTM_NEWADDR monitoring to theKenneth R Westerback
minimum required to ensure that resolv.conf is written out on startup/HUP. Noticed by and fix tested by jmc@
2017-07-17Nuke findproto() and get_ifa(). They are unused now thatKenneth R Westerback
RTM_DELADDR and RTM_NEWADDR are no longer of interest. Pointed out by jca@
2017-07-17Remove some magic formerly used to detect the presence of anotherKenneth R Westerback
dhclient taking control of the interface. In particular do not exit when addresses are manually added to or deleted from the interface dhclient(8) is concerned about. Note that such changes will still be removed whenever dhclient(8) is re-started or gets a different lease during renewal.
2017-07-14Replace remaining "!var" expressions withKenneth R Westerback
"<var> == 0", "!(<var> & FLAG)" with "(<var> & FLAG) == 0", "!<func()>" with "<func()> == 0" and "!<define>" with "<define> == 0". And the positive cases as well. A few stray == NULL and != NULL as well.
2017-07-14Replace remaining "!<pointer>" expressions withKenneth R Westerback
"<pointer> == NULL". And of course "<pointer>" expressions with "<pointer> != NULL".
2017-07-14Pour the few relevant bits of the current lease and the offeredKenneth R Westerback
renewal lease into canonical forms and compare those rather than the leases themselves. Eliminates spurious interface and route manipulation when irrelevant aspects of the leases are changed by the DHCP server. Problem found by Paul de Weerd when his DHCP server returned renewed leases differing only by a decremented dhcp-lease-time option. ok mpi@
2017-07-10Take some of the mystery out of who does what byKenneth R Westerback
renaming "if_register_bpf()" to "get_bpf_sock()", "if_register_send()" to "get_udp_sock()" and "if_register_receive()" to "configure_bpf_sock()". Pull back interface_info knowledge and just pass the interface name, rdomain and bpf socket fd as required.
2017-07-10Use ioctlfd/routefd sockets rather than rolling one's ownKenneth R Westerback
for resolving 'egress' and adding a route. Move creation of main()'s ioctlfd up so it can be used for the 'egress' resolution.
2017-07-10Use a modern spacious idiom on all function local variableKenneth R Westerback
declarations.
2017-07-09Be consistent. "return (e);" -> "return e;"Kenneth R Westerback
2017-07-09Whitespace tweaks to assuage auto-indent.Kenneth R Westerback
2017-07-08Fold tables.c into options.c and stop exporting the oneKenneth R Westerback
table (dhcp_options) involved. Provide functions code_to_name(), name_to_code(), code_to_format() and replace direct access to dhcp_options with them. Eliminate unneeded 'struct option'. Unhook tables.c from Makefile.
2017-07-08Always use uintNN_t instead of sometimes u_intNN_tKenneth R Westerback
and sometimes uintNN_t.
2017-07-07Replace the many occurances of '256' with a new #defineKenneth R Westerback
DHO_COUNT.
2017-07-07dispatch_imsg() only needs to know name and rdomain.Kenneth R Westerback
No more struct interface_info knowledge in privsep.[ch]
2017-07-07Rename cons_options() to pack_options(), and do_packet() toKenneth R Westerback
unpack_options(). Store the unpacked options in a static variable. Move remaining raw packet processing from unpack_options() to packethandler(). No more struct interface_info knowledge in options.c
2017-07-06cons_options() only needs to know a buffer and a length toKenneth R Westerback
pack options into. Not all the gory details of interface_info. Move some of the raw packet processing out of options.c's do_packet() and into the more obvious dispatch.c's packethandler(). Mention that RFC791 is why we use 576-byte UDP packets.
2017-07-05Remove knowledge of struct interface_info from clparse.c. JustKenneth R Westerback
pass the interface name and the TAILQ to put static leases into. Add a TAILQ for static leases to struct client_config to hold the static leases until it's time to add them to ifi. Add add_lease() to add leases to a TAILQ while checking for leases that are superseded by the new lease.
2017-07-01Eliminate multiple socket openings/closings and passKenneth R Westerback
fd'd from main loops as required. One socket to do ioctl's per process (called ioctlfd) and one socket to do route messages per socket (called routefd). Clean up local variable declaration lists in passing.
2017-06-29delete_addresses(), interface_status(), addressinuse(),Kenneth R Westerback
lease_as_string() and rewrite_option_db() only use the interface name, so supply just the name. Tweak interface_link_forceup() to use the same param name as other functions taking the interface name.
2017-06-28Only pass required fields of interface_info to priv_* functionsKenneth R Westerback
and friends. i.e. ifi->name, ifi->rdomain, or both.
2017-06-28Stop trying to clean up addresses, routes and "-L" fileKenneth R Westerback
whenever dhclient dies. Eliminates differences in handling and thus need to intercept signals INT, TERM, USR1, USR2. Eliminates need for 'zapzombies' field and thus entire struct imsg_flushroutes. Eliminates need for 'imsg' parameter to and associated logic in priv_flush_routes(). Address, routes and '-L' file are still cleaned out when binding a lease.
2017-06-28Consistently use socket(..., AF_INET) for routingKenneth R Westerback
sockets to cut down on unwanted IPv6 messages. suggested by & ok claudio@
2017-06-27Nuke get_rdomain() and just snag the interface rdomain from the sameKenneth R Westerback
ifa we use to get the interface hw address. One less socket() and ioctl()! MIssed cleanup from shift to just watching RTM_IFINFO messages for rdomain switch.
2017-06-25Oops. Revert unintentional/premature functional change. Deleting theKenneth R Westerback
address configured by dhclient should cause exit, not restart. There is no need to invoke sendhup(). Just exit and let the privileged child follow.
2017-06-24Tweak handling of HUP and new LLADDR. Just use expose and use sighup()Kenneth R Westerback
function. Don't exit dispatch() loop on SIGHUP, wait for privileged child to execvp() dhclient. Eliminate struct imsg_hup since its contents were not being used except in priv_cleanup(). And 'active_addr' works just as well there. Cleaner and eliminates some extraneous log entries.
2017-06-24Use a local variable rather than a global flag to recordKenneth R Westerback
the reception of a IMSG_HUP message and trigger the desired restart. Nuke the now pointless IFI_HUP.
2017-06-23Once you have forked into two processes, setting a global flagKenneth R Westerback
in one process does not mean the other process can see the change. Nuke the pointless IFI_NEW_LLADDR.
2017-06-23Use a const char * for "/etc/resolv.conf.tail" instead of repeating theKenneth R Westerback
text in various forms in different error messages. Also makes the error messages consistent by always displaying the full path name.
2017-06-21Teach get_recorded_lease() that static leases do notKenneth R Westerback
expire.
2017-06-21No need to manually check validity of ifi->active whenKenneth R Westerback
REBOOT'ing. It will be pointing to a recorded lease if anything. So rely on get_recorded_lease() to return the next valid candidate lease, which might be the lease ifi->active was pointing at.
2017-06-21Consistently use time(&var) idiom rather than tossing in a fewKenneth R Westerback
var = time(NULL). Flip "struct interface *" to be the first parameter in set_timeout(), as in other functions taking the state info.
2017-06-21Allow familiar idiom free_client_lease(NULL).Kenneth R Westerback
2017-06-19Various KNF nits.Kenneth R Westerback
2017-06-19Erroneous host names in various options should be ignoredKenneth R Westerback
and not cause the lease to be declined. Restore inadvertantly changed behaviour. Tweak logic to also ignore invalid host names in domain-search. Reported by Christer Solskogen via misc@
2017-06-18Move the timeout information into struct interface_info withKenneth R Westerback
the rest of the dhcp state. One less struct (dhcp_timeout) to worry about, one less field (ifi) to keep track of.
2017-06-18Convert last set_timeout() use to set_timeout_interval() andKenneth R Westerback
then remove set_timeout() and rename set_timeout_interval() to set_timeout().
2017-06-18Drop (int) casts of (time_t - time_t) calculations thatKenneth R Westerback
are assigned to an int variable.
2017-06-18Nuke stray and misleading comment.Kenneth R Westerback
2017-06-18Make 'DEBUG' compile again.Kenneth R Westerback
2017-06-17Shuffle dhcp[offer|ack|nak]() functions together for easy reference.Kenneth R Westerback
2017-06-17Rename struct interface_info field 'new' to clearer 'offer'.Kenneth R Westerback
2017-06-17We accept either the first offer received, or an offer for theKenneth R Westerback
current address if one arrives inside select_timeout. So there is no need to keep a list of received offers. Just keep the best one and DECLINE the rest. Nuke now unused 'offered_leases' TAILQ. Also fixes the oddity that the *last* offer for the current address is taken rather than the *first*.
2017-06-17DECLINE offers as they are deemed invalid. Decline them at theKenneth R Westerback
first problem rather than continuing to look for other reasons to decline them. Nuke is_invalid field since it is now unused. More informative log message when a lease is determined to be unacceptable.
2017-06-16Nuke 'is_bootp' field and just use a #define to check if the leaseKenneth R Westerback
has DHO_DHCP_MESSAGE_TYPE info.