Skip to content

Conversation

@robmry
Copy link
Contributor

@robmry robmry commented Oct 11, 2024

- What I did

Only add a single rule to the iptables filter-FORWARD chain for each bridge network in the common case (down from four rules per bridge in 27.x, down from two before this PR).

- How I did it

For a bridge network with default configuration (gateway mode nat, and inter-container communication enabled), we created two rules in the filter-FORWARD chain:

  ACCEPT -i <bridge> -o <bridge>   // icc=true
  ACCEPT -i <bridge> ! -o <bridge> // outgoing

This PR combines those:

  ACCEPT -i <bridge>  // icc=true and outgoing

For ICC=false, continue to do:

  DROP -i <bridge> -o <bridge>
  ACCEPT -i <bridge> ! -o <bridge>

- How to verify it

No functional change - so, existing tests. The updated markdown generated by an integration test shows the effect.

- Description for the changelog

n/a

@robmry robmry added kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. area/networking Networking area/networking/firewalling Networking area/networking/d/bridge Networking labels Oct 11, 2024
@robmry robmry added this to the 28.0.0 milestone Oct 11, 2024
@robmry robmry self-assigned this Oct 11, 2024
@robmry robmry force-pushed the iptables-combine-outgoing-and-icc-rules branch 3 times, most recently from f9c3c8f to 6755020 Compare October 22, 2024 17:38
@robmry robmry force-pushed the iptables-combine-outgoing-and-icc-rules branch 11 times, most recently from 7f31c24 to 6e96e9e Compare October 25, 2024 16:52
@robmry robmry force-pushed the iptables-combine-outgoing-and-icc-rules branch 2 times, most recently from 5b463f8 to c4b3d08 Compare December 12, 2024 18:13
- Move variable declarations closer to where they're used.
- Put comments in the blocks they apply to.

Signed-off-by: Rob Murray <rob.murray@docker.com>
setupIPTablesInternal is/was called from setupIPTables to set
up some rules for a network ... "internal" behaviour of the
outer function.

Then commit 7b64b1c added support for "--internal" bridge
networks, calling setupInternalNetworkRules from setupIPTables
instead of setupIPTablesInternal.

So, setupIPTablesInternal is the function that deals with
everything except "--internal" networks ... rename it.

Signed-off-by: Rob Murray <rob.murray@docker.com>
Rather than:

  ACCEPT -i <bridge> -o <bridge>   // icc=true
  ACCEPT -i <bridge> ! -o <bridge> // outgoing

Do:

  ACCEPT -i <bridge>  // icc=true and outgoing

For ICC=false, continue to do:

  DROP -i <bridge> -o <bridge>
  ACCEPT -i <bridge> ! -o <bridge>

Signed-off-by: Rob Murray <rob.murray@docker.com>
@robmry robmry force-pushed the iptables-combine-outgoing-and-icc-rules branch from c4b3d08 to df3c78d Compare December 17, 2024 10:38
@robmry robmry marked this pull request as ready for review December 17, 2024 11:41
@robmry robmry requested a review from akerouanton December 17, 2024 11:41
@robmry robmry merged commit f237ba0 into moby:master Dec 17, 2024
143 checks passed
@robmry robmry deleted the iptables-combine-outgoing-and-icc-rules branch December 17, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/networking/d/bridge Networking area/networking/firewalling Networking area/networking Networking kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants