[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 0/9] net: bootp: add native DHCPv4 support

From: Andre Przywara
Subject: [PATCH v2 0/9] net: bootp: add native DHCPv4 support
Date: Tue, 12 Feb 2019 17:46:51 +0000

This is a split-up of the previous all-in-one patch from Andrei,
to teach grub proper DHCP manners.
This split is based on my limited understanding of BOOTP/DHCP and grub,
but it should be an improvement over the single patch version anyway.
All patches compile and work, although only patch 8/9 actually enables
DHCP handling and makes grub work with DHCP servers without BOOTP
The series is build to first introduce some refactoring (patches 1-5),
than adding DHCP functionality in patches 6-8. Patch 9 adds the somewhat
optional net_dhcp command alias, which is identical to net_bootp.
I also fixed the white space and comment style options.

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

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.


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.


Andrei Borzenkov (9):
  net: dhcp: remove dead code
  net: dhcp: replace parse_dhcp_vendor() with find_dhcp_option()
  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 | 774 +++++++++++++++++++++++++++++-------------
 grub-core/net/ip.c    |   2 +-
 include/grub/net.h    |  14 +-
 3 files changed, 545 insertions(+), 245 deletions(-)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]