headscale/hscontrol/policy/v2
Kristoffer Dalby ccd284c0a5 policy/v2: use per-node filter compilation for via grants
Via grants compile filter rules that depend on the node's route state
(SubnetRoutes, ExitRoutes). Without per-node compilation, these rules
were only included in the global filter path which explicitly skips via
grants (compileFilterRules skips grants with non-empty Via fields).

Add a needsPerNodeFilter flag that is true when the policy uses either
autogroup:self or via grants. filterForNodeLocked now uses this flag
instead of usesAutogroupSelf alone, ensuring via grant rules are
compiled per-node through compileFilterRulesForNode/compileViaGrant.

The filter cache also needs to account for route-dependent compilation:

- nodesHavePolicyAffectingChanges now treats route changes as
  policy-affecting when needsPerNodeFilter is true, so SetNodes
  triggers updateLocked and clears caches through the normal flow.

- invalidateGlobalPolicyCache now clears compiledFilterRulesMap
  (the unreduced per-node cache) alongside filterRulesMap when
  needsPerNodeFilter is true and routes changed.

Updates #2180
2026-04-01 14:10:42 +01:00
..
testdata policy/v2: add advertised routes to compat test topologies 2026-04-01 14:10:42 +01:00
filter.go policy/v2: fix grant-only policies returning FilterAllowAll 2026-04-01 14:10:42 +01:00
filter_test.go policy/v2: add unit tests for grant filter compilation helpers 2026-04-01 14:10:42 +01:00
main_test.go all: fix test flakiness and improve test infrastructure 2026-03-14 02:52:28 -07:00
policy.go policy/v2: use per-node filter compilation for via grants 2026-04-01 14:10:42 +01:00
policy_test.go state,servertest: add grant control plane tests and fix via route ReduceRoutes filtering 2026-04-01 14:10:42 +01:00
tailscale_acl_data_compat_test.go policy/v2: implement CapGrant compilation with companion capabilities 2026-04-01 14:10:42 +01:00
tailscale_grants_compat_test.go policy/v2: implement autogroup:danger-all support 2026-04-01 14:10:42 +01:00
tailscale_routes_data_compat_test.go policy/v2: convert routes compat tests to data-driven format with Tailscale SaaS captures 2026-04-01 14:10:42 +01:00
tailscale_ssh_data_compat_test.go policy/v2: add SSH compatibility testdata from Tailscale SaaS 2026-02-28 05:14:11 -08:00
types.go policy/v2: use per-node filter compilation for via grants 2026-04-01 14:10:42 +01:00
types_test.go policy/v2: implement autogroup:danger-all support 2026-04-01 14:10:42 +01:00
utils.go policy/v2: exclude exit routes from ReduceFilterRules 2026-04-01 14:10:42 +01:00
utils_test.go policy/v2: exclude exit routes from ReduceFilterRules 2026-04-01 14:10:42 +01:00