summaryrefslogtreecommitdiff
path: root/sbin/dhclient/kroute.c
AgeCommit message (Collapse)Author
2019-05-17Don't put dhclient into a loop when interface-mtu is presentKenneth R Westerback
in a lease. dhclient.c r1.634 made every RTM_IFINFO restart the DHCP protocol and obtain a new/renewed lease. If the lease contained interface-mtu the interface MTU was set. An RTM_IFINFO is generated every time an interface MTU is set. So only set the interface MTU if it is different from the existing MTU. Fix using %d to print an unsigned value in passing. Noticed and fix inmproved & tested by Bj??rn Ketelaars while usihg the wifi on Dutch Railways.
2019-05-10Make it possible to switch between wireless and physical interfacsSebastian Benoit
(again?): when adding the default route, set it with the interface address of the interface we are configuring. This way its possible to have two default routes (from two running dhclient processes) in the routing table. Since wireless interfaces have a higher prio value, when a physical interface is connected it will be prefered (for new connections). ok krw@ mumble yes mumble claudio@
2019-02-23Correct comment on delete_addresses() return value.Kenneth R Westerback
2019-02-23Restore pre-a2k19 behaviour of clearing out all existing addressesKenneth R Westerback
when setting new address. That change needs specific consideration rather than inadvertant inclusion, especially after claiming no functional change was being made. Change and related problems noted and reversion tested by Kurt Mosiejczuk.
2019-02-12Restructure code to simplifiy imsg communications, further separatingKenneth R Westerback
DHCP knowledge and interface manipulation. Unprivileged process now sends proposal derived from the accepted lease to the privileged process rather than individual interface manipulation requests. The only intended functional change is that /etc/resolv.conf.tail is not re-read each time a new proposal is implemented, rather than once at dhclient startup.
2019-01-26Zap trailing space that stuck its head up.Kenneth R Westerback
2019-01-10"AF_* values are *almost* always the correct choice, particularly withKenneth R Westerback
POSIX APIs". Also sprach guenther@. So switch PF_ROUTE to AF_ROUTE in socket() and setsockopt() calls. Keep PF_ROUTE in sysctl(2) uses. adding a comment for future visitors, Also replace PF_UNSPEC with 0 in socketpair(), as socketpair(2) points out this is the only sensible value. Cluebat from and ok guenther@
2018-06-13Add a cloning direct route to the default route gateway when theKenneth R Westerback
gateway is not reachable via the IP address/netmask provided by the lease. Allows OpenBSD to work as well as iOS in certain weird/misconfigured/overly clever hotspots. A generalization of the handling of the /32 addresses handed out by Goggle Cloud, suggested by claudio@ Error in initial diff pointed out by henning@. Feedback from job@, mpi@, kn@. Tweaks & ok claudio@
2018-02-06Flip -q (be quiet) into -v (be noisy), making terseness the defaultKenneth R Westerback
behaviour. Always go daemon after link_timeout seconds and complete lease negotiations in the background if necessary. No hanging around in the foreground for the full 64 seconds waiting for a server to appear. Log a more relevant message when a default route can't be obtained via RTM_GET. i.e. "no default route" rather than "No such process". -q -> -v ok mpi@
2017-10-23Use 'for (;;)' instead of a mix of "while (1) {}" andKenneth R Westerback
"do {} while (1)".
2017-09-20Tweak, shorten, use more consistant verbiage.Kenneth R Westerback
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-20Use consistant simple verbiage when SIOC* ioctl's fail.Kenneth R Westerback
2017-09-20Wrong captilization, long lines.Kenneth R Westerback
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-15Use a poll() loop when trying read the default route fromKenneth R Westerback
a routing socket. Fixes at least one cause of resolv.conf confusion and possibly hanging/looping dhclient if the RTM_GET gets lost. Fingered by phessler@ when doing many suspend/resumes while switching between wifi and wired interfaces. Testing & ok phessler@
2017-09-14Strive to rationalize fatal[x]() usage andKenneth R Westerback
verbiage.
2017-09-09Tweak extract_classless_route() to return unsigned intKenneth R Westerback
and accept NULL pointers for unwanted components of the route.
2017-09-08Tweak route_in_rtstatic() to return the position of theKenneth R Westerback
route if found. Cleans up some int vs unsigned int confusion and makes the function more generally useful for future changes.
2017-08-31Don't delete v4 routes that are going to beKenneth R Westerback
added back. ok mpi@
2017-08-29Add a utility function extract_classless_route() andKenneth R Westerback
use it to simplify logic at both places that process RFC 3442 data.
2017-08-26Since we no longer try to uniquely label routes addedKenneth R Westerback
by dhclients, there is no need to retry adding a route if the first attempt fails with EEXIST. And EUNREACHABLE should be considered final since the address if any is already configured. Use log_getverbose() to allow logging of EEXIST errors.
2017-08-26Remove inadvertantly included param names inKenneth R Westerback
get_rtaddrs() prototype.
2017-08-26Change currently unused populate_rti_info() withKenneth R Westerback
the get_rtaddrs() everyone is using. Soon to be used or deleted.
2017-08-18Truncating a file and then deciding not to change itsKenneth R Westerback
contents doesn't do what you think it does. Restore "no dns servers, no search, means don't touch resolv.conf" behaviour unintentionally changed at t2k17. Noticed by ajacoutot@ during an upgrade using a non-OpenBSD dhcpd server that only provides the options it is asked for.
2017-08-14Try for consistency in sizeof() usage.Kenneth R Westerback
No intentional functional change.
2017-08-12Stop trying to outfox the routing tableKenneth R Westerback
by labelling dhclient routes. Just use the route(8) logic when flushing routes. ok benno@ claudio@
2017-08-10Add IMSG_SET_RESOLV_CONF and keep the cached contentsKenneth R Westerback
in the priv process, so that they do not have to be continually retransmitted. IMSG_WRITE_RESOLV_CONF now just triggers a write of the cached info. Simplifies a bunch of logic.
2017-08-09Stop obsessively flushing the imsg connection. JustKenneth R Westerback
flush any queued messages on getting a POLLOUT.
2017-08-08Rename resolv_conf_priority() to default_route_index() toKenneth R Westerback
reflect what it does.
2017-08-08KNF some long lines.Kenneth R Westerback
2017-08-06Simplify logic seeking/checking the interface overKenneth R Westerback
which the current default route exits. If the dhclient instance owns that interface it owns resolv.conf and will overwrite it no matter who created the default route. Feedback & suggestions claudio@
2017-08-05Factor out get_routes() to do the sysctl() danceKenneth R Westerback
needed to get a set of routes.
2017-08-05Bring route creation into line with what route(8) does. InKenneth R Westerback
particular stop providing RFA_IFA, and instead supply the relevant interface index in the RTM_ADD message. Various code simplifications as a result.
2017-08-05Don't delete the address/netmask that is about to beKenneth R Westerback
added. Just skip both the delete and the add.
2017-08-04Do not attempt to parse zero'd input buffer afterKenneth R Westerback
read() on routing socket fails. Just bail.
2017-08-03Whitespace.Kenneth R Westerback
2017-08-03Flush static (RTF_STATIC) routes and not justKenneth R Westerback
gateway (RTF_GATEWAY) routes. Thus catching and flushing direct routes that could have been added by dhclient.
2017-08-02Delete duplicated switch {} case: block.Kenneth R Westerback
2017-07-30Use effective_proposal data to build resolv.conf contents.Kenneth R Westerback
Fix a missing != NULL, and add a comment on why no search path and no dns servers means resolv.conf.tail is ignored.
2017-07-30Use effective_proposal data to set mtu and address.Kenneth R Westerback
2017-07-29Default routes supplied via DHO_CLASSLESS[_MS]_STATIC_ROUTESKenneth R Westerback
should have the same add_route() logic applied to them as the one supplied via DHO_ROUTERS. i.e. add the /32 route if needed, create direct route if gateway address is the same as interface address. Simplify logic by using the canonical rtstatic[] version of static routes created by lease_as_proposal().
2017-07-27Kill extra whitespace that snuck in.Kenneth R Westerback
2017-07-27Fold add_direct_route(), add_default_route() andKenneth R Westerback
add_classless_static_routes() into set_routes(). One less layer of abstraction and all five add_route() invocations now in one place. Clearly comment the route(8) command equivalents for each add_route() invocation.
2017-07-26Fix add_default_route() so -iface routes are actuallyKenneth R Westerback
created when gateway == interface address.
2017-07-24Throw DHO_STATIC_ROUTES to the floor! Roughly! EnsureKenneth R Westerback
they don't appear in effective leases at all.
2017-07-24Shuffle some declarations and functions into the onlyKenneth R Westerback
files they are used in. Tweak a bunch of whitespace.
2017-07-24Move invocations of flush_routes() and delete_addresses() fromKenneth R Westerback
bind_lease() into set_routes() and set_address() respectively.
2017-07-24Unify ROUNDUP macros for parsing route messages.friehm
Use the macro from route(8) / ospf6d(8) since it works also with argument 0. OK claudio@
2017-07-23Cease pretending to support option 33 (classFULL static routes). TheyKenneth R Westerback
are dead to the internet. And the current code actually creates /32 routes since kernel magic for classfull routes died a while ago. ok phessler@ claudio@ reyk@ sthen@