Skip to content

bpf: allow L7LB TCP close packets on stale endpoint marks - #46508

Closed
thorn3r wants to merge 1 commit into
cilium:mainfrom
thorn3r:l7lb/connectionClose
Closed

bpf: allow L7LB TCP close packets on stale endpoint marks#46508
thorn3r wants to merge 1 commit into
cilium:mainfrom
thorn3r:l7lb/connectionClose

Conversation

@thorn3r

@thorn3r thorn3r commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Envoy L7LB upstream sockets can outlive the source endpoint whose ID is stored in the proxy egress mark. Once that endpoint's policy program is removed, TCP close/control packets on the existing socket can miss the egress policy tail call and get dropped with DROP_EP_NOT_READY.

To allow Envoy to terminate connections to backends, allow only FIN/RST segments and payloadless ACKs if the egress policy has already been removed. SYNs and ACKs with payload will still be dropped.

Fixes: #41970

@thorn3r
thorn3r force-pushed the l7lb/connectionClose branch from 4c10047 to 11491b9 Compare June 11, 2026 20:09
@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 Jun 11, 2026
@thorn3r
thorn3r force-pushed the l7lb/connectionClose branch from 11491b9 to 7d5a7d3 Compare June 11, 2026 20:16
@thorn3r

thorn3r commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

/test

Envoy L7LB upstream sockets can outlive the source endpoint whose ID is
stored in the proxy egress mark. Once that endpoint's policy program is
removed, TCP close/control packets on the existing socket can miss the
egress policy tail call and get dropped with DROP_EP_NOT_READY.

To allow Envoy to terminate connections to backends, allow FIN/RST
segments and payloadless ACKs if the egress policy has already been
removed. SYNs and ACKs with payload will still be dropped.

Fixes: cilium#41970
Signed-off-by: Tim Horner <[email protected]>
@thorn3r
thorn3r force-pushed the l7lb/connectionClose branch from 7d5a7d3 to 0b2ccf8 Compare June 12, 2026 14:55
@thorn3r

thorn3r commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

/test

@thorn3r
thorn3r marked this pull request as ready for review June 12, 2026 18:24
@thorn3r
thorn3r requested a review from a team as a code owner June 12, 2026 18:24
@thorn3r
thorn3r requested a review from jrife June 12, 2026 18:24
@asauber asauber added the release-note/bug This PR fixes an issue in a previous release of Cilium. label Jun 26, 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 Jun 26, 2026
@asauber

asauber commented Jun 26, 2026

Copy link
Copy Markdown
Member

@jrife gentle ping for review

@jrife

jrife commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

oops, missed this. I'll take a look soon.

@jrife

jrife commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

The scenario described and fix makes sense overall. Have you done any work to repro #41970 to make sure that this fixes it?

@thorn3r

thorn3r commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@jrife yes locally in kind. I created a gist with the details here.
Apply the sample workload, then run the repro script and the hubble-observe 1-liner in separate terminals to monitor for drops. The script creates a bunch of short-lived clients to seed stale endpoints, then restarts the backends while a long-lived client continues to send GAMMA traffic.

Here's the results from the most recent run

On main:

gamma_requests_total=320
drop_ep_not_ready_total=2655

On this branch:

gamma_requests_total=318
drop_ep_not_ready_total=0

@maintainer-s-little-helper maintainer-s-little-helper Bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jul 2, 2026
@julianwiedmann julianwiedmann added the dont-merge/waiting-for-review Requires further review before merging. label Jul 6, 2026
@julianwiedmann
julianwiedmann self-requested a review July 6, 2026 06:27
@julianwiedmann julianwiedmann added area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. area/proxy Impacts proxy components, including DNS, Kafka, Envoy and/or XDS servers. area/loadbalancing Impacts load-balancing and Kubernetes service implementations labels Jul 6, 2026

@julianwiedmann julianwiedmann left a comment

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.

Besides the issue noted below - this is a lot of additional detail, in an already complex code path. Are we sure that the problem is severe enough to justify this additional complexity?

Comment thread bpf/bpf_lxc.c
Comment on lines -2653 to 2655
ret = tail_call_egress_policy(ctx, lxc_id);
ret = l7lb_tail_call_egress_policy(ctx, lxc_id, proto);
if (ret == CTX_ACT_OK)
return ret;
return send_drop_notify(ctx, lxc_id, sec_label, LXC_ID,
ret, METRIC_INGRESS);

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.

This now skips all ingress processing for the destination endpoint, no? I think that's not ok.

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.

Ah is this because we are now returning from cil_to_container if this is an "accetpable" tail call miss? Could we continue only on CTX_ACT_OK instead?

		ret = l7lb_tail_call_egress_policy(ctx, lxc_id, proto);
		if (ret != CTX_ACT_OK)
			return send_drop_notify(ctx, lxc_id, sec_label, LXC_ID,
						ret, METRIC_INGRESS);

@julianwiedmann julianwiedmann removed the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jul 6, 2026
@thorn3r

thorn3r commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@julianwiedmann That's a good question. The problem seems rather benign, since nothing is functionally broken here. I think this is more of a "nice-to-have" improvement for signal:noise, not triggering a drop for an expected behavior. There's a few others that have +1 on the issue, but i'm not sure they are actually a direct match to the report.

I'll defer to your opinion on this one. If this is adding a lot of overhead it might be better suited as a caveat in documentation

@thorn3r
thorn3r requested a review from julianwiedmann July 10, 2026 16:06
@julianwiedmann

Copy link
Copy Markdown
Member

@julianwiedmann That's a good question. The problem seems rather benign, since nothing is functionally broken here. I think this is more of a "nice-to-have" improvement for signal:noise, not triggering a drop for an expected behavior. There's a few others that have +1 on the issue, but i'm not sure they are actually a direct match to the report.

I'll defer to your opinion on this one. If this is adding a lot of overhead it might be better suited as a caveat in documentation

If this is purely a cosmetic improvement (suppressing drop notifications during client teardown), then I don't think it's worth the maintenance & complexity overhead. This code path is complicated enough, no need to add one more variable to it.

@thorn3r thorn3r closed this Jul 29, 2026
@thorn3r

thorn3r commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Closed in favor of documenting this behavior: #47587

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. area/loadbalancing Impacts load-balancing and Kubernetes service implementations area/proxy Impacts proxy components, including DNS, Kafka, Envoy and/or XDS servers. dont-merge/waiting-for-review Requires further review before merging. release-note/bug This PR fixes an issue in a previous release of Cilium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Random flows DROPPED targetting service using GAMMA HTTPRoutes

5 participants