Skip to content

policy: return ICMP "Destination unreachable" on ipv4 ingress policy denials#44184

Draft
41ks wants to merge 2 commits intocilium:mainfrom
DataDog:alex.melhem/ingress-deny-icmp
Draft

policy: return ICMP "Destination unreachable" on ipv4 ingress policy denials#44184
41ks wants to merge 2 commits intocilium:mainfrom
DataDog:alex.melhem/ingress-deny-icmp

Conversation

@41ks
Copy link
Copy Markdown
Contributor

@41ks 41ks commented Feb 4, 2026

Description

This is mostly a copy of PR #42068 following the changes introduced in PR #43226. See #41859 for the full list of TODOs.

This PR adds the ICMP response functionality to ingress policy denials.
The functionality works for local and remote endpoints with/without tunneling and with/without eBPF Host Routing.

Testing

  • Created a new unit test
  • Performed integration tests: backported the PR to Cilium 1.18.6, then created a pod with an ingress policy denying all traffic. Then tried to reach this pod from multiple different places and confirmed ping was returning "Packet filtered":
# ping 10.130.112.4
 PING 10.130.112.4 (10.130.112.4) 56(84) bytes of data.
 From 10.130.112.4 icmp_seq=1 Packet filtered
 From 10.130.112.4 icmp_seq=2 Packet filtered
 [...]
  • Local pod from same node [legacy routing]
  • Pod from a different node in the same cluster [legacy routing]
  • Pod in a different cluster [legacy routing]
  • Local pod from same node [eBPF host routing]
  • Pod from a different node in the same cluster [eBPF host routing]
  • Pod in a different cluster [eBPF host routing]
policy: add option to return ICMP "Destination unreachable" on ipv4 ingress policy denials

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Feb 4, 2026
@github-actions github-actions bot added the kind/community-contribution This was a contribution made by a community member. label Feb 4, 2026
@41ks 41ks force-pushed the alex.melhem/ingress-deny-icmp branch from eeeff75 to 212d3fd Compare February 4, 2026 13:47
@41ks 41ks marked this pull request as ready for review February 4, 2026 14:18
@41ks 41ks requested review from a team as code owners February 4, 2026 14:18
@41ks 41ks requested review from fristonio, jrife and qmonnet February 4, 2026 14:18
@julianwiedmann
Copy link
Copy Markdown
Member

👋 please rebase on-top of #44186

@julianwiedmann julianwiedmann self-requested a review February 5, 2026 08:04
@41ks 41ks force-pushed the alex.melhem/ingress-deny-icmp branch from 212d3fd to 39a2a7a Compare February 5, 2026 09:38
@ldelossa
Copy link
Copy Markdown
Contributor

ldelossa commented Feb 5, 2026

@41ks it appears the initial container build on CI failed. This doesn't seem to be an issue with this PR. however, the simplest thing to re-kick all the failed tests if so perform an amend and a force push.

@41ks 41ks force-pushed the alex.melhem/ingress-deny-icmp branch from 39a2a7a to 412ff7c Compare February 5, 2026 16:47
Copy link
Copy Markdown
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm only reviewing for the doc update - the change looks good, thanks!

@qmonnet qmonnet added release-note/minor This PR changes functionality that users may find relevant to operating Cilium. sig/policy Impacts whether traffic is allowed or denied based on user-defined policies. labels Feb 6, 2026
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Feb 6, 2026
@qmonnet qmonnet added the area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. label Feb 6, 2026
This expands the functionality enabled by --policy-deny-response=icmp from egress-only to
egress and ingress. Now ICMP responses can be sent for ingress policy denials as well.

Signed-off-by: Alex Melhem <alex.melhem@datadoghq.com>
@41ks 41ks force-pushed the alex.melhem/ingress-deny-icmp branch from 412ff7c to dcea67d Compare February 9, 2026 09:23
Copy link
Copy Markdown
Member

@julianwiedmann julianwiedmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for tackling this! I see that the change currently only has your sign-off - please check with @antonipp how you can accurately attribute his contributions.

I left some initial comments inline. Once we have more test coverage, it's easier to evaluate the proposed change.

Comment on lines +2615 to +2618
if (!IS_ERR(ret)) {
update_metrics(ctx_full_len(ctx), metric_dir,
__DROP_REASON(verdict));
return ret;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of an if-else construct, you could just fall through here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if the new implementation looks better

This applies PR suggestions and refactors icmp deny response test suit to add more test cases for the ingress path.

Signed-off-by: Alex Melhem <alex.melhem@datadoghq.com>
@41ks 41ks force-pushed the alex.melhem/ingress-deny-icmp branch from f91cf23 to 5d0fb20 Compare February 10, 2026 13:31
@41ks
Copy link
Copy Markdown
Contributor Author

41ks commented Feb 10, 2026

Hey @julianwiedmann I applied your suggestions in the second commit. I also revamped the test suite to make it more complete. Let me know what you think and if I have correctly applied your suggestions.

@pchaigno
Copy link
Copy Markdown
Member

/test


if (ret == CTX_ACT_OK) {
#if !defined(ENABLE_HOST_ROUTING) && !defined(ENABLE_ROUTING)
/* If the shared helper returned CTX_ACT_OK (pass to stack) but
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can imagine, this is the really tricky part. I don't think it's robust to assume that we have one specific scenario (!defined(ENABLE_HOST_ROUTING) && !defined(ENABLE_ROUTING)) that we should special-case - we always need to be ready to handle a CTX_ACT_OK.

And it's gets more interesting - the pod ingress path can be entered in two ways:

  1. as to-container on the pod's TC hook (I believe this is what your tests currently exercise). Any returned CTX_ACT_OK would then result in the ICMP packet accidentally slipping into the original destination pod.
  2. in cil_lxc_policy(), when another BPF program calls tail_call_policy() to push a packet straight to the destination. Not handling the CTX_ACT_OK would mean that the ICMP packet then continues in the initial program's context. We need to be careful here, I think we might need to bring some of the epilogue logic in cil_lxc_policy() over into our new tailcall program.

In the end CTX_ACT_OK should always mean "send to host stack". Maybe we just need to be explicit about that, and redirect the packet to the cilium_host veth pair ... ?

We should also think about tests for (2.). There's prior art for how to correctly enter this path, if you look for local_delivery_fill_meta() in bpf/tests.

@jrife jrife removed their request for review February 16, 2026 21:45
@joestringer joestringer marked this pull request as draft March 4, 2026 16:41
@joestringer
Copy link
Copy Markdown
Member

I've marked this PR as draft. When you have addressed the comments and workflow test results, bring the PR back to the attention of reviewers by scrolling to the bottom of the page and clicking the "Ready for Review" button. Thanks!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

This pull request has been automatically marked as stale because it
has not had recent activity. It will be closed if no further activity
occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. label Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. kind/community-contribution This was a contribution made by a community member. release-note/minor This PR changes functionality that users may find relevant to operating Cilium. sig/policy Impacts whether traffic is allowed or denied based on user-defined policies. stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants