Skip to content

Support multiple static IPs and validate subnets#557

Merged
Luap99 merged 1 commit intocontainers:mainfrom
Honny1:multi-static-ip-subnet
Mar 6, 2026
Merged

Support multiple static IPs and validate subnets#557
Luap99 merged 1 commit intocontainers:mainfrom
Honny1:multi-static-ip-subnet

Conversation

@Honny1
Copy link
Copy Markdown
Member

@Honny1 Honny1 commented Dec 15, 2025

Fixes allocation logic to support containers with multiple static IPs from different subnets, while preventing invalid subnet configurations.

Fixes: https://issues.redhat.com/browse/RHEL-98277

Related: containers/netavark#1379

@github-actions github-actions Bot added the common Related to "common" package label Dec 15, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Dec 15, 2025
@podmanbot
Copy link
Copy Markdown

✅ A new PR has been created in buildah to vendor these changes: containers/buildah#6603

@packit-as-a-service
Copy link
Copy Markdown

Packit jobs failed. @containers/packit-build please check.

@Honny1 Honny1 marked this pull request as ready for review December 15, 2025 16:36
@Honny1
Copy link
Copy Markdown
Member Author

Honny1 commented Dec 15, 2025

/packit rebuild-failed

@Honny1 Honny1 force-pushed the multi-static-ip-subnet branch from 1626621 to 4b6cbdb Compare February 10, 2026 14:07
@Honny1 Honny1 force-pushed the multi-static-ip-subnet branch from 4b6cbdb to 8e205ad Compare March 2, 2026 19:07
@Honny1
Copy link
Copy Markdown
Member Author

Honny1 commented Mar 2, 2026

PTAL @Luap99 @mheon

@Honny1 Honny1 force-pushed the multi-static-ip-subnet branch from 8e205ad to 7524bc5 Compare March 2, 2026 19:13
Copy link
Copy Markdown
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

one minor nit, LGTM overall


network := types.Network{Driver: "bridge", Subnets: ns}
_, err := libpodNet.NetworkCreate(network, nil)
if wantErr {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just practically speaking we do not need that bool just match on errContains != "" and drop the bool which makes the test case listing a bit simpler and avoids the issue where someone has set wantErr true but not provided an error message to match on

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have removed wantErr.

@Luap99
Copy link
Copy Markdown
Member

Luap99 commented Mar 5, 2026

also cc @ashley-cui as you move the creation validation logic into netavark so this new check needs to be there as well but @Honny1 already added the same validate subnet function there containers/netavark@a85e493 so it can just be reused

Copy link
Copy Markdown
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

I know nothing about the problem space. LGTM just looking at the implementation without understanding the surrounding code, one question:

// IPv6Enabled to true if at least one subnet is ipv6.
func ValidateSubnets(network *types.Network, addGateway bool, usedNetworks []*net.IPNet) error {
for i := range network.Subnets {
for j := i + 1; j < len(network.Subnets); j++ {
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.

https://issues.redhat.com/browse/RHEL-98277?focusedId=27450128&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-27450128 suggests that duplicate subnets were previously documented as working, although perhaps only partially.

Do we need to preserve that?!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No, this just makes no sense to allow with this change anymore and with 6.0 with have enough room to just outright refuse it.

my testing it doesn't work at all when specifying a static ip via --network mv1:ip=... as the IPAM allocation logic is not designed to handle that.

I.e. it never really worked it was just something that happend to work. We never documented that and this comment was just me testing some things and should not be seen as encouragement of that possibility.

Fixes allocation logic to support containers with multiple static IPs
from different subnets, while preventing invalid subnet configurations.

Fixes: https://issues.redhat.com/browse/RHEL-98277

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
@Honny1 Honny1 force-pushed the multi-static-ip-subnet branch from 7524bc5 to ac26a49 Compare March 6, 2026 12:36
Copy link
Copy Markdown
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

@Luap99 Luap99 enabled auto-merge March 6, 2026 12:43
@Luap99 Luap99 merged commit d48bc74 into containers:main Mar 6, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to "common" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants