Skip to content

bridge + dhcp IPAM: CNI DEL never sends a DHCPRELEASE #1324

Open

Description

@maiqueb

With the bridge plugin and dhcp IPAM, deleting a container never releases the DHCP lease; the address is only reclaimed when the lease expires.

Why

Current DEL order:

  1. bridge tears down the container interface: bridge.go#L826 (ip.DelLinkByNameAddr)
  2. bridge invokes IPAM DEL: bridge.go#L843-L846 (ipam.ExecDel)

The DHCP IPAM DEL then:

  1. calls DHCP.Release: main.go#L131
  2. stops the lease: daemon.go#L133
  3. triggers lease.release(): lease.go#L357-L360
  4. creates the client: lease.go#L428-L438 → lease.go#L554 (nclient4.New)
  5. which requires the link to exist: client.go#L204 (net.InterfaceByName)

By step 7 the link is already gone, so the release fails and no DHCPRELEASE is sent. On current main, WithUnicast also tries to bind the leased IP, which is gone as well:

eth0: failed to release DHCP lease: unable to apply option:
      unable to start listening UDP port: listen udp4 192.168.1.5:68:
      bind: cannot assign requested address

The failure is only logged inside the daemon; DHCP.Release still returns success, so CNI DEL reports no error. This has been broken since #702.

Reproduction

  • bridge network with "ipam": {"type": "dhcp"} and a DHCP server reachable over the bridge
  • run dnsmasq with --log-dhcp
  • CNI ADD, then CNI DEL
  • result: DHCPACK is logged on ADD; on DEL the daemon logs the failure above and dnsmasq never logs DHCPRELEASE

I have a regression test that drives the real bridge and dhcp binaries and asserts on the dnsmasq log; please check PR #1323, and run the DHCP unit tests (remember to remove the skip from that test).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions