Skip to content

net: bootp: add native DHCPv4 support

Andre Przywara grub-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest10 patches 10 repliesIn review
  2. v29 patches 10 repliesSuperseded
  3. v11 patch 4 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10net: dhcp: remove dead codegrub-core/net/bootp.c+0 -290 replies
2/10net: dhcp: replace parse_dhcp_vendor() with find_dhcp_option()grub-core/net/bootp.c+117 -1101 reply
3/10net: dhcp: Allow overloading legacy bootfile and name fieldgrub-core/net/bootp.c include/grub/net.h+59 -13 replies
4/10net: dhcp: refactor DHCP packet transmission into separate functiongrub-core/net/bootp.c+81 -650 replies
5/10net: dhcp: make grub_net_process_dhcp take an interfacegrub-core/net/bootp.c grub-core/net/ip.c include/grub/net.h+16 -170 replies
6/10net: dhcp: introduce per-interface timeoutgrub-core/net/bootp.c include/grub/net.h+36 -40 replies
7/10net: dhcp: use DHCP options for name and bootfilegrub-core/net/bootp.c include/grub/net.h+54 -201 reply
8/10net: dhcp: allow receiving DHCP OFFER and ACK packetsgrub-core/net/bootp.c include/grub/net.h+70 -133 replies
9/10net: dhcp: actually send out DHCPv4 DISCOVER and REQUEST messagesgrub-core/net/bootp.c include/grub/net.h+121 -10 replies
10/10net: dhcp: add explicit net_dhcp commandgrub-core/net/bootp.c+5 -10 replies

Reviews trailers per patch

All 10 patches have a Reviewed-by or Acked-by.

PatchDaniel Kiper
1/10R-b
2/10R-b
3/10R-b
4/10R-b
5/10R-b
6/10R-b
7/10R-b
8/10R-b
9/10R-b
10/10R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 00/10] net: bootp: add native DHCPv4 support

A minor rework compared to v2, addressing Daniel's comments on the list. The former patch 2/9 has been split up to first refactor the parse_dhcp_vendor() function, then later introduce the OVERLOAD functionality. The other minor nits should be fixed as well, also I added Daniel's Reviewed-by: tags.
Again tested against a modern DHCP-only server and some legacy bootpd version.

Cheers,
Andre.

Original commit message:
----------------------------------
This patch adds support for native DHCPv4 and removes requirement for BOOTP compatibility support in DHCP server.

There is no provision for selecting preferred server. We take the first OFFER and try to REQUEST configuration from it. If NAK was received, transaction is restarted, but if we hit timeout, configuration fails.

It also handles pure BOOTP reply (detected by lack of DHCP message type option) and proceeds with configuration immedately. I could not test it because I do not have pure BOOTP server.

Because we need access to DHCP options in multiple places now, it also factors out DHCP option processing, adding support for option overload.

Timeout handling is now per-interface, with independent timeouts for both DISCOVER and REQUEST. It should make it more responsive if answer was delayed initially. Total timeout remains the same as originally, as well as backoff algorithm, but we poll in fixed 200ms ticks so notice (successful) reply earlier.

Failure to send packet to interface now does not terminate command (and leaks memory) but rather simply ignores this interface and continues with remaining ones if present.

Finally it adds net_dhcp alias with intention to deprecate net_bootp completely (it would be possible to make net_bootp to actually send BOOTP packet if someone thinks it is required).

Features not implements:

- DHCP server selection. We take first DHCPOFFER or BOOTPREPLY. No plans to implement.

- DHCP option concatenation (RFC3396). I do not expect to hit it in real life and it rather complicates implementation, so let's wait for actual use case.

- client identifier (RFC6842). So far we expect valid MAC address, which should be enough to uniquely identify client. It is also not clear how to generate unique client identifier if we ever need one.

v2: change find_dhcp_option to use subscripts to avoid signed/unsigned
comparison warning.

Should fix "may be used uninitialized" warning (although I could not reproduce it).

---------
This is a rebased version of Andrei's work from 2016 [1][2][3]. We have still this issue here where our company DHCP server does not support the BOOTP protocol, so grub doesn't get a valid IP address.

I took v2 from Andrei of the list, and fixed the minor conflicts during the rebase. I can confirm that this patch makes the difference between DHCP working and not:
grub-master> net_bootp
error: couldn't autoconfigure efinet0.
...
grub-patched> net_bootp
grub-patched> net_ls_addr
efinet0:dhcp 00:11:22:33:44:55 10.1.23.42

Also back in the days there were concerns about regressing BOOTP-only servers. So I took the CMU bootpd[4], disabled the DHCP extensions at compile time and still got IP addresses in both cases (patched/unpatched). dhclient on Linux on the other hand was not happy with that server and ignored the reply. I guess this is as close to a "BOOTP only server" as we can get in 2019.

I would be very happy if we can get this merged now.

Please let me know if you need more information or any help on this.

Thanks!
Andre.

P.S. The original patch didn't have a Signed-off-by:, so I kept it that way. Added mine for legal reason, feel free to drop it.

[1] http://lists.gnu.org/archive/html/grub-devel/2016-01/msg00035.html
[2] http://lists.gnu.org/archive/html/grub-devel/2016-03/msg00276.html
[3] http://lists.gnu.org/archive/html/grub-devel/2016-04/msg00066.html
[4] https://packages.debian.org/jessie/bootp

Andrei Borzenkov (10):
net: dhcp: remove dead code
net: dhcp: replace parse_dhcp_vendor() with find_dhcp_option()
net: dhcp: Allow overloading legacy bootfile and name field
net: dhcp: refactor DHCP packet transmission into separate function
net: dhcp: make grub_net_process_dhcp take an interface
net: dhcp: introduce per-interface timeout
net: dhcp: use DHCP options for name and bootfile
net: dhcp: allow receiving DHCP OFFER and ACK packets
net: dhcp: actually send out DHCPv4 DISCOVER and REQUEST messages
net: dhcp: add explicit net_dhcp command

 grub-core/net/bootp.c | 772 +++++++++++++++++++++++++++++-------------
 grub-core/net/ip.c    |   2 +-
 include/grub/net.h    |  14 +-
 3 files changed, 543 insertions(+), 245 deletions(-)
Signature · 1 line
2.17.1