Skip to content

dhcp: send DHCPRELEASE with the client IP addr as ciaddr - #1279

Open
maiqueb wants to merge 1 commit into
mainfrom
fix-dhcp-release-issue-1278
Open

dhcp: send DHCPRELEASE with the client IP addr as ciaddr#1279
maiqueb wants to merge 1 commit into
mainfrom
fix-dhcp-release-issue-1278

Conversation

@maiqueb

@maiqueb maiqueb commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

The dhcp IPAM plugin sends DHCPRELEASE packets with 0.0.0.0 as the IP source address instead of the client's assigned IP.

This violates RFC 2131 section 4.4.4 (quote below) and causes DHCP servers (e.g. dnsmasq) to silently ignore the release. Leases are never freed - they only expire via timeout.

Use of broadcast and unicast
The DHCP client broadcasts DHCPDISCOVER, DHCPREQUEST and DHCPINFORM
messages, unless the client knows the address of a DHCP server. The
client unicasts DHCPRELEASE messages to the server.

By using the nclient4.WithUnicast() option to create the DHCPClient, the client will send unicast msgs.

Fixes: #1278

The dhcp IPAM plugin sends DHCPRELEASE packets with 0.0.0.0 as the IP source
address instead of the client's assigned IP.

This violates RFC 2131 section 4.4.4 and causes DHCP servers (e.g. dnsmasq) to
silently ignore the release. Leases are never freed — they only expire via
timeout.

By using the `nclient4.WithUnicast()` option, the client will stop using
a raw packet socket which constructs IP headers with 0.0.0.0 as the source.

Using src IP 0.0.0.0 is appropriate for DHCPDISCOVER (no address assigned yet)
but wrong for DHCPRELEASE.

Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
@maiqueb

maiqueb commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Tested this fix manually and it is working as expected - CNI DEL with DHCP IPAM sends the DHCPRELEASE msg w/ the proper source IP address, and in turn, dnsmasq actually processes the packet and releases the DHCP lease.

@zeeke zeeke left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

+1, he fix aligns with the RFC

@SchSeba SchSeba 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.

LGTM

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.

dhcp IPAM plugin: DHCPRELEASE sent with 0.0.0.0 source IP, ignored by servers

3 participants