Skip to content

libnetwork: fan out firewall reload top-down#46666

Draft
corhere wants to merge 2 commits intomoby:masterfrom
corhere:libn/firewalld-reload-top-down-fan-out
Draft

libnetwork: fan out firewall reload top-down#46666
corhere wants to merge 2 commits intomoby:masterfrom
corhere:libn/firewalld-reload-top-down-fan-out

Conversation

@corhere
Copy link
Contributor

@corhere corhere commented Oct 17, 2023

The pattern of having low-level code that sets up iptables rules register reload callbacks for itself is not ideal. Callbacks can not be unregistered, so any values captured by the closures can never be GC'ed. And the callback registry is a singleton. While these issues could be overcome by iterating on the API, there are some other insurmountable issues which cannot be overcome without a complete overhaul of how the firewall reload logic is plumbed through. Imperative callback registration makes the control flow hard to reason about and the order of callbacks is implied by the order they were registered.

- What I did
Make the libnetwork Controller ultimately responsible for replaying firewall configuration when the firewall rulesets have been flushed externally. It fans out the reload signal to the drivers, which in turn fan out to the individual networks.

- How I did it
Made (*Controller).handleFirewallReload the only registered iptables.OnReloaded callback. It handles replaying firewall configuration for the controller, then calls into all the drivers which implement FirewallReplayer to handle replaying their own firewall configuration.

- How to verify it
TODO - UNVERIFIED

- Description for the changelog

N/A

- A picture of a cute animal (not mandatory but encouraged)

@corhere corhere requested review from akerouanton and thaJeztah and removed request for thaJeztah October 17, 2023 20:35
@corhere corhere added status/1-design-review area/networking Networking kind/refactor PR's that refactor, or clean-up code area/networking/firewalld Networking labels Oct 17, 2023
Make one global variable go away.

Signed-off-by: Cory Snider <csnider@mirantis.com>
The pattern of having low-level code that sets up iptables rules
register reload callbacks for itself is not ideal. Callbacks can not be
unregistered, so any values captured by the closures can never be GC'ed.
And the callback registry is a singleton. While these issues could be
overcome by iterating on the API, there are some other insurmountable
issues which cannot be overcome without a complete overhaul of how the
firewall reload logic is plumbed through. Imperative callback
registration makes the control flow hard to reason about and the order
of callbacks is implied by the order they were registered.

Make the libnetwork Controller ultimately responsible for replaying
firewall configuration when the firewall rulesets have been flushed
externally. It fans out the reload signal to the drivers, which in turn
fan out to the individual networks.

Signed-off-by: Cory Snider <csnider@mirantis.com>
@corhere corhere force-pushed the libn/firewalld-reload-top-down-fan-out branch from d8d0cea to 221d1ab Compare October 18, 2023 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/networking/firewalld Networking area/networking Networking kind/refactor PR's that refactor, or clean-up code status/1-design-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant