-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Drop the use of ipset #49530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop the use of ipset #49530
Conversation
effdb11 to
6bfcbec
Compare
6bfcbec to
a6e157c
Compare
673e09a to
14c96a5
Compare
14c96a5 to
20751f1
Compare
akerouanton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| network that's made it through the DOCKER and isolation chains, whether the | ||
| destination is external or another network. | ||
|
|
||
| The DOCKER-CT chain is an early ACCEPT for any RELATED,ESTABLISHED traffic to a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reminds me that we're lacking a proper --ctstate INVALID -j DROP but IIRC it could cause issues for some Docker users (although I don't recall the exact details). That's probably something we should add in the next major. I can raise a PR if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, probably best not to try to tackle that for 28.0.1 and risk introducing new issues.
|
I guess after this one, we can also revert the changes in |
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code LGTM
(but I'm an iptables illiterate, so don't hold me to those parts)
| defer func() { | ||
| if retErr != nil { | ||
| if err := iptable.RemoveExistingChain(DockerBridgeChain, iptables.Filter); err != nil { | ||
| log.G(context.TODO()).Warnf("failed on removing iptables FILTER chain %s on cleanup: %v", DockerBridgeChain, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a follow-up, we could use structured logs (at least WithError() for these. (and at some point see where we / if we can punch through contexts).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there are lots of log lines following the same pattern in that function, we could sort them all out separately. (Or, not, because hopefully we'll delete all the iptables code soon ... first though, it's being moved to a separate package, to make it possible to swap in nftables / firewalld backends - that's in-progress, so I'd rather not make lots of changes here that might get lost when I rebase.
We haven't plumbed in context for any of the bridge driver's initialisation code (or most/all of libnetwork's initialisation code). We could also do that separately.
|
|
||
| _, err = iptable.NewChain(DockerBridgeChain, iptables.Filter) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to create FILTER chain %s: %v", DockerBridgeChain, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing the underlying error would never be relevant to us, beyond reporting "something failed"? (looking at %v vs %w)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I don't think we'd want to look at the underlying error ... most of the errors in that function use %v, so we could swap them for %w in a follow up.
Commit 0546d90 introduced the use of ipset to reduce the number of rules that need to be processed per-packet, and make the code a bit simpler. But, docker's used on embedded kernels compiled without support for ipset, so the change is too disruptive. Replace the two ipset rules with a new chain that writes out the rule's actions long-hand. So .. This rule: -A FORWARD -m set --match-set docker-ext-bridges-v4 dst \ -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT Is transformed into a per-bridge rule in new chain DOCKER-CT: -A DOCKER-FORWARD -j DOCKER-CT -A DOCKER-CT -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -A DOCKER-CT -o bridge1 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT And: -A FORWARD -m set --match-set docker-ext-bridges-v4 dst -j DOCKER Is transformed into a per-bridge rule in new chain DOCKER-BRIDGE: -A DOCKER-FORWARD -j DOCKER-BRIDGE -A DOCKER-BRIDGE -o docker0 -j DOCKER -A DOCKER-BRIDGE -o bridge1 -j DOCKER Signed-off-by: Rob Murray <[email protected]>
20751f1 to
76417bf
Compare
|
Rebased, and reworded some text in the iptablesdoc template (@vvoland) ... |
Oh, yes - will do. |
vvoland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
- What I did
Commit 0546d90 introduced the use of ipset to reduce the number of rules that need to be processed per-packet, and make the code a bit simpler.
But, docker's used on embedded kernels compiled without support for ipset, so the change is too disruptive.
- How I did it
Replace the two ipset rules with a new chain that writes out the rule's actions long-hand. So ..
This rule:
Is transformed into a per-bridge rule in new chain DOCKER-CT:
And:
Is transformed into a per-bridge rule in new chain DOCKER-BRIDGE:
- How to verify it
The usual tests.
Ran 28.0.0 with some networks, stopped it and updated to this PR, checked that the ipset rules were removed.
- Human readable description for the release notes