Skip to content

feat(gotls): add fd extraction from tls.Conn for connection tuple sup…#947

Merged
cfc4n merged 1 commit into
gojue:masterfrom
skylar2826:feature/gotls2
Mar 16, 2026
Merged

feat(gotls): add fd extraction from tls.Conn for connection tuple sup…#947
cfc4n merged 1 commit into
gojue:masterfrom
skylar2826:feature/gotls2

Conversation

@skylar2826
Copy link
Copy Markdown
Contributor

@skylar2826 skylar2826 commented Mar 11, 2026

…port

Add pad[3]+fd to go_tls_event struct and extract_fd_from_tls_conn() in BPF to walk tls.Conn->netFD->Sysfd. Align Go-side inner struct, add Tuple/Sock to GoTLSEvent, and parse real IP:port in Base() replacing the hardcoded 127.0.0.1.

bpftool prog tracelog:
image

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Mar 11, 2026
@skylar2826
Copy link
Copy Markdown
Contributor Author

skylar2826 commented Mar 11, 2026

我的梳理&测试:[ecapture]go1.20 tls fd抽取

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances GoTLS plaintext capture events by extracting the underlying socket FD from *tls.Conn in the eBPF probe, extending the Go/C event struct layouts to carry that FD, and attempting to populate source/destination tuple information on the Go side.

Changes:

  • Extend go_tls_event (BPF) / inner (Go) with explicit padding + fd to keep struct layouts aligned.
  • Add eBPF logic to walk tls.Conn -> net.Conn -> netFD -> poll.FD.Sysfd and emit the extracted FD.
  • Add Tuple/Sock fields to GoTLSEvent, update UUID composition, and parse tuple into Base().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
user/event/event_gotls.go Adds fd + tuple/sock fields, updates UUID, and parses tuple into Base() fields.
kern/gotls_kern.c Adds fd to the perf event struct and introduces BPF-side FD extraction from tls.Conn.
Comments suppressed due to low confidence (1)

user/event/event_gotls.go:74

  • These comments say GoTLS events do not have Src/Dst IP/port, but this function now derives them from ge.Tuple. Please update the comments to avoid misleading readers (and to reflect when/if Tuple is expected to be populated).
		SrcIP:     "127.0.0.1", // GoTLS events do not have SrcIP
		SrcPort:   0,           // GoTLS events do not have SrcPort
		DstIP:     "127.0.0.1", // GoTLS events do not have DstIP
		DstPort:   0,           // GoTLS events do not have DstPort

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread user/event/event_gotls.go Outdated
Comment thread kern/gotls_kern.c
Comment thread kern/gotls_kern.c Outdated
Comment thread kern/gotls_kern.c Outdated
Comment thread user/event/event_gotls.go Outdated
@skylar2826 skylar2826 force-pushed the feature/gotls2 branch 6 times, most recently from a9ffc0f to 632c1db Compare March 12, 2026 03:14
Comment thread kern/gotls_kern.c Outdated
@skylar2826 skylar2826 force-pushed the feature/gotls2 branch 2 times, most recently from 88b116d to e3e0ce3 Compare March 16, 2026 02:47
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Mar 16, 2026
…port

Add pad[3]+fd to go_tls_event struct and extract_fd_from_tls_conn() in BPF to walk tls.Conn->netFD->Sysfd. Align Go-side inner struct, add Tuple/Sock to GoTLSEvent, and parse real IP:port in Base() replacing the hardcoded 127.0.0.1.
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 16, 2026
@skylar2826
Copy link
Copy Markdown
Contributor Author

skylar2826 commented Mar 16, 2026

image image

这个失败的测试不是我的代码导致的

Copy link
Copy Markdown
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Mar 16, 2026
@cfc4n cfc4n merged commit 5b7e8f4 into gojue:master Mar 16, 2026
11 of 12 checks passed
Comment thread internal/probe/gotls/event.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants