OpenBSD CVS

CVS log for src/sbin/dhclient/dispatch.c


[BACK] Up to [local] / src / sbin / dhclient

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.172 / (download) - annotate - [select for diffs], Sun Mar 28 17:25:21 2021 UTC (3 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9, HEAD
Changes since 1.171: +4 -4 lines
Diff to previous 1.171 (colored)

Now that the real time and monotonic time streams don't
cross flip CLOCK_REALTIME to CLOCK_MONOTONIC.

Suggested by cheloha@, millert@, otto@ at various
stages in the time_t -> timespec conversion.

Revision 1.171 / (download) - annotate - [select for diffs], Tue Mar 9 14:32:24 2021 UTC (3 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.170: +4 -2 lines
Diff to previous 1.170 (colored)

Replace time_t startup_time with struct timespec link_timeout.

Feedback from otto@

Revision 1.170 / (download) - annotate - [select for diffs], Tue Mar 2 16:17:26 2021 UTC (3 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.169: +4 -4 lines
Diff to previous 1.169 (colored)

Rename local variable 'cur_time' in set_timeout() to 'now' like
all the other struct timespec variables holding the current time.

Revision 1.169 / (download) - annotate - [select for diffs], Sat Feb 27 13:59:00 2021 UTC (3 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.168: +4 -1 lines
Diff to previous 1.168 (colored)

Disentangle log_debug() output from tick_msg() output.

Simplifies -v output, and reduces non-'-v' output.

Reduce non-'-v' output further by only displaying the first 'link up'
event.

Restore behaviour specified in dhclient.conf(5) of going daemon after
link-timeout seconds, rather than waiting another link-timeout seconds
for a lease to be accepted.

Lease verbiage problem reported, and fix tested by Mihai Popescu. Thanks!

Link verbiage problems reported, fix tested & ok tb@.

Revision 1.168 / (download) - annotate - [select for diffs], Fri Feb 19 13:33:37 2021 UTC (3 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.167: +2 -2 lines
Diff to previous 1.167 (colored)

Missed poll -> ppoll in log_warn() verbiage.

Revision 1.167 / (download) - annotate - [select for diffs], Mon Feb 1 01:42:21 2021 UTC (3 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.166: +18 -22 lines
Diff to previous 1.166 (colored)

Switch dispatch loop to ppoll() and protocol timeouts to struct timespec.

Reduces spurious packet transmissions in situations with short timings.

Suggestions millert@, further suggestions & ok cheloha@

Revision 1.166 / (download) - annotate - [select for diffs], Tue Nov 19 14:35:08 2019 UTC (4 years, 6 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.165: +4 -1 lines
Diff to previous 1.165 (colored)

Inform unwind about DNS servers it finds in leases.

ok florian@

Revision 1.165 / (download) - annotate - [select for diffs], Fri May 10 01:29:31 2019 UTC (5 years, 1 month ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.164: +1 -2 lines
Diff to previous 1.164 (colored)

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@

Revision 1.164 / (download) - annotate - [select for diffs], Sat Feb 16 18:42:07 2019 UTC (5 years, 3 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.163: +3 -1 lines
Diff to previous 1.163 (colored)

SSID/LLADDR/LINK_STATE_IS_UP changes must discard the previous
proposal to ensure the new lease is applied to the interface.

Revision 1.163 / (download) - annotate - [select for diffs], Sat Jan 19 21:07:13 2019 UTC (5 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.162: +7 -29 lines
Diff to previous 1.162 (colored)

Since dhclient no longer tries to clean up when exiting, there is no
need to start a new copy when LLADDR or SSID changes. Just go back to
S_PREBOOT and get a new lease.

Fewer log messages, faster join'ing new networks, simpler code.

Revision 1.162 / (download) - annotate - [select for diffs], Sat Jan 19 02:55:10 2019 UTC (5 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.161: +7 -7 lines
Diff to previous 1.161 (colored)

IMSG_HUP -> IMSG_RESTART. sendhup() -> sendrestart.

Revision 1.161 / (download) - annotate - [select for diffs], Sat Jan 19 02:45:05 2019 UTC (5 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.160: +4 -4 lines
Diff to previous 1.160 (colored)

Drop pseudo-signal idiom. Rename INTERNALSIG to TERMINATE. Use RESTART
instead of overloading SIGHUP.

Revision 1.160 / (download) - annotate - [select for diffs], Sat Jan 19 02:20:25 2019 UTC (5 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.159: +6 -13 lines
Diff to previous 1.159 (colored)

'quit' no longer holds signals, so strsignal(quit) is both pointless
and now in unreachable code. Simplifies dispatch loops by eliminating
most uses of INTERNALSIG.

Revision 1.159 / (download) - annotate - [select for diffs], Fri Jan 18 01:38:58 2019 UTC (5 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.158: +2 -2 lines
Diff to previous 1.158 (colored)

Be consistent in explicitly testing memcmp() return values.

Revision 1.158 / (download) - annotate - [select for diffs], Sat Jan 5 21:40:44 2019 UTC (5 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.157: +31 -21 lines
Diff to previous 1.157 (colored)

Simplify and clarify (i.e. shrink) code processing
the bpf captures.

Revision 1.157 / (download) - annotate - [select for diffs], Sat Jan 5 19:59:12 2019 UTC (5 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.156: +2 -2 lines
Diff to previous 1.156 (colored)

KNF nit.

Revision 1.156 / (download) - annotate - [select for diffs], Thu Jan 3 16:42:30 2019 UTC (5 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.155: +2 -1 lines
Diff to previous 1.155 (colored)

The need for separate bpf and routing message buffers was eliminated
when dhclient moved to processing the entire buffer rather than trying
to process one packet per dispatch() loop.

So use ifi->rbuf for both purposes, resizing it during initialization
to accommodate the larger of the routing socket read size or the bpf
socket read size.

Eliminates a calloc()/free() per routing socket read.

Revision 1.155 / (download) - annotate - [select for diffs], Thu Dec 27 17:19:56 2018 UTC (5 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.154: +2 -2 lines
Diff to previous 1.154 (colored)

Rename routehandler() to routefd_handler() to make the code slightly
more intuitive.

Revision 1.154 / (download) - annotate - [select for diffs], Thu Dec 27 17:02:03 2018 UTC (5 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.153: +10 -10 lines
Diff to previous 1.153 (colored)

Rename bfdesc to bpffd and packethandler() to bpffd_handler() to make
the code slightly more intuitive.

Revision 1.153 / (download) - annotate - [select for diffs], Sun Nov 4 16:32:11 2018 UTC (5 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.152: +2 -2 lines
Diff to previous 1.152 (colored)

No names in function prototypes. Spaces after commas in
function prototypes.

Revision 1.152 / (download) - annotate - [select for diffs], Fri Nov 2 16:15:55 2018 UTC (5 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.151: +14 -2 lines
Diff to previous 1.151 (colored)

When reacting to SIGHUP, i.e. trying to restart, ignore incoming
packets, routing socket messages and cancel any pending protocol
timeout.

Since >1 packet can be received from bpf at a time, don't process any
further buffered packets after one triggers a decision to exit or
a signal is received.

Revision 1.151 / (download) - annotate - [select for diffs], Tue Apr 24 07:06:49 2018 UTC (6 years, 1 month ago) by stsp
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.150: +4 -4 lines
Diff to previous 1.150 (colored)

Make dhclient show imsg pipe poll error messages in debug output only.
ok krw@

Revision 1.150 / (download) - annotate - [select for diffs], Wed Feb 28 22:16:56 2018 UTC (6 years, 3 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.149: +8 -8 lines
Diff to previous 1.149 (colored)

Now that log_debug() has been decyphered, replace DPRINTF() instances
with log_debug() so -v unleashes all debug output without having to
compile a custom dhclient.

Revision 1.149 / (download) - annotate - [select for diffs], Sun Jan 28 23:12:36 2018 UTC (6 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.148: +11 -25 lines
Diff to previous 1.148 (colored)

Refactor and simplify the logic to select and invoke the
appropriate function to process a packet.

Revision 1.148 / (download) - annotate - [select for diffs], Thu Jan 25 15:43:51 2018 UTC (6 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.147: +8 -22 lines
Diff to previous 1.147 (colored)

Add DPRINTF() and use it to replace log_debug() statements inside
#ifdef DEBUG/#endif blocks.

Suggestions on correct idiom (C99 vs gcc) from millert@

ok tom@

Revision 1.147 / (download) - annotate - [select for diffs], Wed Jan 24 19:12:49 2018 UTC (6 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.146: +3 -2 lines
Diff to previous 1.146 (colored)

Don't display the seconds until renewal. i.e. "em0: bound to 1.2.3.4
-- renewal in 300000 seconds" becomes simply "em0: bound to 1.2.3.4"

While here avoid setting timeouts before the current time.

ok florian@

Revision 1.146 / (download) - annotate - [select for diffs], Wed Sep 20 22:05:10 2017 UTC (6 years, 8 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.145: +3 -3 lines
Diff to previous 1.145 (colored)

Fix some spacing. A couple of log_warx() -> log_warn() to
use standard error messages for malloc errors.

Revision 1.145 / (download) - annotate - [select for diffs], Wed Sep 20 18:28:14 2017 UTC (6 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.144: +9 -9 lines
Diff to previous 1.144 (colored)

Make log messages more informative by using the
name of the function that failed and the significant
parameters. Distinguish between poll() errors and
problematic revents values.

Revision 1.144 / (download) - annotate - [select for diffs], Wed Sep 20 15:31:29 2017 UTC (6 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.143: +2 -3 lines
Diff to previous 1.143 (colored)

Remove stray %s/ifi->name from fatalx().

Revision 1.143 / (download) - annotate - [select for diffs], Tue Sep 19 12:33:52 2017 UTC (6 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.142: +6 -6 lines
Diff to previous 1.142 (colored)

flush_unpriv_ibuf() is now used only once so no
need to complicate things by passing it a string
identifying where it was called. Tweak log
verbiage.

Revision 1.142 / (download) - annotate - [select for diffs], Sun Sep 17 21:20:23 2017 UTC (6 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.141: +23 -21 lines
Diff to previous 1.141 (colored)

Create global 'log_procname' and set it to '<ifname>' or
'<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.

Revision 1.141 / (download) - annotate - [select for diffs], Thu Sep 14 00:10:17 2017 UTC (6 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.140: +2 -2 lines
Diff to previous 1.140 (colored)

Strive to rationalize fatal[x]() usage and
verbiage.

Revision 1.140 / (download) - annotate - [select for diffs], Thu Aug 31 17:01:48 2017 UTC (6 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.139: +2 -1 lines
Diff to previous 1.139 (colored)

Don't delete v4 routes that are going to be
added back.

ok mpi@

Revision 1.139 / (download) - annotate - [select for diffs], Sun Aug 13 17:57:32 2017 UTC (6 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.138: +6 -8 lines
Diff to previous 1.138 (colored)

Simplify HUP handling now that proper error
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.

Revision 1.138 / (download) - annotate - [select for diffs], Sat Aug 12 17:36:21 2017 UTC (6 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.137: +2 -1 lines
Diff to previous 1.137 (colored)

sig_atomic_t is not (necessarily) an int. Use
SIG_ATOMIC_MAX for INTERNALSIG instead of
INT_MAX.

Revision 1.137 / (download) - annotate - [select for diffs], Wed Aug 9 19:57:54 2017 UTC (6 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.136: +21 -3 lines
Diff to previous 1.136 (colored)

Stop obsessively flushing the imsg connection. Just
flush any queued messages on getting a POLLOUT.

Revision 1.136 / (download) - annotate - [select for diffs], Wed Aug 9 19:35:59 2017 UTC (6 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.135: +30 -15 lines
Diff to previous 1.135 (colored)

Add some additional poll() error checking. Remove checks
for EAGAIN as that is not a possible poll() errno.

suggestions & ok guenther@

Revision 1.135 / (download) - annotate - [select for diffs], Mon Jul 24 17:15:41 2017 UTC (6 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.134: +1 -100 lines
Diff to previous 1.134 (colored)

Shuffle some declarations and functions into the only
files they are used in. Tweak a bunch of whitespace.

Revision 1.134 / (download) - annotate - [select for diffs], Fri Jul 14 16:21:03 2017 UTC (6 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.133: +8 -8 lines
Diff to previous 1.133 (colored)

Replace remaining "!var" expressions with
"<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.

Revision 1.133 / (download) - annotate - [select for diffs], Fri Jul 14 13:08:41 2017 UTC (6 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.132: +6 -3 lines
Diff to previous 1.132 (colored)

bpf(4) *may* deliver more than one captured packet at a time. So when
the bpf socket signals that it has data, call packethandler() in a
loop until no more bpf packets are available.

Revision 1.132 / (download) - annotate - [select for diffs], Fri Jul 7 14:53:07 2017 UTC (6 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.131: +69 -2 lines
Diff to previous 1.131 (colored)

Rename cons_options() to pack_options(), and do_packet() to
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

Revision 1.131 / (download) - annotate - [select for diffs], Thu Jul 6 16:56:52 2017 UTC (6 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.130: +42 -5 lines
Diff to previous 1.130 (colored)

cons_options() only needs to know a buffer and a length to
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.

Revision 1.130 / (download) - annotate - [select for diffs], Sat Jul 1 23:27:56 2017 UTC (6 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.129: +10 -11 lines
Diff to previous 1.129 (colored)

Eliminate multiple socket openings/closings and pass
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.

Revision 1.129 / (download) - annotate - [select for diffs], Thu Jun 29 13:55:53 2017 UTC (6 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.128: +5 -5 lines
Diff to previous 1.128 (colored)

delete_addresses(), interface_status(), addressinuse(),
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.

Revision 1.128 / (download) - annotate - [select for diffs], Tue Jun 27 13:24:49 2017 UTC (6 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.127: +5 -19 lines
Diff to previous 1.127 (colored)

Nuke get_rdomain() and just snag the interface rdomain from the same
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.

Revision 1.127 / (download) - annotate - [select for diffs], Sat Jun 24 23:32:57 2017 UTC (6 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.126: +11 -20 lines
Diff to previous 1.126 (colored)

Tweak handling of HUP and new LLADDR. Just use expose and use sighup()
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.

Revision 1.126 / (download) - annotate - [select for diffs], Wed Jun 21 15:24:34 2017 UTC (6 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.125: +5 -4 lines
Diff to previous 1.125 (colored)

Consistently use time(&var) idiom rather than tossing in a few
var = time(NULL). Flip "struct interface *" to be the first
parameter in set_timeout(), as in other functions taking the
state info.

Revision 1.125 / (download) - annotate - [select for diffs], Mon Jun 19 19:28:35 2017 UTC (6 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.124: +3 -3 lines
Diff to previous 1.124 (colored)

Various KNF nits.

Revision 1.124 / (download) - annotate - [select for diffs], Sun Jun 18 21:08:15 2017 UTC (6 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.123: +12 -18 lines
Diff to previous 1.123 (colored)

Move the timeout information into struct interface_info with
the rest of the dhcp state. One less struct (dhcp_timeout) to
worry about, one less field (ifi) to keep track of.

Revision 1.123 / (download) - annotate - [select for diffs], Sun Jun 18 17:01:46 2017 UTC (6 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.122: +2 -11 lines
Diff to previous 1.122 (colored)

Convert last set_timeout() use to set_timeout_interval() and
then remove set_timeout() and rename set_timeout_interval() to
set_timeout().

Revision 1.122 / (download) - annotate - [select for diffs], Wed Jun 14 20:27:08 2017 UTC (6 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.121: +12 -10 lines
Diff to previous 1.121 (colored)

No need to be coy - call a "struct interface_info *" a
"struct interface_info *" and not a "void *".

No intentional functional change.

Revision 1.121 / (download) - annotate - [select for diffs], Wed Jun 14 16:52:35 2017 UTC (6 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.120: +2 -3 lines
Diff to previous 1.120 (colored)

Move active, new, offered_leases, leases from
client_state to interface_info.

Nuke empty struct client_state.

No intentional functional change.

Revision 1.120 / (download) - annotate - [select for diffs], Sun May 28 14:37:48 2017 UTC (7 years ago) by krw
Branch: MAIN
Changes since 1.119: +22 -40 lines
Diff to previous 1.119 (colored)

Elegant and reliable link status checking courtesy of mpi@.

Less of unreliable ioctl(SIOCGIFMEDIA), more getifaddrs().

ok mpi@

Revision 1.119 / (download) - annotate - [select for diffs], Wed Apr 5 18:22:30 2017 UTC (7 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.118: +24 -1 lines
Diff to previous 1.118 (colored)

Shuffle sendhup() into dispatch.c, the only place it is used.

Revision 1.118 / (download) - annotate - [select for diffs], Tue Apr 4 15:15:48 2017 UTC (7 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.117: +9 -13 lines
Diff to previous 1.117 (colored)

Send a RTM_PROPOSAL to clear out other dhclient instances on startup.

Replaces forcing interface link state down and up to generate
RTM_IFINFO messages.

Revision 1.117 / (download) - annotate - [select for diffs], Wed Mar 8 15:46:36 2017 UTC (7 years, 3 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.116: +2 -2 lines
Diff to previous 1.116 (colored)

Stray #endif w/o comment.

Revision 1.116 / (download) - annotate - [select for diffs], Tue Feb 14 22:46:53 2017 UTC (7 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.115: +6 -7 lines
Diff to previous 1.115 (colored)

fatalx() prepends 'fatal in _progname:'. So eliminate redundant
'; exiting' suffix used by old style logging.

Eliminate an extra log message before fatal()'ing out with a summary
message.

Revision 1.115 / (download) - annotate - [select for diffs], Sun Feb 12 15:53:15 2017 UTC (7 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.114: +9 -15 lines
Diff to previous 1.114 (colored)

Eliminate most strerror() invocations by using log_warn() and fatal()
instead of log_warnx() and fatalx(). A few log_info() to log_warn()
for the same reason.

Suggested by millert@.

Revision 1.114 / (download) - annotate - [select for diffs], Sun Feb 12 13:55:01 2017 UTC (7 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.113: +3 -3 lines
Diff to previous 1.113 (colored)

Adjust lines that are too long.

Revision 1.113 / (download) - annotate - [select for diffs], Sun Feb 12 13:15:50 2017 UTC (7 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.112: +15 -14 lines
Diff to previous 1.112 (colored)

Switch from 'legacy' errwarn.c to standard daemon logging functions.

No objections heard. Feedback from millert@ guenther@

Revision 1.112 / (download) - annotate - [select for diffs], Mon Jan 23 04:45:59 2017 UTC (7 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.111: +3 -16 lines
Diff to previous 1.111 (colored)

Keep socket open from startup, and reuse for SIOCGIFFLAGS later on,
rather than opening a fresh socket on the fly.
ok krw

Revision 1.111 / (download) - annotate - [select for diffs], Thu Oct 6 16:29:17 2016 UTC (7 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.110: +2 -3 lines
Diff to previous 1.110 (colored)

Add support for RFC 6842, which says the client MUST drop packets when
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.

Revision 1.110 / (download) - annotate - [select for diffs], Thu Sep 29 00:40:08 2016 UTC (7 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.109: +2 -2 lines
Diff to previous 1.109 (colored)

'ifname' --> 'ifi->name' so DEBUG compiles again.

Revision 1.109 / (download) - annotate - [select for diffs], Fri Sep 2 15:44:26 2016 UTC (7 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.108: +11 -6 lines
Diff to previous 1.108 (colored)

Kill 'ifi' global.

ok henning@, krw@

Revision 1.108 / (download) - annotate - [select for diffs], Wed Aug 31 12:57:31 2016 UTC (7 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.107: +2 -1 lines
Diff to previous 1.107 (colored)

Remove the 'client' global and make it per-ifp.

ok krw@

Revision 1.107 / (download) - annotate - [select for diffs], Tue Aug 23 09:26:02 2016 UTC (7 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.106: +12 -12 lines
Diff to previous 1.106 (colored)

Make the 'ifi' global local to dhclient.c and pass it as an argument to
functions needing it.

This is the first step to support multiple interfaces in one dhclient(8)
instance.

ok krw@

Revision 1.106 / (download) - annotate - [select for diffs], Thu Jul 21 09:58:55 2016 UTC (7 years, 10 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.105: +2 -2 lines
Diff to previous 1.105 (colored)

Use explicit idiom when testing the result of strcmp() and strncmp().
i.e. == 0 and != 0 as appropriate. No intentional functional change.

Suggested by & ok tom@

Revision 1.105 / (download) - annotate - [select for diffs], Sat Feb 6 19:30:52 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.104: +24 -4 lines
Diff to previous 1.104 (colored)

Eliminate #include inside *.h files and include only needed headers in
each *.c file.

Inspired by mention of header silliness by Edgar Pettijohn and mmcc@
on tech@.

Revision 1.104 / (download) - annotate - [select for diffs], Sat Dec 19 01:16:33 2015 UTC (8 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.103: +1 -2 lines
Diff to previous 1.103 (colored)

Delete superfluous "continue;" just before end of loop.

Revision 1.103 / (download) - annotate - [select for diffs], Thu Dec 3 20:54:13 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.102: +1 -7 lines
Diff to previous 1.102 (colored)

No need to continuously check the current rdomain of the interface
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@

Revision 1.102 / (download) - annotate - [select for diffs], Mon May 18 14:59:42 2015 UTC (9 years ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.101: +1 -68 lines
Diff to previous 1.101 (colored)

Stop rejecting leases with a subnet that overlaps a subnet already
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@

Revision 1.101 / (download) - annotate - [select for diffs], Thu Apr 16 15:14:31 2015 UTC (9 years, 1 month ago) by gsoares
Branch: MAIN
Changes since 1.100: +2 -2 lines
Diff to previous 1.100 (colored)

Tweak error output.
ok krw@

Revision 1.100 / (download) - annotate - [select for diffs], Fri Feb 6 04:18:20 2015 UTC (9 years, 4 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.99: +8 -4 lines
Diff to previous 1.99 (colored)

Don't let errors leak the memory returned by getifaddrs().

Revision 1.99 / (download) - annotate - [select for diffs], Wed Dec 10 02:34:03 2014 UTC (9 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.98: +2 -1 lines
Diff to previous 1.98 (colored)

Reusing the same field for different things in different contexts may
be clever, but it is definitely confusing. Use a flag IFI_VALID_LLADDR
to indicate that the ifi->hw_address field is valid, rather than
assuming ifi->linkstat does that. Add startup_time to record client
startup rather than using first_sending and hoping nobody else needs
it until link is complete.

Revision 1.98 / (download) - annotate - [select for diffs], Thu Nov 27 23:04:12 2014 UTC (9 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.97: +1 -2 lines
Diff to previous 1.97 (colored)

Use if_nametoindex() to get the interface index, and thereby check
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.

Revision 1.97 / (download) - annotate - [select for diffs], Wed Nov 26 19:25:31 2014 UTC (9 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.96: +6 -6 lines
Diff to previous 1.96 (colored)

Reset ifi->errors after a successful receive_packet(), rather than
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.

Revision 1.96 / (download) - annotate - [select for diffs], Wed Nov 26 17:34:36 2014 UTC (9 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.95: +6 -21 lines
Diff to previous 1.95 (colored)

'ifi' is successfully calloc'd during initialization or dhclient
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.

Revision 1.95 / (download) - annotate - [select for diffs], Wed Nov 26 00:15:36 2014 UTC (9 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.94: +4 -4 lines
Diff to previous 1.94 (colored)

Rename 'got_one()' to 'packethandler()'.

Revision 1.94 / (download) - annotate - [select for diffs], Sun Nov 23 18:22:45 2014 UTC (9 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.93: +15 -40 lines
Diff to previous 1.93 (colored)

Rename discover_interface() to more meaningful get_hw_address().

Hoist one-time initialization of client identifier out of
get_hw_address() to the one-time initialization code in main().

No intentional functional change.

Revision 1.93 / (download) - annotate - [select for diffs], Sun Nov 23 14:02:21 2014 UTC (9 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.92: +11 -18 lines
Diff to previous 1.92 (colored)

Cleanup some struct interface_info fields. Make 'nomedia' a flag. Replace
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.

Revision 1.92 / (download) - annotate - [select for diffs], Sun Nov 16 12:12:01 2014 UTC (9 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.91: +2 -2 lines
Diff to previous 1.91 (colored)

Read your compiler output even when it succeeds. Add missing variable to
error print statement.

Revision 1.91 / (download) - annotate - [select for diffs], Thu Nov 13 00:33:35 2014 UTC (9 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.90: +17 -23 lines
Diff to previous 1.90 (colored)

Tweak some comments and error messages. Put all "I can't handle
this" tests at the top of the dispatch loop. Use a 'continue' instead
of 'goto <label just after the while>'. No intended functional change.

Revision 1.90 / (download) - annotate - [select for diffs], Mon May 5 18:02:49 2014 UTC (10 years, 1 month ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.89: +3 -3 lines
Diff to previous 1.89 (colored)

Zap trailing whitespace. Started by pointed comments from andre@.

Revision 1.89 / (download) - annotate - [select for diffs], Tue Feb 18 01:46:58 2014 UTC (10 years, 3 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.88: +8 -2 lines
Diff to previous 1.88 (colored)

Do not create the default dhcp-client-identifier if an empty string
has been configured as the value.

i.e. 'send dhcp-client-identifier "";' in dhclient.conf will result in
no dhcp-client-identifier (option 61) being sent.

Useful for testing dhcp server behaviour.

Revision 1.88 / (download) - annotate - [select for diffs], Sun Feb 9 20:45:56 2014 UTC (10 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.87: +2 -7 lines
Diff to previous 1.87 (colored)

Don't use imsg_flush(), roll a local flush_unpriv_ibuf() that loops
on EAGAIN, sets quit to INTERNALSIG on errors (unless quit is already
set to something else), and prints a consistant error message when
errors other than EPIPE and end of file are encountered.

Fixes failure to write resolv.conf when -L is used, and makes
add_address() and add_route() also wait until imsg is in pipe.

Revision 1.87 / (download) - annotate - [select for diffs], Sun Dec 8 22:49:02 2013 UTC (10 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.86: +8 -7 lines
Diff to previous 1.86 (colored)

Reduce in_addr memcpy() dances by simply using assignments where the source
variable has been copied to [cm]alloc'ed memory and thus properly aligned.

Revision 1.86 / (download) - annotate - [select for diffs], Fri Dec 6 23:40:48 2013 UTC (10 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.85: +11 -10 lines
Diff to previous 1.85 (colored)

Having stopped pretending we handle anything but ethernet packets,
replace the 'struct hardware' abstraction layer and use 'struct
ether_addr' where hardware addresses are of interest.

ok matthew@, confirmed by reyk@ not to impact DHCP-over-IPSec support.

Revision 1.85 / (download) - annotate - [select for diffs], Thu Dec 5 21:32:59 2013 UTC (10 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.84: +4 -4 lines
Diff to previous 1.84 (colored)

Use destination size as size of memcpy(). Use <in_addr> rather than
<in_addr>.s_addr to shorten code.

ok deraadt@ matthew@ as part of larger diff

Revision 1.84 / (download) - annotate - [select for diffs], Wed Dec 4 19:39:50 2013 UTC (10 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.83: +5 -3 lines
Diff to previous 1.83 (colored)

More memcpy() stylistic repairs and size checks.

Revision 1.83 / (download) - annotate - [select for diffs], Sat Nov 16 19:34:43 2013 UTC (10 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.82: +3 -2 lines
Diff to previous 1.82 (colored)

Fix msgbuf_write() usage.

Revision 1.82 / (download) - annotate - [select for diffs], Mon Nov 11 21:00:01 2013 UTC (10 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.81: +3 -1 lines
Diff to previous 1.81 (colored)

Shuffle function prototypes and extern declarations around to
put local functions prototypes and variables in their .c files, and
cross-file functions into .h files. Prompted by deraadt@.

Revision 1.81 / (download) - annotate - [select for diffs], Sat Jul 6 01:12:20 2013 UTC (10 years, 11 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.80: +3 -3 lines
Diff to previous 1.80 (colored)

Zap leading whitespace.

Revision 1.80 / (download) - annotate - [select for diffs], Fri Jul 5 22:13:10 2013 UTC (10 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.79: +2 -2 lines
Diff to previous 1.79 (colored)

Zap trailing whitespace.

Revision 1.79 / (download) - annotate - [select for diffs], Fri May 10 18:59:22 2013 UTC (11 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.78: +2 -2 lines
Diff to previous 1.78 (colored)

Fix subnet check. Check our rdomain against the rdomains of the other
interfaces and not against our own.

Problem noted, fix tested and ok mikeb@

Revision 1.78 / (download) - annotate - [select for diffs], Thu May 2 16:35:27 2013 UTC (11 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.77: +7 -11 lines
Diff to previous 1.77 (colored)

Bunch of comment/whitespace cleanup. Eliminate some misleading or
pointless ones, make multiline comments readable, nuke '...' in
favour of '.', etc.

Revision 1.77 / (download) - annotate - [select for diffs], Fri Apr 5 19:19:05 2013 UTC (11 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.76: +2 -2 lines
Diff to previous 1.76 (colored)

Nuke parameter to do_packet() not used since 2006. From dhill.

Revision 1.76 / (download) - annotate - [select for diffs], Fri Mar 22 23:58:51 2013 UTC (11 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.75: +20 -4 lines
Diff to previous 1.75 (colored)

Ignore client-identifier option in leases from a server. They're not supposed
to be there! Instead, always record the client-identifier used to obtain
the lease. Ignore recorded leases that have a different client-identifier
than the one currently in force. If a client-identifier is not specified
in the dhclient.conf file, construct one from the network type and
MAC, like most other clients out there do these days.

Thus, if one plugs in a different USB network adapter, renewing the
previous lease (which upsets servers due to the MAC being different)
is skipped and DISCOVER is attempted at once.

Issue noted and fix tested by tedu@.

Revision 1.75 / (download) - annotate - [select for diffs], Mon Feb 18 15:57:08 2013 UTC (11 years, 3 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.74: +10 -12 lines
Diff to previous 1.74 (colored)

Rework log messages to be more useful. Rename
IMGS_CLEANUP/imsg_cleanup/cleanup to IMSG_HUP/imsg_hup/sendhup to
more accurately reflect intent of causing the privileged process
to initiate restart.

There should now be one and only one message logged at termination
or restart, logged by the process initiating the termination or
restart.

As part of fixing this, remove duplicate cleanup attempts and exit
after sending IMSG_HUP. These make logged messages more consistant and
fix issues with incorrect cleanups.

More prodding from deraadt@

Revision 1.74 / (download) - annotate - [select for diffs], Sun Feb 17 17:36:31 2013 UTC (11 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.73: +7 -7 lines
Diff to previous 1.73 (colored)

Using the value SIGQUIT to cause the dispatch loops to exit produced
universal revulsion and no little confusion.  #define our own value,
currently INT_MAX, which should not overlap any likely signal value.

Revision 1.73 / (download) - annotate - [select for diffs], Sun Feb 17 17:04:41 2013 UTC (11 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.72: +2 -2 lines
Diff to previous 1.72 (colored)

Suppress some pointless debugging message:

1) If the pipe to the priv process is closed while waiting for
something to happen in the non-priv dispatch() loop, assume the
priv process issued an error message and exit without additional
verbiage.

2) Ditto if the pipe to the priv process is closed when the flush
of IMSG_CLEANUP is attempted.

3) No need to report when SIOCDIFADDR fails because the address is
already gone.

Start to ensure the priv process always issues a useful message
before exiting by noting when it restarts due to the LLADDR having
changed.

Prodded by deraadt@ to clean this up.

Revision 1.72 / (download) - annotate - [select for diffs], Thu Feb 14 22:18:12 2013 UTC (11 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.71: +1 -4 lines
Diff to previous 1.71 (colored)

When an interface generates an RTM_IFINFO message, it may be as the
result of its LLADDR changing! Check said address and if it differs
from what we think it is, simulate a SIGHUP to restart, getting the
new address and a new lease for it.

Spotted by, fix tested by, and ok beck@

Revision 1.71 / (download) - annotate - [select for diffs], Wed Feb 13 19:32:52 2013 UTC (11 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.70: +12 -8 lines
Diff to previous 1.70 (colored)

Restore previous behaviour of not cleaning up in response to SIGTERM.

SIGTERM is used to make processes go away during system shutdown and
NFS filesystems may be still be in use when it is received. So removing
routes to the NFS servers is a bad thing.

Problem discovered and fix tested by landry@.

Revision 1.70 / (download) - annotate - [select for diffs], Fri Jan 18 06:05:54 2013 UTC (11 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.69: +33 -14 lines
Diff to previous 1.69 (colored)

Change a bunch of error()'s to warning()'s in the dispatch loop.
Set 'quit' to exit the loop in those situations, allowing more
cleanup() attempts in those error situations.

Revision 1.69 / (download) - annotate - [select for diffs], Sat Dec 29 14:40:00 2012 UTC (11 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.68: +9 -3 lines
Diff to previous 1.68 (colored)

Make HUP to either one of the processes cause a restart that will
have dhclient re-read dhclient.conf and get a new lease. Constrain
the filename passed to '-l' (alternate dhclient.lease.if location)
to be a regular file for the moment.

Original suggestion from phessler@. Feedback from deraadt@ and
espie@.

Revision 1.68 / (download) - annotate - [select for diffs], Tue Dec 4 19:24:03 2012 UTC (11 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.67: +13 -8 lines
Diff to previous 1.67 (colored)

Eliminate hand-rolled pseudo-strerror() %m strangeness by replacing
all occurances of %m with strerror(errno). And then nuking do_percentm()
and related buffer shuffling.

Also simplify parse_warn() so it takes a simple char * of the error,
and thus rely on pointing to error location in input for details.

Makes sense to beck@

Revision 1.67 / (download) - annotate - [select for diffs], Sat Nov 24 18:06:14 2012 UTC (11 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.66: +3 -2 lines
Diff to previous 1.66 (colored)

Don't segfault if no subnet-mask is provided, or is marked 'ignore'
in dhclient.conf.

Always zero out stack masks rather than using stack garbage when
no subnet-mask is provided.

Revision 1.66 / (download) - annotate - [select for diffs], Fri Nov 23 15:25:47 2012 UTC (11 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.65: +11 -3 lines
Diff to previous 1.65 (colored)

Use the libutil imsg framework rather than a hand-rolled local
version. This is the last hand-rolled imsg implementation I could
spot. Doesn't seem to break sparc64.

Suggested by chris@, tweaks from brad@ and reyk@.

ok reyk@

Revision 1.65 / (download) - annotate - [select for diffs], Thu Nov 8 21:32:55 2012 UTC (11 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.64: +18 -16 lines
Diff to previous 1.64 (colored)

Remove confusing extra address abstraction 'struct iaddr'. Just use
'in_addr'. Remove many double conversions and other perversions.
piaddr() replaced with inet_ntoa(). dhclient is extremely unlikely
to support anything but ipv4/dhcp without a complete rewrite.

Joint work with chris@.

Positive feedback from deraadt@ zinke@ phessler@.

Revision 1.64 / (download) - annotate - [select for diffs], Wed Nov 7 15:20:28 2012 UTC (11 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.63: +2 -2 lines
Diff to previous 1.63 (colored)

Use memset() consistently rather than tossing in a few bzero()'s.

Revision 1.63 / (download) - annotate - [select for diffs], Wed Nov 7 15:07:02 2012 UTC (11 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.62: +3 -3 lines
Diff to previous 1.62 (colored)

Use memcpy() consistently rather than tossing in a few bcopy()'s.

Revision 1.62 / (download) - annotate - [select for diffs], Sun Nov 4 23:40:59 2012 UTC (11 years, 7 months ago) by stsp
Branch: MAIN
Changes since 1.61: +2 -2 lines
Diff to previous 1.61 (colored)

Properly clear the UP flag while forcing the interface down/up
rather than setting all flags to zero. ok krw deraadt

Revision 1.61 / (download) - annotate - [select for diffs], Fri Nov 2 14:23:49 2012 UTC (11 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.60: +9 -5 lines
Diff to previous 1.60 (colored)

Watch the non-privileged end of the pipe to the privileged child
process. So when the child dies, the parent exits immediately.

Revision 1.60 / (download) - annotate - [select for diffs], Tue Oct 30 18:39:44 2012 UTC (11 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.59: +19 -13 lines
Diff to previous 1.59 (colored)

Nuke dhclient-script and dhclient.conf 'script' directive. Do all
interface and route configuration via ioctl's and routing sockets.

This will break configurations using local enhancements of
dhclient-script, which will now require alternate arrangements.

Committing early to allow time to identify and develop required
alternatives.

Several proddings by deraadt@.

Revision 1.59 / (download) - annotate - [select for diffs], Thu Oct 11 08:05:05 2012 UTC (11 years, 8 months ago) by sthen
Branch: MAIN
Changes since 1.58: +1 -3 lines
Diff to previous 1.58 (colored)

Remove the new (as of r1.56) line of code which updates ifi->linkstat in
the dispatch loop again; in the case where two RTM_IFINFO link changes occur
immediately after each other (as in the case with trunk and probably vlan)
dhclient missed the state change of the second interface.

ok krw@, who points out that dhcp packets received between the two
RTM_IFINFO messages would be lost, however the window is small (<0.4ms on
my laptop) and this is better than not noticing the link change.

Revision 1.58 / (download) - annotate - [select for diffs], Tue Sep 18 09:34:09 2012 UTC (11 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.57: +57 -1 lines
Diff to previous 1.57 (colored)

Don't accept leases that offer a subnet that is already configured
on an interface. Crude hammer that may be refined as needed.

Feedback from tedu@, beck@, sthen@ claudio@

Revision 1.57 / (download) - annotate - [select for diffs], Mon Sep 17 12:10:46 2012 UTC (11 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.56: +5 -10 lines
Diff to previous 1.56 (colored)

De-obfuscate and update reality correspondance of some comments.

Revision 1.56 / (download) - annotate - [select for diffs], Sat Sep 1 19:02:27 2012 UTC (11 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.55: +3 -13 lines
Diff to previous 1.55 (colored)

Nuke a static global I can't get my head around - interfaces_invalidated.
Since reinitialize_interface() was simply setting interfaces_invalidated
to 0, nuke it too!

Always update ifi->linkstat in dispatch() loop.

Revision 1.55 / (download) - annotate - [select for diffs], Sun Aug 26 23:33:31 2012 UTC (11 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.54: +9 -5 lines
Diff to previous 1.54 (colored)

Junk global cur_time, and use time(NULL) or local variables where
time is checked multiple times. Add a set_timeout_interval() function
to allow setting a timeout based on an interval from current time.

Fixes issues with initial startup where the global cur_time was
always old and caused initial DHCPDISCOVER or DHCPREQUEST packets
to be sent multiple times. And probably other timeout related
oddities.

Tested by naddy@

Revision 1.54 / (download) - annotate - [select for diffs], Sat Aug 18 00:20:01 2012 UTC (11 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.53: +4 -1 lines
Diff to previous 1.53 (colored)

Update global cur_time after exiting poll() and before calling the
state engine for packet processing. Time may have passed! Use cur_time
in routing message processing.

Makes sense to todd@

Revision 1.53 / (download) - annotate - [select for diffs], Thu Jul 26 18:42:58 2012 UTC (11 years, 10 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.52: +7 -4 lines
Diff to previous 1.52 (colored)

Make interface_status() assume that a link is up when IFM_AVALID
is not set. This is what the late interface_link_status() did.
Allows drivers who cannot tell what the link state is to get
dhcp leases.

Prodding by henning@.

ok deraadt@ miod@

Revision 1.52 / (download) - annotate - [select for diffs], Mon Jul 9 16:21:21 2012 UTC (11 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.51: +17 -93 lines
Diff to previous 1.51 (colored)

Terminate with extreme prejudice the multiple timeout queuing
mechanism that was a holdover from when dhclient handled multiple
interfaces at once. There is only one timeout possible at a time.

Also move calculation of current time to just before check to see
if the timeout has expired.

ok beck@ guenther@

Revision 1.51 / (download) - annotate - [select for diffs], Sun Jun 24 16:01:18 2012 UTC (11 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.50: +1 -32 lines
Diff to previous 1.50 (colored)

Nuke interface_link_status() (check media status only) and use
interface_status() (check IFF_UP|IFF_RUNNING and media status). The
interface is forced up when dhclient starts so the flags should be
correct.

Thanks to guenther@ for pointing out the original raison d'etre of
the difference between the two.

Revision 1.50 / (download) - annotate - [select for diffs], Fri Jun 22 01:01:59 2012 UTC (11 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.49: +3 -3 lines
Diff to previous 1.49 (colored)

Two 'ioctl() < 0' -> 'ioctl() == -1'. guenther@ says they're odd.

Revision 1.49 / (download) - annotate - [select for diffs], Sat Oct 23 14:26:57 2010 UTC (13 years, 7 months ago) by phessler
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.48: +4 -1 lines
Diff to previous 1.48 (colored)

make sure an interface is registered before we start using it

found by clang

OK claudio@, krw@

Revision 1.48 / (download) - annotate - [select for diffs], Sat Jul 3 04:44:51 2010 UTC (13 years, 11 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.47: +2 -2 lines
Diff to previous 1.47 (colored)

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains.  This changes the name of the
system calls, socket option, and ioctl.  After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me

Revision 1.47 / (download) - annotate - [select for diffs], Fri Jul 2 22:03:27 2010 UTC (13 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.46: +1 -28 lines
Diff to previous 1.46 (colored)

garbage collect an unused function; ok claudio

Revision 1.46 / (download) - annotate - [select for diffs], Wed Jun 2 09:57:16 2010 UTC (14 years ago) by phessler
Branch: MAIN
Changes since 1.45: +24 -1 lines
Diff to previous 1.45 (colored)

Have dhclient obey the interface's rdomain, instead of doing routes on
rdomain 0.

OK krw@, claudio@
sharp stick prodding from claudio@

Revision 1.45 / (download) - annotate - [select for diffs], Thu Nov 26 23:14:29 2009 UTC (14 years, 6 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.44: +3 -7 lines
Diff to previous 1.44 (colored)

Silence dhclient by immediately exiting if the interface doesn't exist
or can't return important flags via ioctl. Excess verbiage pointed out
by deraadt@.

ok henning@

Revision 1.44 / (download) - annotate - [select for diffs], Sat Jun 6 04:02:42 2009 UTC (15 years ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.43: +5 -1 lines
Diff to previous 1.43 (colored)

Nuke debug() unless DEBUG is defined. Elminates debug output from
normal operations.

Prodded by deraadt@ a while ago.

Revision 1.43 / (download) - annotate - [select for diffs], Thu Feb 19 03:29:21 2009 UTC (15 years, 3 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.42: +2 -3 lines
Diff to previous 1.42 (colored)

'(ifi->linkstat && ifi && ifi->rfdesc != -1)' is flawed. Swap the
first two terms so ifi is checked first.

Revision 1.42 / (download) - annotate - [select for diffs], Mon May 26 03:11:49 2008 UTC (16 years ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.41: +11 -9 lines
Diff to previous 1.41 (colored)

If an interface has no link at startup, try to force it up, and then
give it about 4 seconds of (silent) grace period before doing the verbose
search for a link...
tested by various developers who got burned a bit

Revision 1.41 / (download) - annotate - [select for diffs], Fri May 9 05:19:14 2008 UTC (16 years, 1 month ago) by reyk
Branch: MAIN
Changes since 1.40: +13 -17 lines
Diff to previous 1.40 (colored)

- don't give up when the link is not available on startup: dhclient
goes to background and listens on the routing socket for link to come
up before it retries.
- renew the lease whenever the link was lost and becomes active again.
- listen for link state changes on non-ethernet devices like wireless,
the link state becomes active when the wireless has been associated to
the AP and becomes active. this helps to automatically renew the lease
when the user is roaming.

ok beck@, deraadt@

Revision 1.40 / (download) - annotate - [select for diffs], Mon Nov 12 10:14:40 2007 UTC (16 years, 7 months ago) by dlg
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.39: +7 -10 lines
Diff to previous 1.39 (colored)

dont spew debug output when the SIOCGIFMEDIA ioctl errors with ENOTTY.

ok krw@ henning@

Revision 1.39 / (download) - annotate - [select for diffs], Wed Feb 14 23:15:01 2007 UTC (17 years, 3 months ago) by stevesk
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2, OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.38: +4 -6 lines
Diff to previous 1.38 (colored)

use errwarn functions vs. syslog(); ok henning@ krw@

Revision 1.38 / (download) - annotate - [select for diffs], Sat Jan 27 22:05:24 2007 UTC (17 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.37: +23 -77 lines
Diff to previous 1.37 (colored)

We only poll on the bpf fd and the routing socket fd. No need for
complex list code to keep track. So nuke it.

Also eliminate unnecessary variable ('dead') that means 'rfdesc is
closed'. Just set rfdesc to -1 when it is closed and use that.

As suggested by millert@ and claudio@, don't bother setting revents
members to zero since poll() does that.

Np functional change, just less code.

'looks good' claudio@  'I like where this is going' henning@

Revision 1.37 / (download) - annotate - [select for diffs], Thu Jan 11 02:36:29 2007 UTC (17 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.36: +7 -12 lines
Diff to previous 1.36 (colored)

Since bootp_packet_handler is always set to do_packet before we
process any packets, eliminate that abstraction and just call
do_packet directly.

No functional change.

ok stevesk

Revision 1.36 / (download) - annotate - [select for diffs], Thu Jan 4 22:17:48 2007 UTC (17 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.35: +5 -15 lines
Diff to previous 1.35 (colored)

Another round of cleanup. There is only one instance of struct
dhcp_packet and it is contained in the global *client. So don't pass
around pointers to a struct that contains a pointer to the dhcp_packet
instance. Just use the global client->packet. Eliminate unused struct
packet members and parameter lists accordingly.

No functional change.

Suggestions by stevesk@. ok stevesk@

Revision 1.35 / (download) - annotate - [select for diffs], Tue Dec 26 21:19:52 2006 UTC (17 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.34: +41 -52 lines
Diff to previous 1.34 (colored)

Our dhclient only handles one interface. Simplify code by using the
single, global, instance of 'struct interface_info' (ifi) rather than
passing around pointers to it.

"I agree" henning@

Testing moritz@ stevesk@, ok stevesk@

Revision 1.34 / (download) - annotate - [select for diffs], Tue Aug 29 04:09:27 2006 UTC (17 years, 9 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.33: +2 -2 lines
Diff to previous 1.33 (colored)

snuck in a typo, damnit

Revision 1.33 / (download) - annotate - [select for diffs], Tue Aug 29 03:55:09 2006 UTC (17 years, 9 months ago) by deraadt
Branch: MAIN
Changes since 1.32: +57 -2 lines
Diff to previous 1.32 (colored)

some net if devices do not media negotiate (for link) until brought up.
(for some drivers, this is a bug.  for others, it is part of how they work)
therefore before doing the 10-second link test, we must bring the if up.
ok krw, tested marco ckuethe

Revision 1.32 / (download) - annotate - [select for diffs], Tue May 24 03:11:12 2005 UTC (19 years ago) by todd
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9, OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.31: +8 -20 lines
Diff to previous 1.31 (colored)

no more 'ifconfig $if 0.0.0.0 up' only 'ifconfig $if up' since dhclient
uses bpf exclusively

ok deraadt@, henning@, claudio@

Revision 1.31 / (download) - annotate - [select for diffs], Tue Sep 21 04:07:03 2004 UTC (19 years, 8 months ago) by david
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.30: +2 -2 lines
Diff to previous 1.30 (colored)

spelling fixes; ok jmc@ henning@

Revision 1.30 / (download) - annotate - [select for diffs], Wed Sep 15 18:15:18 2004 UTC (19 years, 8 months ago) by henning
Branch: MAIN
Changes since 1.29: +2 -2 lines
Diff to previous 1.29 (colored)

no \n in error() calls and minor KNF, from Moritz Jodeit <moritz@jodeit.org>

Revision 1.29 / (download) - annotate - [select for diffs], Tue Jun 22 01:10:49 2004 UTC (19 years, 11 months ago) by canacar
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.28: +2 -2 lines
Diff to previous 1.28 (colored)

handle interface removals in the poll loop. ok henning@

Revision 1.28 / (download) - annotate - [select for diffs], Wed May 5 23:07:47 2004 UTC (20 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.27: +2 -2 lines
Diff to previous 1.27 (colored)

knf

Revision 1.27 / (download) - annotate - [select for diffs], Tue May 4 22:23:01 2004 UTC (20 years, 1 month ago) by mickey
Branch: MAIN
Changes since 1.26: +3 -3 lines
Diff to previous 1.26 (colored)

do not overload libc function names causing linker troubles

Revision 1.26 / (download) - annotate - [select for diffs], Tue May 4 21:48:16 2004 UTC (20 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.25: +7 -6 lines
Diff to previous 1.25 (colored)

knf

Revision 1.25 / (download) - annotate - [select for diffs], Tue May 4 20:28:40 2004 UTC (20 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.24: +3 -5 lines
Diff to previous 1.24 (colored)

remove things not used, spotted by lint mostly; ok henning

Revision 1.24 / (download) - annotate - [select for diffs], Tue May 4 18:58:50 2004 UTC (20 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.23: +2 -2 lines
Diff to previous 1.23 (colored)

more shrink and lint fixes; henning ok

Revision 1.23 / (download) - annotate - [select for diffs], Wed Apr 7 16:27:08 2004 UTC (20 years, 2 months ago) by henning
Branch: MAIN
Changes since 1.22: +2 -2 lines
Diff to previous 1.22 (colored)

fix a logic botch in discover_interfaces that prevented dhclient to see
any but the first real interface
found yesterday evening at RATT when dhclient would not get me a lease on
wireless

Revision 1.22 / (download) - annotate - [select for diffs], Tue Mar 2 18:49:21 2004 UTC (20 years, 3 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.21: +13 -16 lines
Diff to previous 1.21 (colored)

more pruning; henning ok

Revision 1.21 / (download) - annotate - [select for diffs], Tue Mar 2 13:39:44 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.20: +0 -1 lines
Diff to previous 1.20 (colored)

we deal with one interface at a time, so remove the interface list gunk.

Revision 1.20 / (download) - annotate - [select for diffs], Tue Mar 2 12:56:30 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.19: +1 -1 lines
Diff to previous 1.19 (colored)

remove dummy_interfaces and fallback_interface gunk

Revision 1.19 / (download) - annotate - [select for diffs], Tue Mar 2 12:46:44 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.18: +1 -3 lines
Diff to previous 1.18 (colored)

our interface discovery is so quiet now (nonexistant) that we don't need a
quiet_interface_discovery flag any more

Revision 1.18 / (download) - annotate - [select for diffs], Tue Mar 2 12:43:09 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.17: +2 -2 lines
Diff to previous 1.17 (colored)

mixing memcpy and bcopy in the same function is highly confusing

Revision 1.17 / (download) - annotate - [select for diffs], Tue Mar 2 12:40:31 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.16: +18 -60 lines
Diff to previous 1.16 (colored)

since we're dealing with one interface and not quite a few ones we can give
this one onterface as parameter to discove_interfaces and get rid of quite
some of the multiple-interface-discover logic

Revision 1.16 / (download) - annotate - [select for diffs], Tue Mar 2 12:19:14 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.15: +3 -12 lines
Diff to previous 1.15 (colored)

do not record all these interfaces we don't care about

Revision 1.15 / (download) - annotate - [select for diffs], Tue Feb 24 17:26:43 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.14: +1 -11 lines
Diff to previous 1.14 (colored)

whack unused token ring code and a few empty functions

Revision 1.14 / (download) - annotate - [select for diffs], Tue Feb 24 15:35:56 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.13: +2 -20 lines
Diff to previous 1.13 (colored)

get rid of tons of structs we never use, a lot of new_someotherjunk functions
in alloc.c we never call, and a shitload of genius comments like
char *script_name; /* name of script */
char *server_name; /* name of server */
etc etc etc...

Revision 1.13 / (download) - annotate - [select for diffs], Tue Feb 24 14:49:08 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.12: +3 -63 lines
Diff to previous 1.12 (colored)

discover_interfaces doesn't run in multiple modes any more - kill unreachable
code, partitally server-only

Revision 1.12 / (download) - annotate - [select for diffs], Tue Feb 24 11:35:39 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.11: +3 -16 lines
Diff to previous 1.11 (colored)

remove ill-advised interface discovery-scan, and require an interface to be
always given.
theo agrees with removal, pb ok

Revision 1.11 / (download) - annotate - [select for diffs], Mon Feb 23 20:09:02 2004 UTC (20 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.10: +4 -4 lines
Diff to previous 1.10 (colored)

remove time_t related crud; henning ok

Revision 1.10 / (download) - annotate - [select for diffs], Mon Feb 23 19:19:12 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.9: +1 -59 lines
Diff to previous 1.9 (colored)

remove allocation/storage/search code for subnets, shared networks, and
leases - it is server-only code.

Revision 1.9 / (download) - annotate - [select for diffs], Mon Feb 23 18:29:33 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.8: +1 -4 lines
Diff to previous 1.8 (colored)

scrap dead code

Revision 1.8 / (download) - annotate - [select for diffs], Mon Feb 23 18:21:15 2004 UTC (20 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.7: +1 -3 lines
Diff to previous 1.7 (colored)

dhclient always uses bpf on openbsd no matter what, it works, and we don't
need to fallback to their raw socket code
suddenly dhclient is so fast...
pb tested and sez ok

Revision 1.7 / (download) - annotate - [select for diffs], Tue Feb 10 13:12:48 2004 UTC (20 years, 4 months ago) by henning
Branch: MAIN
Changes since 1.6: +33 -1 lines
Diff to previous 1.6 (colored)

at startup, before sending several DHCPDISCOVER and waiting ages for answers,
check the link state of the interface(s) in question and don't try on
intrfaces that for sure have no link. interfaces with unknown linkstates are
treated as if they had a link, not all drivers are capable of reporting
linkstate upstream, and for some media there is no such thing as a link state.
saves quite sme time when booting notebooks configured for dhcp without
teh cable inserted...
note that this is the not yet active copy of dhclient
ok grange@ mcbride@ pb@ naddy@

Revision 1.6 / (download) - annotate - [select for diffs], Sat Feb 7 11:40:17 2004 UTC (20 years, 4 months ago) by henning
Branch: MAIN
Changes since 1.5: +6 -6 lines
Diff to previous 1.5 (colored)

whitespace police

Revision 1.5 / (download) - annotate - [select for diffs], Sat Feb 7 11:35:59 2004 UTC (20 years, 4 months ago) by henning
Branch: MAIN
Changes since 1.4: +154 -137 lines
Diff to previous 1.4 (colored)

more style fixes from Emil Mikulic <emikulic@dmr.ath.cx>
Thank you very much for this excellent work, it helps a lot.
binary unchanged.
I am still convinced dhclient can be made readable.

Revision 1.4 / (download) - annotate - [select for diffs], Wed Feb 4 12:16:56 2004 UTC (20 years, 4 months ago) by henning
Branch: MAIN
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (colored)

$OpenBSD$, tedu

Revision 1.3 / (download) - annotate - [select for diffs], Wed Feb 4 01:18:26 2004 UTC (20 years, 4 months ago) by henning
Branch: MAIN
Changes since 1.2: +169 -179 lines
Diff to previous 1.2 (colored)

8579 lines of KNF, ANSO and zap-junk diff without the resulting binary
changing by a single byte.
partly from theo

Revision 1.2 / (download) - annotate - [select for diffs], Mon Jan 26 19:15:50 2004 UTC (20 years, 4 months ago) by henning
Branch: MAIN
Changes since 1.1: +1 -7 lines
Diff to previous 1.1 (colored)

-we don't use SIOCGIFCONF any more, we use getifaddrs(). update comment.
-we don't need the socket any more either; remove.

ok deraadt@

Revision 1.1 / (download) - annotate - [select for diffs], Sun Jan 18 01:26:20 2004 UTC (20 years, 4 months ago) by deraadt
Branch: MAIN

this is where dhclient will start surgery

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.