History log of /openbsd-current/usr.sbin/dhcpd/dhcp.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: OPENBSD_6_2_BASE
# 1.57 11-Jul-2017 reyk

Handle DHCPINFORM from clients behind a DHCP relay.

The dhcpinform() function has assumed that ciaddr matches the packet's
IP source address and didn't consider a relay, such as dhcrelay(8) -
indicated by giaddr, has forwarded the request.

Tested by landry@
OK krw@


# 1.56 24-Apr-2017 krw

Add 'echo-client-id' statment, so that RFC 6842 behaviour can be
turned off for those clients and networks that find it impossible to
move past RFC 2131. Modelled on the same statement in recent ISC
versions, though we default to 'on' (a.k.a. RFC 6842) rather that
'off' (a.k.a. RFC 2131).

Problems reported by Bastien Durel (Xerox Phaser 6022 printer) and
Bryan Vyhmeister (Hon Hai Precision router) via misc@. Thanks!


Revision tags: OPENBSD_6_1_BASE
# 1.55 13-Feb-2017 krw

branches: 1.55.4;
Eliminate pointless'%m' (a.k.a. hand rolled strerror()) by using fatal() and
log_warn(). Zap a couple of explicit 'syslog()' calls.


# 1.54 13-Feb-2017 krw

Adjust some long lines.


# 1.53 13-Feb-2017 krw

Switch from old errwarn.c logging to shiny new log.[ch].

ok benno@


# 1.52 24-Oct-2016 krw

Compare server-identifiers and reject packets only *after* applying
value specified in dhcpd.conf.

i.e. don't assume it is always the primary address of the interface
the packet arrived on.

Fixes issues with redundant dhcpd servers and CARP'd interfaces.

Issue reported and fix tested by Johan Huldtgren


# 1.51 12-Oct-2016 krw

client_identifier is not a string so using strlen() on it is
inappropriate. Which is why client_identifier_len exists.

Replace copy&pasted strlen() with client_identifier_len.

Symptoms (crash) and cause (bad c&p) spotted by sthen@.

tested & ok sthen@


# 1.50 10-Oct-2016 krw

Stop pretending we use RFC 3046/Option 82/Relay Agent Information.

RFC 3042 says servers that do not understand the option will not
echo it.

Plus, our desultory attempt at echoing was almost certainly broken
for OFFERs (use after free of packet data) and not even attempted
for NACKs.

ok millert@


# 1.49 06-Oct-2016 krw

Add support for RFC 6842. RFC 2131 said the server MUST NOT echo
the client-identifier value. RFC 6842 says the server MUST echo it.

Echoing the information disambiguates packets for relays and clients
when chaddr is 0. Similar to what dhcpv6 does.


# 1.48 05-Oct-2016 krw

Use consistant idiom (intermediate variable 'i' rather than repeated
uses of very long #define names) to access option data in nak_lease()
and ack_lease().

Shortens a lot of lines, which allows a number of line splits to
be eliminates.

Makes some upcoming diffs easier to integrate.

No intentional functional change.


# 1.47 04-Oct-2016 krw

Zap stray whitespace.


# 1.46 05-Aug-2016 krw

Don't leak the option data of non-DHCPINFORM messages received on
the udp socket.

Found by David Carlier.

ok yasuoka@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.45 06-Feb-2016 krw

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@.


# 1.44 21-Dec-2015 mmcc

remove NULL-checks before free()


# 1.43 20-Aug-2015 deraadt

stdlib.h is in scope; do not cast malloc/calloc/realloc*
ok millert krw


Revision tags: OPENBSD_5_8_BASE
# 1.42 15-Apr-2015 krw

Avoid using inet_ntoa() twice in a single printf() parameter list
by caching the results from excess inet_ntoa() calls before doing
the printf(). Should improve usefullness (?) of DHCPRELEASE log
entries by actually printing ciaddr and giaddr correctly when
dhcprelays stand between servers and clients.

Looks good to dlg@.


Revision tags: OPENBSD_5_7_BASE
# 1.41 11-Nov-2014 krw

Tweak the the DHCPACK to DHCPINFORM log entry so that it is
less threatening and more informative.

e.g.

DHCPACK on <null address> to 5c:51:4f:56:81:c3 via em0

changes to

DHCPACK to 192.168.19.62 (3c:97:0e:0c:0c:d7) via em0

Issue noted and diff tested by Marc Peters. Thanks!

ok yasuoka@ millert@


# 1.40 10-Nov-2014 krw

Typo: consitent -> consistent.


# 1.39 11-Aug-2014 tobias

validate len field for proper length, not just "not zero."

ok krw@


Revision tags: OPENBSD_5_6_BASE
# 1.38 11-Jul-2014 yasuoka

Fix DHCPINFORM not to lookup the lease database, not to fill the yiaddr
field and not to include the lease time parameters.

ok krw


# 1.37 11-Jul-2014 yasuoka

Add -u option to bind UDP port as a socket to answer DHCPINFORM from
the clients on non ethernet interfaces (eg. tun(4) or pppx(4)).

input krw
ok krw


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.36 05-Apr-2013 krw

send_packet() and writev() return ssize_t, not int. Use correct
type to store the returned value. From dhill.


# 1.35 22-Mar-2013 krw

RFC 2131 4.3.1 seems clear that a server MUST NOT include the
client-identifier option in OFFER or ACK messages. So stop
doing so.


# 1.34 11-Mar-2013 krw

RFC 2131 says don't ACK any REQUEST messages that contain a
server-identifier option that specifies a different dhcp server.

So don't.

Pointed put and fix tested by Andy via bugs@


Revision tags: OPENBSD_5_3_BASE
# 1.33 14-Feb-2013 krw

Obey RFC 2131 and when the broadcast flag is set send reply back
via udp broadcast and link-local broadcast. Not udp broadcast to
link address of client. Fixes at least some switches who
use the broadcast flag.

Bug submitted by Andy via bugs@, and fix tested by same. Thanks!

ok beck@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.32 29-Mar-2010 krw

Initialize 'flags' field of tree_cache stack variables to 0. Paranoia.


# 1.31 29-Mar-2010 krw

Always put server id in NAK's to requests. Some router/switches
need this, as reported in PR#6339.

Fix tested by submitter, Marcel Widget, who also supplied the diff
that I tweaked.

ok beck@


Revision tags: OPENBSD_4_7_BASE
# 1.30 02-Jan-2010 krw

Eliminate all uses of dmalloc() where the returned pointer
is checked for NULL and a specific error/warning issued. Add
two such manual warning/error checks and kill those dmalloc
calls. And then there were none, so kill dmalloc(). Whew.


# 1.29 01-Jan-2010 krw

Eliminate all uses of dfree() where the pointer is either dereferenced
immediately before the use or the pointer is checked for NULL before
the call. And then there were none, so kill dfree().


# 1.28 01-Sep-2009 reyk

Echo back the Relay Agent Information option if present (RFC 3046).
Also add support for the "ipsec-tunnel" hardware type as described in
RFC 3456.

ok henning@ krw@ (but needs more testing from others)


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.27 21-Jul-2008 millert

Initial stab at DHCPINFORM support. OK phessler@


# 1.26 07-May-2008 beck

Add synchronisation support for dhcpd - this allows for two dhcpd's
with the same configuration to be run on the same net and they will
keep their lease files/state in synch, and therefore allowing you to
run redundant dhcpd's. Synchronization code stolen from spamd, uses
an hmac key in /var/db/dhcpd.key if it exists.
ok krw@ deraadt@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.25 15-Dec-2006 stevesk

small KNF


Revision tags: OPENBSD_4_0_BASE
# 1.24 14-Jun-2006 ckuethe

Move the transmission of privsep messages into its own function. Wherever
we might have conditionally sent a message, we now just call the pfmsg()
function, and let it figure out whether the message should be sent or not.

ok henning


# 1.23 31-May-2006 ckuethe

This diff makes dhcpd able to manipulate pf tables on certain lease events.

dhcpd is now able to place abandoned addresses into a table (to offer some
protection against machines camping on an address) and remove them from the
table if they are properly leased.

When dhcpd assigns an IP to a new hardware address, it can remove that
address from a table. This is for use with the overload table in pf; newly
arrived machines will not be punished for the actions of a machine that
went away.

beck@ and krw@ liked previous versions of this, henning@ final ok


# 1.22 16-Mar-2006 claudio

KNF. No binary change.


# 1.21 13-Mar-2006 otto

tiny bit of delinting; ok krw@


Revision tags: OPENBSD_3_9_BASE
# 1.20 22-Nov-2005 beck

fix problem of dhcp server looping with "already acking lease"
when busy with short lease times. Fix by and discussed with millert
over a year ago, run at u of a for over a year, but never committed.
ok millert@ cloder@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.19 31-Jan-2005 claudio

Be a bit more paranoid about leases that are currently acked. There is a
small window where it is possible that a lease is acked and simultaniously
removed and so the state is not removed. This may be a cause for the
"already acking" issue. OK millert@


# 1.18 31-Jan-2005 claudio

Simply use the ethernet source address of the request as new ethernet
destination instead of the one included in the dhcp packet. Especially
because there are to many cases where the supplied address is wrong.
This hopefully solves all problems with gateways involved, like the
one reported by Dylan Martin.
OK krw@ henning@ millert@


# 1.17 29-Jan-2005 millert

Fix memory leak when supersede_lease() fails and it is a DHCPACK
or a dynamic BOOTREPLY offer. OK claudio@


# 1.16 06-Dec-2004 claudio

Bah, unbreak. from not form. Noticed by Dan Harnett.


# 1.15 06-Dec-2004 claudio

Set correct source address for relayed packets. This affects only setups that
use 'next-server' config option. From Hans Kremers. OK henning@


# 1.14 16-Sep-2004 deraadt

avoid aliasing with libc functions; ok henning


# 1.13 16-Sep-2004 claudio

Remove the not initialized fallback_interface code and use the normal bpf
interface for that. Also store the hardware (ethernet) address in the state
so that relayed dhcp request are sent to the correct destination.
OK henning@ requested by deraadt@ tested otto@


Revision tags: OPENBSD_3_6_BASE
# 1.12 24-May-2004 henning

typo; From: Andrey Matveev <andrushock@korovino.net>


# 1.11 04-May-2004 deraadt

remove DEBUG_PACKET stuff; henning ok


# 1.10 04-May-2004 deraadt

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


# 1.9 21-Apr-2004 canacar

filter writes and lock bpf descriptor, ok henning@


# 1.8 20-Apr-2004 henning

$OpenBSD$


# 1.7 19-Apr-2004 tom

Catch negative lease times. From openbsd@nerd-marrow.com in PR 2888,
which this closes (though the PR was for usr.sbin/dhcpd/server/).

ok henning@


# 1.6 18-Apr-2004 deraadt

spacing


# 1.5 18-Apr-2004 deraadt

various knf; henning ok


# 1.4 16-Apr-2004 deraadt

a bunch of knf, ok henning


# 1.3 14-Apr-2004 deraadt

spaces


# 1.2 13-Apr-2004 henning

time_t and kill a few dumb defines


# 1.1 13-Apr-2004 henning

may the whacking begin