consomme: fix DHCPv4 reply delivery and framing#3996
Merged
alextnewman merged 5 commits intoJul 22, 2026
Conversation
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
Contributor
There was a problem hiding this comment.
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.
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
Contributor
There was a problem hiding this comment.
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 theResultinside the closure and propagate it afterresp_udp.emitreturns.
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();
},
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
Brian-Perkins
approved these changes
Jul 22, 2026
damanm24
approved these changes
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
ciaddr, broadcast, thenyiaddrprecedence;ciaddr,yiaddr, andsiaddr, plus option 54;ciaddrfor renewal and rebinding requests;siaddrzero unless a real bootstrap server is configured;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.
consommetests passed.10.0.0.2/24with gateway10.0.0.1.10.0.0.2/24; gateway, DHCP server, and DNS server were10.0.0.1.