policy: return ICMP "Destination unreachable" on ipv4 ingress policy denials#44184
policy: return ICMP "Destination unreachable" on ipv4 ingress policy denials#4418441ks wants to merge 2 commits intocilium:mainfrom
Conversation
eeeff75 to
212d3fd
Compare
|
👋 please rebase on-top of #44186 |
212d3fd to
39a2a7a
Compare
|
@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. |
39a2a7a to
412ff7c
Compare
qmonnet
left a comment
There was a problem hiding this comment.
I'm only reviewing for the doc update - the change looks good, thanks!
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>
412ff7c to
dcea67d
Compare
julianwiedmann
left a comment
There was a problem hiding this comment.
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.
| if (!IS_ERR(ret)) { | ||
| update_metrics(ctx_full_len(ctx), metric_dir, | ||
| __DROP_REASON(verdict)); | ||
| return ret; |
There was a problem hiding this comment.
Instead of an if-else construct, you could just fall through here.
There was a problem hiding this comment.
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>
f91cf23 to
5d0fb20
Compare
|
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. |
|
/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 |
There was a problem hiding this comment.
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:
- as
to-containeron the pod's TC hook (I believe this is what your tests currently exercise). Any returnedCTX_ACT_OKwould then result in the ICMP packet accidentally slipping into the original destination pod. - in
cil_lxc_policy(), when another BPF program callstail_call_policy()to push a packet straight to the destination. Not handling theCTX_ACT_OKwould 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 incil_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.
|
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! |
|
This pull request has been automatically marked as stale because it |
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