Skip to content

net: dhcp: current DHCP client implementation does not follow RFC2131 and RFC2132 #89641

Closed
@fjpse1

Description

@fjpse1

Describe the bug

Two problems have been detected in the DHCP client code:

  1. The DHCPREQUEST message does not contain the same 'xid' as the DHCPOFFER message.
  2. The PAD option is not processed correctly

Problem 1

According to the RFC2131 (see page 38 and table 5):

The DHCPREQUEST message contains the same 'xid' as the DHCPOFFER message.

In the current DHCP client implementation, each time a DHCPREQUEST is send, the "xid" value is incremented, so the "xid" value of the DHCPREQUEST is not the same that the "xid" value of the DCHPOFFER.

Problem 2

According to the RFC2132 (see page 4):

Options may be fixed length or variable length. All options begin with a tag octet, which uniquely identifies the option. Fixed-length options without data consist of only a tag octet. Only options 0 and 255 are fixed length. All other options are variable-length with a length octet following the tag octet.

In the current DHCP client implementation, option 0 (PAD option) is processed as a variable-length option, so when this option is present, an extra byte is read as the option length and corrupts the processing of options.

To Reproduce

The problem can be reproduced appling the attached patch and building the DHCP client test using the native_sim board.

  1. cd zephryproject/zephry/tests/net/dhcpv4/client
  2. copy the pad-option.patch in this directory
  3. git apply pad-option.patch
  4. west build -p -b native_sim/native/64 -t run

pad-option.patch

Expected behavior

  1. The "xid" value of the DHCPREQUEST must be the same value of the DHCPDISCOVER
  2. The options that appers after the PAD option must be processed correctly

Impact

Some DHCP servers discard the DHCPREQUEST because the "xid" value is not the same that the DHCPOFFER sent by them.

Also, the disruption of the correct processing of the PAD option can cause out-of-buffer readings.

Logs and console output

See console.png attachment to see the result of the test execution

Image

Environment (please complete the following information):

  • OS: WSL on Windows 10
  • Toolchain: zephyr-sdk-0.16.8
  • Commit SHA or Version used: main branch (e96bf44)

Additional context

Metadata

Metadata

Assignees

Labels

area: NetworkingbugThe issue is a bug, or the PR is fixing a bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions