Skip to content

libnet/iptables: split ProgramChain and move to bridge driver#49107

Merged
akerouanton merged 2 commits intomoby:masterfrom
akerouanton:ipt-split-ProgramChain
Dec 17, 2024
Merged

libnet/iptables: split ProgramChain and move to bridge driver#49107
akerouanton merged 2 commits intomoby:masterfrom
akerouanton:ipt-split-ProgramChain

Conversation

@akerouanton
Copy link
Copy Markdown
Member

- What I did

The ProgramChain method was called exclusively by the bridge driver to insert totally unrelated ipt rules in two different table-chains.

Break down this method into two functions, and move them into the bridge pkg.

The new function addNATJumpRules inserts rules that aren't related to any specific network, and depends solely on the driver config. Call it during driver configuration instead of during network setup.

- How I did it

- How to verify it

Existing tests, and particularly iptablesdoc, should pass.

@akerouanton akerouanton self-assigned this Dec 16, 2024
@akerouanton akerouanton added status/2-code-review area/networking Networking kind/refactor PR's that refactor, or clean-up code area/networking/firewalling Networking labels Dec 16, 2024
@akerouanton akerouanton added this to the 28.0.0 milestone Dec 16, 2024
return fmt.Errorf("failed to create FILTER chain %s: %v", DockerChain, err)
}
defer func() {
if err != nil {
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 noticed this one; is this defer checking the wrong error? (should this be retErr ?)

If so, perhaps something we should fix separately before this one

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.

@akerouanton akerouanton force-pushed the ipt-split-ProgramChain branch 3 times, most recently from f81862b to e916376 Compare December 17, 2024 10:58
The `ProgramChain` method was called exclusively by the bridge driver
to insert totally unrelated ipt rules in two different table-chains.

Break down this method into two functions, and move them into the bridge
pkg.

The new function `addNATJumpRules` inserts rules that aren't related to
any specific network, and depends solely on the driver config. Call it
during driver configuration instead of during network setup.

Signed-off-by: Albin Kerouanton <[email protected]>
@akerouanton akerouanton force-pushed the ipt-split-ProgramChain branch from e916376 to 820dea0 Compare December 17, 2024 11:38
Copy link
Copy Markdown
Contributor

@robmry robmry left a comment

Choose a reason for hiding this comment

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

LGTM

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 akerouanton merged commit 0d53725 into moby:master Dec 17, 2024
@akerouanton akerouanton deleted the ipt-split-ProgramChain branch December 17, 2024 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/networking/firewalling Networking area/networking Networking kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants