summaryrefslogtreecommitdiff
path: root/sbin/dhclient
AgeCommit message (Collapse)Author
2014-12-05Move initial wait for network link into the state machine by addingKenneth R Westerback
state S_PREBOOT and associated state_preboot() function. This results in routing socket messages being processed even while the link is being waited for. Thus the RTM_IFINFO message announcing the link is ready can be reacted to immediately, rather than waiting for the sleep(1)'ing process to wake up and look at the link state. Some interfaces seem to lose the first packet sent when the RTM_IFINFO message is reacted to so quickly, so temporarily leave in place an explicit delay before sending the first packet.
2014-12-03Correct comment to state that the BPF program is patched inKenneth R Westerback
if_register_receive.
2014-11-30Don't check for hardware address change unless link was up. DelayKenneth R Westerback
construction of default client identifier until link is up (i.e. do it in state_reboot()).
2014-11-29Explicitly initialize client->state to S_REBOOTING rather thanKenneth R Westerback
relying on S_REBOOTING being 0.
2014-11-27Use if_nametoindex() to get the interface index, and thereby checkKenneth R Westerback
the validity of the interface name as soon the actual name is known. i.e. right after 'egress' is expanded. One less thing for get_hw_address() to do.
2014-11-26Reset ifi->errors after a successful receive_packet(), rather thanKenneth R Westerback
incrementing sporadic errors until the limit is exceeded. i.e. only exit dhclient when enough consecutive errors occur. Tweak error messages. Don't bother checking interface_status() when receive_packet() fails. Let other status checks function on their own.
2014-11-26'ifi' is successfully calloc'd during initialization or dhclientKenneth R Westerback
exits, so there is no need to constantly check if 'ifi' is NULL. Similarly 'ifi->bfdesc' is successfully opened during initialization or dhclient exits, so there is no point in constantly checking if it has regressed to -1. Finally, no need to check 'ifi->linkstat' before trying to read a packet. If there is a packet it should just as well be read immediately rather than waiting for the link to reappear and confuse things. No intentional functional change.
2014-11-26Rename 'got_one()' to 'packethandler()'.Kenneth R Westerback
2014-11-25r1.118 starting using LINK_STATE_IS_UP() to check the link statusKenneth R Westerback
info provided in RTM_IFINFO messages. But it didn't replicate the checks for IFI_NOMEDIA and (IFF_UP | IFF_RUNNING) used in interface_status() to set ifi->linkstat. So the test (LINK_STATE_IS_UP() != ifi->linkstat) was comparing kiwi fruit and hairballs. Do the additional checks using info present in the RTM_IFINFO message. As a result interface_status() need not be called to update ifi->linkstat. Thus avoiding opening/closing a socket and some ioctls to re-obtain the info already provided in the RTM_IFINFO message. Using RTM_IFINFO data ok mpi@
2014-11-23Rename discover_interface() to more meaningful get_hw_address().Kenneth R Westerback
Hoist one-time initialization of client identifier out of get_hw_address() to the one-time initialization code in main(). No intentional functional change.
2014-11-23Cleanup some struct interface_info fields. Make 'nomedia' a flag. ReplaceKenneth R Westerback
the two copies of the bpf socket descriptor (rfdesc, wfdesc) with just one (bfdesc). No need to keep a struct ifreq (ifp) since it's only used once and can be constructed there and discarded. Nuke unused 'primary_address' member. No intentional functional change.
2014-11-20A little too agressive reordering. Must initialize the client structKenneth R Westerback
before filling it in with read_client_conf(). Fixes seg fault when lease {} statement is used. Problem reported by Alessandro de Laurenzis via misc@. Thanks!
2014-11-17Further juggle startup code, putting config file reading after forkingKenneth R Westerback
the priv child but before getting hardware link. Reducing further the possibly inappropriate information the priv child could read.
2014-11-16Move some memory allocations/initialization and file reading toKenneth R Westerback
after forking the privileged process, which should not be reading those bits. No intentional functional change.
2014-11-16Read your compiler output even when it succeeds. Add missing variable toKenneth R Westerback
error print statement.
2014-11-15Make -q (quiet) and -d (don't daemonize) options mutually exclusive.Kenneth R Westerback
2014-11-13Tweak some comments and error messages. Put all "I can't handleKenneth R Westerback
this" tests at the top of the dispatch loop. Use a 'continue' instead of 'goto <label just after the while>'. No intended functional change.
2014-11-08Use open(O_CLOEXEC) rather than open() + fcntl(FD_CLOEXEC). InspiredKenneth R Westerback
by and ok guenther@.
2014-11-08Exhort user to recompile 'dhclient', not 'dhcpd', when bpf versions areKenneth R Westerback
mismatched.
2014-11-04Of the 14 occurances of free_client_lease() only 2 deal with leasesKenneth R Westerback
that might be in the client->leases TAILQ. So don't traverse said TAILQ in free_client_lease() trying see if the lease should be TAILQ_REMOVE()'d. Instead use TAILQ_REMOVE() in the two places (one of which is dubious) where it might be relevant. Be careful not to TAILQ_REMOVE() a static lease.
2014-11-04Instead of correcting things after the fact, use SOCK_NONBLOCK and SOCK_CLOEXECPhilip Guenther
to create the socketpair() with non-blocking and close-on-exec set. ok krw@
2014-11-03Don't leak static leases when the 'lease {}' parsing fails or one staticKenneth R Westerback
lease supersedes an earlier one.
2014-11-03No need to immediately remove an expired lease from the list ofKenneth R Westerback
leases. It will be ignored, so let the normal cleanup in bind_lease() take care of it.
2014-11-02Pesky whitespace and spurious parenthesis.Kenneth R Westerback
2014-11-01And finally move convert.c to the attic.Kenneth R Westerback
2014-11-01Unhook convert.c. It's empty but for the license text.Kenneth R Westerback
2014-11-01Try to ensure that the various lease timeouts are sane. i.e., renewKenneth R Westerback
is before rebind is before expiry. Don't allow lease expiry to be set past the end of time, but do allow lease lengths >INT32_MAX. Tweak default times to be more reliably in-line with RFCs. Nuke getULong(), the last function in convert.c, since its last uses were in this now re-written code. Suspicions aroused while diagnosing the expiry problem weerd@ found.
2014-10-29Calling a function to htonl() a constant 32-bit value into a stackKenneth R Westerback
variable and memcpy() that value into 4 bytes of malloc()'d space seems roundabout. Just memcpy() a four byte constant string into the malloc()'d space as required and kill putULong(). No functional change.
2014-10-27Compare with/use UINT16_MAX rather than 65535. Less magic is more.Kenneth R Westerback
2014-10-27Nuke getLong(), getShort(), getUShort(). Two line functions (memcpy();Kenneth R Westerback
ntoh[ls]()) obscure rather than simplify things. Especially when they are used only once. Just use the expansion.
2014-10-27htonl(ntohl(memcpy'd buf)) seems like the long way around to copyKenneth R Westerback
an IPv4 address. Just memcpy() it.
2014-10-27Zap extraneous whitespace and a stuttered extra 'break;'.Kenneth R Westerback
2014-10-26Allow the current lease to expire without causing dhclient to segKenneth R Westerback
fault when it tries to get a new one. Problem spotted by weerd@
2014-10-25Remove unnecessary netinet/in_systm.h include.Lawrence Teo
ok millert@
2014-10-17Nuke 'increase' which was always set to 1. Replace the if/else that testedKenneth R Westerback
its value with the body of the if. No functional change. 'increase' was orphaned when r1.139 eliminated support for 'medium' statements in dhclient.conf. Stumbled over while looking into a problem for weerd@.
2014-10-02dhclient: add support for RFC 3442 local subnet routesMatthew Dempsky
If the classless-static-routes option specifies the router IP address as 0.0.0.0, then that indicates the route is a "local subnet route" that should be directly routable via the interface. This reuses the "route add -net $dest -netmask $mask -cloning -iface $addr" trick suggested by claudio@ for r1.272. Restores interoperability with Google Compute Engine after recent GCE DHCP server changes. ok krw, mpi
2014-08-11When parsing 32 bit values, verify that we received 4 bytes.Tobias Stoeckmann
ok krw@
2014-07-28Fix memory exhaustion occurring on DHCP options with 0 length.Tobias Stoeckmann
halex@ and krw@ pointed out that a NULL check before free can go, too. ok deraadt@, halex@, krw@
2014-07-28merge dhcpd's packet.c revision 1.7:Tobias Stoeckmann
Fix very hard to reach DoS attack vector, which would involve more than 8 billion network packets. Mixture of many many malformed and proper packets could result in a division by zero. ok krw@
2014-07-14Make sure to correctly exit the loop in priv_flush_routes() in case ofMiod Vallat
allocation failure; ok krw@
2014-07-13When renewing a lease, update client->active or you end up in aKenneth R Westerback
tight renew loop. Caused by recent reshuffling of code in bind_lease().
2014-07-12Log a warning whenever RTM_DESYNC is seen. Thus giving entrailKenneth R Westerback
investigators some clue why dhclient may have gotten confused when some RTM_ messages vanish. sthen@ thinks this is a good start.
2014-07-12Bring back resolv.conf write reduction. Race was something else.Kenneth R Westerback
2014-07-11Sigh. Further torture finds a race. Back to drawing board forKenneth R Westerback
reducing resolv.conf writing.
2014-07-11Move updating resolv.conf contents and active lease to before addressKenneth R Westerback
manipulation starts. Thus making it more likely the correct resolv.conf gets written.
2014-07-11Don't write out a new resolv.conf until the new address is addedKenneth R Westerback
and we become responsible for the interface. Don't write out a new resolv.conf when our address has been deleted and we are no longer responsible for the interface. Less writing is more better.
2014-07-09Print sizeof() value and size_t variable with %zu rather than %zd.Kenneth R Westerback
2014-07-09Special case pretty printing of DHO_CLASSLESS_STATIC_ROUTES andKenneth R Westerback
DHO_CLASSLESS_MS_STATIC_ROUTES. Remove 'C' (CIDR) pretty printing outside of those special cases. Add a bunch of paranoia to protect against confused/malicious dhcp servers. Since 'C' is a variable size element it can't be handled by the existing code, which is designed for fixed size elements. Issue found by Someya Yuuichi, reported by yasuoka@ who also provided the first diff. ok yasuoka@
2014-05-23Make DEBUG a bit easier to use by calling setlogmask(LOG_UPTO(LOG_DEBUG))Kenneth R Westerback
when it is set, and the current setlogmask(LOG_UPTO(LOG_INFO)) when it is not set.
2014-05-23A #define to rename another #define which is then used only once introducesKenneth R Westerback
more obscurity than clarity. Nuke DHCPD_LOG_FACILITY and just use LOG_DAEMON in openlog() call.