Skip to content

feat: add allowICMP annotation for port-filter mode - #1

Closed
kvaps wants to merge 1 commit into
mattia-eleuteri:feat/port-filteringfrom
cozystack:feat/allow-icmp
Closed

kvaps wants to merge 1 commit into
mattia-eleuteri:feat/port-filteringfrom
cozystack:feat/allow-icmp

Conversation

@kvaps

@kvaps kvaps commented Apr 27, 2026

Copy link
Copy Markdown

Stacked on top of cozystack#11 to address review feedback: in port-filter mode the current PR drops all ICMP toward the backend pod IP, which breaks ping, PMTU discovery, and ICMP unreachable signalling. This adds an opt-in annotation to accept ICMP for services that need it.

Summary

  • New annotation networking.cozystack.io/allowICMP: "true" (default false). Only meaningful in port-filter mode (wholeIP: "false").
  • New nft set icmp_allowed_pods and a rule in port_filter placed between the ct established,related accept and the per-port drop: ip daddr @icmp_allowed_pods meta l4proto icmp accept.
  • New ProxyProcessor methods EnsureICMPAllow / DeleteICMPAllow / CleanupICMPAllow, mirroring the port-filter API shape.
  • Controller wiring consolidated into reconcilePortFilter / clearPortFilter helpers — fewer scattered if/else blocks for both port-filter and ICMP state.
  • Unit test for the new allowICMP predicate.
  • README documents the annotation and updates the Datapath section.

Why per-pod set, not per-rule

Same reason as filtered_pods/allowed_ports: the chain runs at priority filter (0), after ingress_dnat has rewritten daddr from LB IP to pod IP. Keying on pod IP keeps the chain rule count constant and the per-service state in nft sets, which is consistent with the rest of this PR's design.

Test plan

  • wholeIP: "false" + allowICMP: "true": ping VM works, port filter still in effect for TCP/UDP
  • wholeIP: "false" without allowICMP: ICMP dropped (current PR behavior preserved as default)
  • wholeIP: "true": passthrough, ICMP works (port_filter chain doesn't apply to non-filtered pods)
  • Toggle allowICMP true→false: pod removed from icmp_allowed_pods
  • Service deletion cleans up icmp_allowed_pods entry

Introduce networking.cozystack.io/allowICMP. When set to "true" on a
service in port-filter mode (wholeIP: "false"), ICMP traffic toward the
backend pod IP is accepted instead of being dropped by the per-port
filter. Without this opt-in, port-filter mode silently drops all ICMP,
which breaks ping, PMTU discovery (ICMP "fragmentation needed") and
ICMP unreachable signalling.

Implementation:
- New nft set icmp_allowed_pods (key: ipv4 pod IP).
- New rule in port_filter, between the ct established,related accept
  and the per-port drop: ip daddr @icmp_allowed_pods meta l4proto icmp
  accept.
- New ProxyProcessor methods EnsureICMPAllow / DeleteICMPAllow /
  CleanupICMPAllow, mirroring the port-filter API.
- Controller refactored to consolidate port-filter + ICMP-allow handling
  into reconcilePortFilter / clearPortFilter helpers.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Andrei Kvapil <[email protected]>
@kvaps

kvaps commented Apr 27, 2026

Copy link
Copy Markdown
Author

Retargeting to cozystack:main now that cozystack#11 has merged. Continuing in cozystack/cozy-proxy.

@kvaps kvaps closed this Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant