Don't leak sysctl.d drop-ins for internal networks #1498
this should just be added to an existing internal test
This is mixing way to many things at once, this needs to be split in proper commits with proper reasons why they are needed. Staring with the bug at hand of the wrong internal condition.
I am also not convinced we need the "atomic" write behavior, our writes are small enough. And enabling forwarding on that one bridge should not be needed as we already enable the default forwarding.
Fair point! I've split it up into multiple commits. I still think the atomic write is necessary (see my reasoning in the commit message). I removed emitting the forwarding = 1 setting for non-internal networks altogether, since it shouldn't be necessary as long as everything else operates as it should. (It would be kind of nice from a symmetry perspective, though, so maybe consider it. ;-))
Unit tests are green, Hoping the github tests will be too once they have finished running. 🤞
I did fat-finger the issue # in one commit message, though. :-(
Will force-push a revised commit message.
Done
Is this functionally different from what's already there? It does swap the order of the comparisons, but it could easily still do the two checks on a single line?
yes see the second complete_teardown branch inside which is needed to remove the sysctl file
This needs a rebase, logic wise seem fine now for me
To elaborate on Paul's point: the !self.info.network.internal condition used to guard the entire block, now it's only guarding the teardown_firewall part. The sysctl.d drop-in deletion now happens regardless of the network being internal or not.
Rebased. Checks currently in progress.
LGTM
I rebased once more. If you don't have any more change requests, would you mind merging this?
@Luap99 PTAL
Rebased once again. I know you guys are busy, so if there is anything I can do to help you with this PR, let me know!
I agree with @Luap99 that atomic isnt needed, the file is written before the bridge exists so a plain fs::write should be enough.
This passes on main too. Netavark sets ip_forward = 1, which forces podman0/forwarding to 1 regardless of the stale file. Only the file-content assert tests the fix, so I'd drop these lines.
If this write fails, the stale file stays, I feel like we should keep the error and use a log::warn!?
LGTM logic wise just some thoughts
I think you could use with_added_extension instead of these 3 lines.
Looks like the bug has been fixed in 5d969595efeaf20b30ddaa135f43bbc7c95d3a19.
What remains of this changeset (after rebase) is
1. overwriting an existing sysctl.d file,
2. the atomic write,
3. a bats test.
1\. was only needed for hosts to recover without a reboot (nice to have), 2. is apparently not necessary (judging from the comments on this PR), 3. is only nice to have (I didn't check if an equivalent test has already been added in the meantime).
Thus, I conclude this PR is no longer needed, and #1497 is already fixed.
I'll close this PR.
Luap99
hcebke
Fixes: #1497
These changed were generated by Claude Opus and then reviewed, edited, and tested by me.