Watch
0
0
Fork
You've already forked hyperhive
0

egress: the forward chain accepts the flows the host publishes for the agents

On a host with the egress intercept on, the forward chain rejected an agent's traffic to the queue once the queue ran as a pod: the pod's hostPort rewrites the destination to the pod, and the packet then leaves the bridge for the cluster. The chain now accepts TCP that the host's NAT redirected whose original destination is the bridge's address at a published port, which the queue adds when it runs in the cluster. Everything else from the bridge to the cluster stays refused. The nats switch test runs with the intercept on.
This commit is contained in:
atlas 2026-11-23 18:40:04 +01:00 • committed by maia
commit 0d857b8ae1

View file

@ -2025,6 +2025,39 @@ let
&& has "-t raw -A nixos-fw-nats -p tcp --dport 4222 -m addrtype --dst-type LOCAL -j DROP" onCluster.networking.firewall.extraCommands
&& has "-t raw -F nixos-fw-nats" onCluster.networking.firewall.extraStopCommands;
}
{
# The host with the queue on it is the control: it publishes no port, and
# its chain has no rule of the kind.
name = "the egress forward chain accepts the flows the host publishes for the agents, from the bridge's address at the queue's port, and none on a host without the queue in the cluster";
ok =
let
rules =
c:
lib.filter (l: l != "") (
map lib.trim (
lib.splitString "\n" (
lib.last (
lib.splitString "chain forward" (
lib.head (lib.splitString "table bridge hive_egress {" c.services.hyperhive.network.egress.ruleset)
)
)
)
)
);
idx = c: pat: lib.lists.findFirstIndex (lib.hasInfix pat) 1000 (rules c);
br = onCluster.services.hyperhive.network.bridgeName;
published = ''iifname "${br}" oifname != "${br}" meta nfproto ipv4 meta l4proto tcp ct status dnat ct original ip daddr 10.42.0.1 ct original proto-dst { 4222 } accept'';
in
onCluster.services.hyperhive.deploy.hive-controller.egress.publishedPorts == [ 4222 ]
&& withNode.services.hyperhive.deploy.hive-controller.egress.publishedPorts == [ ]
&& lib.elem published (rules onCluster)
&& !(lib.any (lib.hasInfix "ct original") (rules withNode))
# After the named SSH connections and before the counter and the log:
# a published flow is neither counted nor logged.
&& idx onCluster "@agent_allow accept" < idx onCluster "ct original"
&& idx onCluster "ct original" < idx onCluster "counter"
&& idx onCluster "@direct_mac accept" < idx onCluster "ct original";
}
{
# The file names the runtime and the host units of every service and no
# state: nothing is copied. The units of the poller (timer and service)