Skip to content

Add IPv6 subnet pool allocation for network creation - #1480

Open
thrawn-sh wants to merge 1 commit into
containers:mainfrom
thrawn-sh:feature/ipv6-subnet-pool-allocation
Open

Add IPv6 subnet pool allocation for network creation#1480
thrawn-sh wants to merge 1 commit into
containers:mainfrom
thrawn-sh:feature/ipv6-subnet-pool-allocation

Conversation

@thrawn-sh

Copy link
Copy Markdown

Add support for sequential IPv6 subnet allocation from configurable subnet pools, complementing the existing IPv4 pool allocation and random IPv6 subnet generation (RFC 4193).

When container-libs passes a subnet_pools_v6 field in the create config, netavark now allocates IPv6 subnets sequentially from those pools — mirroring how subnet_pools works for IPv4. When the field is absent or empty, the existing random fd00::/8 allocation is used.

Key changes:

  • types.rs: Add subnet_pools_v6 field to CreateOpts with #[serde(default)] for backward compatibility with older container-libs versions that don't send this field.

  • subnet.rs: Add next_subnet_v6() for incrementing IPv6 network addresses using u128 arithmetic, and get_free_ipv6_network_subnet_from_pools() for sequential allocation with a 10,000 iteration cap to prevent runaway scans in large address spaces (e.g. fd00::/8 with /64 subnets has 2^56 candidates vs 256 for typical IPv4 pools).

  • driver.rs: Dispatch to pool-based allocation when subnet_pools_v6 is non-empty, falling back to random generation otherwise.

This is the netavark counterpart to the container-libs configuration wiring in podman-container-tools/container-libs#995.

Add support for sequential IPv6 subnet allocation from configurable
subnet pools, complementing the existing IPv4 pool allocation and
random IPv6 subnet generation (RFC 4193).

When container-libs passes a `subnet_pools_v6` field in the create
config, netavark now allocates IPv6 subnets sequentially from those
pools — mirroring how `subnet_pools` works for IPv4. When the field
is absent or empty, the existing random fd00::/8 allocation is used.

Key changes:

- types.rs: Add `subnet_pools_v6` field to `CreateOpts` with
  `#[serde(default)]` for backward compatibility with older
  container-libs versions that don't send this field.

- subnet.rs: Add `next_subnet_v6()` for incrementing IPv6 network
  addresses using u128 arithmetic, and `get_free_ipv6_network_subnet_from_pools()`
  for sequential allocation with a 10,000 iteration cap to prevent
  runaway scans in large address spaces (e.g. fd00::/8 with /64
  subnets has 2^56 candidates vs 256 for typical IPv4 pools).

- driver.rs: Dispatch to pool-based allocation when `subnet_pools_v6`
  is non-empty, falling back to random generation otherwise.

This is the netavark counterpart to the container-libs configuration
wiring in podman-container-tools/container-libs#995.
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.

1 participant