Repository navigation
fix(ebpf): flag events lost to a failed copy, and mark TLS on the tracked connection - #367
Merged
Merged
Conversation
…cked connection Two gaps left after the lost-event flag (from review of #365): - An event dropped because bpf_probe_read of the user buffer failed was dropped before send_event, so l7_lost was not set and the parser could not see the gap. COPY_PAYLOAD_RINGBUF now records the loss on the connection, on the written or read side by where it runs. - On a TLS write to an untracked connection, mark_tls ran on the stack copy before the code switched to the map entry. If another CPU had inserted that entry first (the TCP connect path does, with tls 0), it never got the mark and its socket-level ciphertext was not skipped. The mark is now applied again after the switch.
There was a problem hiding this comment.
Code Review
This pull request updates the COPY_PAYLOAD_RINGBUF macro in l7.c to record payload copy failures on the connection state, using new constants L7_LOST_WRITES and L7_LOST_READS instead of magic numbers. It also adds a call to mark_tls(conn) in trace_enter_write when a connection is retrieved from the active connections map. The review feedback points out that the macro parameter e is unused in COPY_PAYLOAD_RINGBUF and suggests removing it to clean up the macro definition and its call sites.
The programs are unchanged (same instruction counts); ebpf.go differs only in the BTF line info that carries the edited source lines.
RamanKharchee
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two gaps the review of #365 found in the lost-event handling:
bpf_probe_readof the user buffer failed was dropped beforesend_event, soconnection.l7_lostwasn't set and the HTTP/2 parser couldn't see the gap.COPY_PAYLOAD_RINGBUFnow records the loss on the connection: on the written side in the write path, on the read side in the read path.mark_tlsran on the stack copy before the code switched to the map entry. If another CPU had inserted that entry first (the TCP connect path does, withtls = 0), the entry never got the mark and its socket-level ciphertext wasn't skipped. The mark is now applied again after the switch.Engineering detail
sys_enter_sendmsgprocesses 207,751 instructions.l7_lostrace. The fix the review proposes is a u32 counter per direction, incremented with XADD. That growsstruct connectionpast 32 bytes, so it waits for dev numbers onevents_lostto show the race matters.Local e2e: built the agent from this branch and ran it in a local Docker VM (kernel 6.10). A Go net/http HTTP/2 client: every request decoded (1,637,696), 0 decode errors. Bulk downloads plus streaming over one server: every stream completed. The short-lived-process suite, including the OpenSSL clients that use the untracked-connection path, is at parity: 386 of 390 short-lived clients captured, Python 19/20, no data races. A failed user-buffer copy can't be provoked locally, so that path is covered by the verifier load and code review only.