Skip to content

[27.x backport] IPv6 only: add API option enable/disable IPv4#48343

Closed
vvoland wants to merge 4 commits intomoby:27.xfrom
vvoland:48271-27.x
Closed

[27.x backport] IPv6 only: add API option enable/disable IPv4#48343
vvoland wants to merge 4 commits intomoby:27.xfrom
vvoland:48271-27.x

Conversation

@vvoland
Copy link
Copy Markdown
Contributor

@vvoland vvoland commented Aug 16, 2024

- What I did

  • Added top level network-create option EnableIPv4 (which can later be hooked up to an option --ipv4 in the CLI, equivalent to --ipv6).
  • Added equivalent driver option com.docker.network.enable_ipv4.
    • Like enable_ipv6, it can be set via default-network-opts.
  • Show EnableIPv4 alongside EnableIPv6 in "inspect" output.
  • Predefined Linux none/host and Windows null networks are created with EnableIPv4=false.
  • Other networks, including predefined Linux bridge default to EnableIPv4=true.\
  • Ignore (clear) EnableIPv4 in a network create request if the API version is less than 1.47.
  • Require --experimental to disable IPv4.

Follow-up PRs will make the option do-something.

- How I did it

The first commit here, bumping the API version to 1.47, is likely to disappear - as this will be merged after another PR that does the same thing. But, for now, it means there's somewhere to put an API version-history.md update.

The rest is fairly machanical copying of EnableIPv6 behaviour.

- How to verify it

Can't disable IPv4 without --experimental:

# docker network create -o com.docker.network.enable_ipv4=false n1
Error response from daemon: IPv4 can only be disabled if experimental features are enabled

With --experimental, can disable IPv4:

# docker network create -o com.docker.network.enable_ipv4=false n1
e3fc95637aa2d9902ed188960283e025b95521cd44c95a645e0b48e7548ef2e6
# docker network inspect n1
[
    {
        "Name": "n1",
        ...
        "EnableIPv4": false,
        "EnableIPv6": false,

Default for a new bridge network is true:

# docker network create n2
9d71a90d0353fd352d53495fca214fa1a8ddecaca90c959a4ef9ed2318438d05
# docker network inspect n2
[
    {
        "Name": "n2",
        "Id": "9d71a90d0353fd352d53495fca214fa1a8ddecaca90c959a4ef9ed2318438d05",
        ...
        "EnableIPv4": true,
        "EnableIPv6": false,

Predefined host network shows EnableIPv4:false, like the existing EnableIPv6:false:

# docker network inspect host
[
    {
        "Name": "host",
        ...
        "EnableIPv4": false,
        "EnableIPv6": false,

Predefined bridge network has EnableIPv4:true:

# docker network inspect bridge
[
    {
        "Name": "bridge",
        ...
        "Driver": "bridge",
        "EnableIPv4": true,
        "EnableIPv6": false,
       ...

Marshalling/unmarshalling a libnetwork.Network with EnableIPv4:true is covered in an updated unit test.

- Description for the changelog

- API Changes:
  - `POST /networks/create` now has an `EnableIPv4` field. Setting it to `false`
  disables IPv4 IPAM for the network. It can only be set to `false` if the
  daemon has experimental features enabled.
  - `GET /networks/{id}` now returns an `EnableIPv4` field showing whether the
  network has IPv4 IPAM enabled.

robmry added 4 commits August 16, 2024 12:09
Signed-off-by: Rob Murray <[email protected]>
(cherry picked from commit a23dcf4)
Signed-off-by: Paweł Gronowski <[email protected]>
Signed-off-by: Rob Murray <[email protected]>
(cherry picked from commit d4d8611)
Signed-off-by: Paweł Gronowski <[email protected]>
Similar to EnableIPv6:
- Set it if EnableIPv4 is specified in a create request.
- Otherwise, set it if included in `default-network-opts`.
  - Apart from in a config-from network, so that it doesn't look
    like the API request set the field.
- Include the new field in  Network marshalling/unmarshalling test.

Signed-off-by: Rob Murray <[email protected]>
(cherry picked from commit 903daa4)
Signed-off-by: Paweł Gronowski <[email protected]>
Signed-off-by: Rob Murray <[email protected]>
(cherry picked from commit 1f542d5)
Signed-off-by: Paweł Gronowski <[email protected]>
@vvoland vvoland added status/2-code-review kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny area/networking Networking impact/api impact/changelog area/networking/ipv6 Networking labels Aug 16, 2024
@vvoland vvoland added this to the 27.2.0 milestone Aug 16, 2024
@vvoland vvoland self-assigned this Aug 16, 2024
@thaJeztah thaJeztah added the area/api API label Aug 16, 2024
Copy link
Copy Markdown
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

@akerouanton ptal

Copy link
Copy Markdown
Member

@akerouanton akerouanton left a comment

Choose a reason for hiding this comment

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

This PR adds a new field to network.CreateOptions but it's not wired up yet. If we merge it, we might see users coming up and saying that this new field doesn't do anything. So, I think it's not worth backporting should be delayed until we do have all the other IPv6-only PRs merged.

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

Labels

area/api API area/networking/ipv6 Networking area/networking Networking impact/api impact/changelog kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants