egress vm test: an agent_allow element passes one MAC to one address and port under reject
This commit is contained in:
parent
eab2dcb0a2
commit
5da6a7bbb8
1 changed files with 18 additions and 0 deletions
|
|
@ -1289,5 +1289,23 @@ pkgs.testers.runNixOSTest {
|
||||||
assert udp_status("203.0.113.77") == 0, "control: an exempt MAC's datagram is not refused"
|
assert udp_status("203.0.113.77") == 0, "control: an exempt MAC's datagram is not refused"
|
||||||
proxy.succeed(f"nft delete element inet hive_egress direct_mac '{{ {AGENT_MAC} }}'")
|
proxy.succeed(f"nft delete element inet hive_egress direct_mac '{{ {AGENT_MAC} }}'")
|
||||||
assert dial_status("203.0.113.2", 8443) == 1, "refused again"
|
assert dial_status("203.0.113.2", 8443) == 1, "refused again"
|
||||||
|
|
||||||
|
# `hive-priv egress-pin` fills `agent_allow` on a hive host; here the
|
||||||
|
# elements are added by hand, as for `direct_mac`.
|
||||||
|
with checked("reject mode: an agent_allow element passes that MAC to that address and port only, and is refused again once it leaves"):
|
||||||
|
proxy.succeed(f"nft add element inet hive_egress agent_allow '{{ {AGENT_MAC} . 203.0.113.2 . 8443 }}'")
|
||||||
|
assert dial_status("203.0.113.2", 8443) == 0, "the allowed address and port"
|
||||||
|
# Another address of the same host, on the same port, is not in the set.
|
||||||
|
assert dial_status("203.0.113.9", 8443) == 1, "another address, same port"
|
||||||
|
wait_reject_line(r"SRC=192\.168\.1\.3 DST=203\.0\.113\.9 .*PROTO=TCP .*DPT=8443 ")
|
||||||
|
# Only TCP to the port is let through.
|
||||||
|
status, out = agent.execute("ping -c1 -W3 203.0.113.2")
|
||||||
|
assert status != 0, f"ICMP to the allowed address is still refused: {out}"
|
||||||
|
assert udp_status("203.0.113.2") != 0, "a datagram to the allowed address and port number is refused"
|
||||||
|
# An element of another MAC allows nothing for this one.
|
||||||
|
proxy.succeed("nft add element inet hive_egress agent_allow '{ 02:00:00:00:00:99 . 203.0.113.9 . 8443 }'")
|
||||||
|
assert dial_status("203.0.113.9", 8443) == 1, "another MAC's element"
|
||||||
|
proxy.succeed(f"nft delete element inet hive_egress agent_allow '{{ {AGENT_MAC} . 203.0.113.2 . 8443 }}'")
|
||||||
|
assert dial_status("203.0.113.2", 8443) == 1, "refused again"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue