Skip to content

Remove generated MAC addresses on restart.#47168

Merged
thaJeztah merged 1 commit intomoby:masterfrom
robmry:47146-duplicate_mac_addrs
Jan 22, 2024
Merged

Remove generated MAC addresses on restart.#47168
thaJeztah merged 1 commit intomoby:masterfrom
robmry:47146-duplicate_mac_addrs

Conversation

@robmry
Copy link
Contributor

@robmry robmry commented Jan 22, 2024

- What I did

Since #45905 - the MAC address of a running container is stored in the same place as the configured address for a container.

So, when starting a stopped container, a generated address was treated as a configured address. If that generated address (based on an IPAM-assigned IP address) had been reused, the containers ended up with duplicate MAC addresses.

- How I did it

Remember whether the MAC address was explicitly configured, and clear it if not.

A similar approach is used for IPAM data (flag IPAMOperational). The plan is to refactor, to separate configured and operational state.

- How to verify it

New integration test.

- Description for the changelog

Ensure that a MAC address based on a container's IP address is re-generated when the container is stopped and restarted, in case the generated IP/MAC addresses have been reused.

- A picture of a cute animal (not mandatory but encouraged)

The MAC address of a running container was stored in the same place as
the configured address for a container.

When starting a stopped container, a generated address was treated as a
configured address. If that generated address (based on an IPAM-assigned
IP address) had been reused, the containers ended up with duplicate MAC
addresses.

So, remember whether the MAC address was explicitly configured, and
clear it if not.

Signed-off-by: Rob Murray <rob.murray@docker.com>
@robmry robmry force-pushed the 47146-duplicate_mac_addrs branch from 861cb3a to cd53b73 Compare January 22, 2024 17:52
Copy link
Member

@thaJeztah thaJeztah left a comment

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MAC address conflict since v25

3 participants