Skip to content

Conversation

@Luap99
Copy link
Member

@Luap99 Luap99 commented Mar 3, 2025

While we already did clean up the allocated ips on the regular setup error this did not worked for errors from the rootlessNetns.Setup() call. To ensure we dealloc the ips on all error paths use a defer function that checks the return error value.

Fixes containers/podman#25422

While we already did clean up the allocated ips on the regular setup
error this did not worked for errors from the rootlessNetns.Setup()
call. To ensure we dealloc the ips on all error paths use a defer
function that checks the return error value.

Fixes containers/podman#25422

Signed-off-by: Paul Holzinger <[email protected]>
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 3, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Mar 3, 2025
@mheon
Copy link
Member

mheon commented Mar 3, 2025

LGTM

Copy link
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.

LGTM going just by the structure of the one function, with zero understanding of libnetwork in general.

The question is almost certainly non-blocking, but I figured I’ll let the experts discuss.

return n.execNetavark([]string{"setup", namespacePath}, needPlugin, netavarkOpts, &result)
}

if n.rootlessNetns != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the len(result) != len(options.Networks) failure — deallocating the IP addresses without doing anything else might be wrong?

But, also, is there anything at all we can reliably do in such a situation?

Copy link
Member Author

Choose a reason for hiding this comment

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

The nice thing about kernel network namespaces is if you delete it it removes all virtual interfaces (i.e. veth/bridge, etc... from it). As such it is safe to assume once podman unmounts the netns path the ip is free to reuse.
(There would still be small race here I suppose until podman unmounts it)

Netavark is written in a way that it should tear down everything cleanly on any error it encounters to not leak interfaces/firewall rules. That of course will not apply to that exact condition because netavark itslef didn't return an error.
The check is more of a it cannot happen thing, if it does happen we made a major mistake in netavark and hopefully CI would notice way before any users do. So I don't think there is anything we can do and deallocating is fine

@baude
Copy link
Member

baude commented Mar 4, 2025

/hold
/lgtm

@baude
Copy link
Member

baude commented Mar 4, 2025

ive given a lgtm and hold ... that way @Luap99 can consider his response. I think the part about "is there anything we can do" is probably applicable if I understood things correctly. Ball is in your court @Luap99

@Luap99
Copy link
Member Author

Luap99 commented Mar 4, 2025

/hold cancel

@openshift-merge-bot openshift-merge-bot bot merged commit 7b93145 into containers:main Mar 4, 2025
16 checks passed
@Luap99 Luap99 deleted the nv-ip-leak branch March 4, 2025 20:13
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.

static ip address is already allocated, but that container is already deleted

4 participants