Skip to content

consomme: fix DHCPv4 reply delivery and framing#3996

Merged
alextnewman merged 5 commits into
microsoft:mainfrom
alextnewman:fix/consomme-dhcp-fidelity
Jul 22, 2026
Merged

consomme: fix DHCPv4 reply delivery and framing#3996
alextnewman merged 5 commits into
microsoft:mainfrom
alextnewman:fix/consomme-dhcp-fidelity

Conversation

@alextnewman

@alextnewman alextnewman commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Correct Consomme’s direct-client DHCPv4 reply behavior.

Consomme previously emitted replies with inconsistent link- and network-layer destinations, incomplete DHCPNAK fields, under-reported checksum state, and BOOTP messages shorter than the required minimum.

Update the DHCPv4 path to:

  • deliver OFFER and ACK replies using RFC 2131 ciaddr, broadcast, then yiaddr precedence;
  • broadcast DHCPNAKs with zero ciaddr, yiaddr, and siaddr, plus option 54;
  • copy and validate ciaddr for renewal and rebinding requests;
  • ignore requests selecting another DHCP server;
  • ignore relayed requests because Consomme has no relay-facing network path;
  • keep siaddr zero unless a real bootstrap server is configured;
  • report verified IPv4 and UDP checksums accurately;
  • pad every BOOTP/DHCP payload to the RFC 1542 minimum of 300 octets.

This remains a deliberately narrow DHCP server for Consomme’s single-guest NAT topology. It does not add relay support, intercept arbitrary UDP/67 traffic, or change DHCPv6.

Testing

All local and live validation was performed on a macOS ARM64 host.

  • Added packet-level coverage for broadcast/unicast OFFER, ACK, renewal, stale-binding NAK, foreign-server silence, unsupported-relay silence, checksum state, and BOOTP padding.
  • All 108 consomme tests passed.
  • Clippy, docs, and formatting checks passed.
  • AZL-3 ARM64 reached SSH and received 10.0.0.2/24 with gateway 10.0.0.1.
  • Windows ARM64 reached SSH and received 10.0.0.2/24; gateway, DHCP server, and DNS server were 10.0.0.1.
  • Both guests shut down cleanly with OpenVMM exit code 0.

Alex T Newman and others added 3 commits July 21, 2026 17:21
Use the request broadcast flag consistently at Ethernet, IPv4, and BOOTP layers, emit standards-compliant DHCPNAK fields, and report the generated UDP checksum state accurately.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Zero-pad emitted DHCP payloads to the 300-octet BOOTP minimum required by RFC 1542 and cover the wire length directly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Silently ignore requests selecting another server and unsupported relay traffic. Validate direct renewal addresses, preserve ciaddr in ACKs, and follow ciaddr delivery precedence.

Add packet-level coverage for ACK, renewal, stale binding, foreign-server, and relay states.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: ba714a8a-7d9a-4f49-8664-6526bb77a44a
Copilot AI review requested due to automatic review settings July 22, 2026 00:34
@alextnewman
alextnewman requested a review from a team as a code owner July 22, 2026 00:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR corrects Consomme’s DHCPv4 server reply behavior for the direct-client NAT topology, aligning reply delivery/framing and several RFC-required fields/behaviors.

Changes:

  • Fixes DHCPv4 reply destination selection (L2/L3) for OFFER/ACK/NAK, including ignoring foreign-server SELECTING requests and relayed requests.
  • Improves DHCPv4 reply framing/metadata: BOOTP minimum payload padding (300 bytes) and more accurate checksum state reporting.
  • Adds packet-level unit tests covering broadcast/unicast behavior, renewal/NAK cases, relay/foreign-server silence, checksum state, and BOOTP padding.

Comment thread vm/devices/net/net_consomme/consomme/src/dhcp.rs
Comment thread vm/devices/net/net_consomme/consomme/src/dhcp.rs
Set the test subnet and endpoint addresses explicitly and use the crate minimum MTU constant so fixture expectations do not depend on parameter defaults.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: ba714a8a-7d9a-4f49-8664-6526bb77a44a
Copilot AI review requested due to automatic review settings July 22, 2026 01:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

vm/devices/net/net_consomme/consomme/src/dhcp.rs:189

  • resp_dhcp.emit(...).unwrap() can panic on malformed/unexpected state derived from guest input. Even if it "should never fail" given the current length calculation, avoiding panics in packet paths is important; you can capture the Result inside the closure and propagate it after resp_udp.emit returns.
        resp_udp.emit(
            &mut resp_udp_packet,
            &IpAddress::Ipv4(resp_ipv4.src_addr),
            &IpAddress::Ipv4(resp_ipv4.dst_addr),
            resp_dhcp_len,
            |udp_payload| {
                let mut resp_dhcp_packet = DhcpPacket::new_unchecked(udp_payload);
                resp_dhcp.emit(&mut resp_dhcp_packet).unwrap();
            },

Comment thread vm/devices/net/net_consomme/consomme/src/dhcp.rs
Return smoltcp DHCP serialization errors through the packet-drop path instead of panicking in a guest-triggered handler.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: ba714a8a-7d9a-4f49-8664-6526bb77a44a
Copilot AI review requested due to automatic review settings July 22, 2026 01:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@github-actions

Copy link
Copy Markdown

@alextnewman
alextnewman merged commit 3450c6b into microsoft:main Jul 22, 2026
99 of 101 checks passed
@alextnewman
alextnewman deleted the fix/consomme-dhcp-fidelity branch July 22, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants