Skip to content

Delta npds#1836

Draft
jrajahalme wants to merge 14 commits intomainfrom
delta-npds
Draft

Delta npds#1836
jrajahalme wants to merge 14 commits intomainfrom
delta-npds

Conversation

@jrajahalme
Copy link
Copy Markdown
Member

No description provided.

@jrajahalme jrajahalme requested a review from a team as a code owner April 6, 2026 18:42
@jrajahalme jrajahalme added the preview-only Preview only label Apr 6, 2026
@jrajahalme jrajahalme requested a review from sayboras April 6, 2026 18:42
@jrajahalme jrajahalme marked this pull request as draft April 6, 2026 18:42
@jrajahalme jrajahalme requested review from fristonio and nezdolik and removed request for sayboras April 6, 2026 18:42
Comment thread cilium/api/bpf_metadata.proto Outdated
@jrajahalme jrajahalme force-pushed the delta-npds branch 2 times, most recently from 2a2e1ff to 030c9e4 Compare April 16, 2026 15:25
Signed-off-by: Jarno Rajahalme <[email protected]>
Keep the new map in the stack so that it is not leaked on exception.
Move-construct to the heap when exchanging for the old map.

Signed-off-by: Jarno Rajahalme <[email protected]>
Refactor policy code in preparation for delta NPDS changes in later
commits:

- Remove unnecessary PortPolicy.map_ member.
- Move NetworkPolicyMapImpl to cilium/network_policy.cc to hide
  implementation detail.
- Add helpers for policy updates to be shared with the delta code later.
- Pass Context to secret watcher functions instead of the full
  NetworkPolicyMap.
- Simplify gRPC subscribe() parameters.

Signed-off-by: Jarno Rajahalme <[email protected]>
Leave enough space after the pass verdict for all the passed rules to fit
in before the following rules on the same tier. This is the requirement
of the current API for correct behavior.

Signed-off-by: Jarno Rajahalme <[email protected]>
Handle pass rules during enforcement by skipping past the passed-over
rules when a rule with a pass verdict matches. This is more
straightforward and gets rid of precedence promotioin altogether, which
is made possible by the duplication of wildcard-port rules into the
port-specific rulesets, as after that change there is no need to compare
precedences between multiple lookups. Since there is no transformation on
the rules, the applied rules have the same shape as the imported policy,
which makes debugging easier. The implementation skips over the
passed-over rules without scanning all of them so the performance should
be similar to the previous implementation.

Signed-off-by: Jarno Rajahalme <[email protected]>
Add new cilium/versioned.h generic container for transactional selector updates.

Add a new NetworkPolicyResourceDiscoveryService that implements delta
updates for policies and selectors, and where policies refer to selectors
by their resource name.

NPRDS adds a top-level oneof wrapper that wraps either a Selector or a
NetworkPolicy. NetworkPolicy definition is shared with NPDS, but
PortNetworkPolicyRule adds a new selectors field that is only used with
NPRDS.

Signed-off-by: Jarno Rajahalme <[email protected]>
Store the latest desired NPDS mode in the policy map and use it for:
- initial policy map subscription
- re-subscription when connection under current subscription is terminated
- a healthy network policy stream is not disrupted

This should work for Cilium Agent upgrades and downgrades, as the agent
expresses the desired mode, and listens for both.

Signed-off-by: Jarno Rajahalme <[email protected]>
Clear the resource map on a first update on a new stream. This fixes NACK
cases where further updates on the stream would have IP collisions with
resources that were kept from the previous stream.

Signed-off-by: Jarno Rajahalme <[email protected]>
Do not use the default decoder as NPRDS does not carry a name inside the
NetworkPolicyResource type.

Signed-off-by: Jarno Rajahalme <[email protected]>
Stream generation accounting has to be shared between NPDS and NPRDS
streams, so that the handoff works as designed, but no other xDS
protocols (e.g., NPHDS) should interfere with the stream generation
accounting. Solve this by defining the stream generation number as a
static member of NetworkPolicyMapImpl and updating it from the already
established transport connected/closed callbacks.

Adjust tests to work with the new shape where the generation numbers do
not start from 1 for each NetworkPolicyMapImpl instance, but increase
monotonically for each established NPDS/NPRDS stream.

Signed-off-by: Jarno Rajahalme <[email protected]>
Use NetworkPolicyResource and NetworkPolicy consistently for the two
typeURLs to make grepping logs more meaningful.

Signed-off-by: Jarno Rajahalme <[email protected]>
Switch to delta mode more eagerly when we have evidence that the agent is
capable, but switch to SotW mode only when xDS stream transport had
failed to connect or closes.

Signed-off-by: Jarno Rajahalme <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants