summaryrefslogtreecommitdiff
path: root/sbin/dhclient/dispatch.c
AgeCommit message (Collapse)Author
2018-02-28Now that log_debug() has been decyphered, replace DPRINTF() instancesKenneth R Westerback
with log_debug() so -v unleashes all debug output without having to compile a custom dhclient.
2018-01-28Refactor and simplify the logic to select and invoke theKenneth R Westerback
appropriate function to process a packet.
2018-01-25Add DPRINTF() and use it to replace log_debug() statements insideKenneth R Westerback
#ifdef DEBUG/#endif blocks. Suggestions on correct idiom (C99 vs gcc) from millert@ ok tom@
2018-01-24Don't display the seconds until renewal. i.e. "em0: bound to 1.2.3.4Kenneth R Westerback
-- renewal in 300000 seconds" becomes simply "em0: bound to 1.2.3.4" While here avoid setting timeouts before the current time. ok florian@
2017-09-20Fix some spacing. A couple of log_warx() -> log_warn() toKenneth R Westerback
use standard error messages for malloc errors.
2017-09-20Make log messages more informative by using theKenneth R Westerback
name of the function that failed and the significant parameters. Distinguish between poll() errors and problematic revents values.
2017-09-20Remove stray %s/ifi->name from fatalx().Kenneth R Westerback
2017-09-19flush_unpriv_ibuf() is now used only once so noKenneth R Westerback
need to complicate things by passing it a string identifying where it was called. Tweak log verbiage.
2017-09-17Create global 'log_procname' and set it to '<ifname>' orKenneth R Westerback
'<ifname> [priv]' as appropriate for the process doing the setting. Use it as the prefix in all log_*() output. Makes tracking messages for an interface or a process much easier.
2017-09-14Strive to rationalize fatal[x]() usage andKenneth R Westerback
verbiage.
2017-08-31Don't delete v4 routes that are going to beKenneth R Westerback
added back. ok mpi@
2017-08-13Simplify HUP handling now that proper errorKenneth R Westerback
checks are done on the imsg socket to detect closure, etc. Die immediately if the priv process notices the interface name can't be turned into an index.
2017-08-12sig_atomic_t is not (necessarily) an int. UseKenneth R Westerback
SIG_ATOMIC_MAX for INTERNALSIG instead of INT_MAX.
2017-08-09Stop obsessively flushing the imsg connection. JustKenneth R Westerback
flush any queued messages on getting a POLLOUT.
2017-08-09Add some additional poll() error checking. Remove checksKenneth R Westerback
for EAGAIN as that is not a possible poll() errno. suggestions & ok guenther@
2017-07-24Shuffle some declarations and functions into the onlyKenneth R Westerback
files they are used in. Tweak a bunch of whitespace.
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-14bpf(4) *may* deliver more than one captured packet at a time. So whenKenneth R Westerback
the bpf socket signals that it has data, call packethandler() in a loop until no more bpf packets are available.
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-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-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-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-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-19Various KNF nits.Kenneth R Westerback
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-14No need to be coy - call a "struct interface_info *" aKenneth R Westerback
"struct interface_info *" and not a "void *". No intentional functional change.
2017-06-14Move active, new, offered_leases, leases fromKenneth R Westerback
client_state to interface_info. Nuke empty struct client_state. No intentional functional change.
2017-05-28Elegant and reliable link status checking courtesy of mpi@.Kenneth R Westerback
Less of unreliable ioctl(SIOCGIFMEDIA), more getifaddrs(). ok mpi@
2017-04-05Shuffle sendhup() into dispatch.c, the only place it is used.Kenneth R Westerback
2017-04-04Send a RTM_PROPOSAL to clear out other dhclient instances on startup.Kenneth R Westerback
Replaces forcing interface link state down and up to generate RTM_IFINFO messages.
2017-03-08Stray #endif w/o comment.Kenneth R Westerback
2017-02-14fatalx() prepends 'fatal in _progname:'. So eliminate redundantKenneth R Westerback
'; exiting' suffix used by old style logging. Eliminate an extra log message before fatal()'ing out with a summary message.
2017-02-12Eliminate most strerror() invocations by using log_warn() and fatal()Kenneth R Westerback
instead of log_warnx() and fatalx(). A few log_info() to log_warn() for the same reason. Suggested by millert@.
2017-02-12Adjust lines that are too long.Kenneth R Westerback
2017-02-12Switch from 'legacy' errwarn.c to standard daemon logging functions.Kenneth R Westerback
No objections heard. Feedback from millert@ guenther@
2017-01-23Keep socket open from startup, and reuse for SIOCGIFFLAGS later on,Theo de Raadt
rather than opening a fresh socket on the fly. ok krw
2016-10-06Add support for RFC 6842, which says the client MUST drop packets whenKenneth R Westerback
the server provides a client-identifier value and it doesn't match the value the client sent. So stop suppressing client-identifer info in the leases file and when reading the leases file stop discarding leases that don't have current client-identifier info. Don't use them, but keep them around in case the client-identifier info changes back next time. Also construct the default client-identifier (if needed) before reading the leases file.
2016-09-29'ifname' --> 'ifi->name' so DEBUG compiles again.Kenneth R Westerback
2016-09-02Kill 'ifi' global.Martin Pieuchot
ok henning@, krw@
2016-08-31Remove the 'client' global and make it per-ifp.Martin Pieuchot
ok krw@
2016-08-23Make the 'ifi' global local to dhclient.c and pass it as an argument toMartin Pieuchot
functions needing it. This is the first step to support multiple interfaces in one dhclient(8) instance. ok krw@
2016-07-21Use explicit idiom when testing the result of strcmp() and strncmp().Kenneth R Westerback
i.e. == 0 and != 0 as appropriate. No intentional functional change. Suggested by & ok tom@
2016-02-06Eliminate #include inside *.h files and include only needed headers inKenneth R Westerback
each *.c file. Inspired by mention of header silliness by Edgar Pettijohn and mmcc@ on tech@.
2015-12-19Delete superfluous "continue;" just before end of loop.Kenneth R Westerback
2015-12-03No need to continuously check the current rdomain of the interfaceKenneth R Westerback
using the SIOCGIFRDOMAIN ioctl. If the rdomain is changed an RTM_IFINFO message is generated on the old rdomain indicating the interface is down. This will cause dhclient to exit, just like our manual check did but even faster! Should make pledging easier. Behaviour confirmed by phessler@
2015-05-18Stop rejecting leases with a subnet that overlaps a subnet alreadyKenneth R Westerback
present. The latest routing stack code can now handle these situations. Much requested by beck@ and others. Detailed discussion at s2k15 identified required routing changes. ok claudio@
2015-04-16Tweak error output.Gleydson Soares
ok krw@