diff --git a/tap/tlstapper/bpf/golang_uprobes.c b/tap/tlstapper/bpf/golang_uprobes.c index 8f784ec61..faa685955 100644 --- a/tap/tlstapper/bpf/golang_uprobes.c +++ b/tap/tlstapper/bpf/golang_uprobes.c @@ -45,7 +45,7 @@ static __always_inline int golang_crypto_tls_write_uprobe(struct pt_regs *ctx) { return 0; } - chunk->type = Golang_type; + chunk->type = golang_type; chunk->pid = pid; chunk->fd = s->fd; // ctx->rsi is common between golang_crypto_tls_write_uprobe and golang_crypto_tls_read_uprobe @@ -91,7 +91,7 @@ static __always_inline int golang_crypto_tls_read_uprobe(struct pt_regs *ctx) { return 0; } - chunk->type = Golang_type; + chunk->type = golang_type; chunk->pid = pid; // ctx->rsi is common between golang_crypto_tls_write_uprobe and golang_crypto_tls_read_uprobe chunk->flags = ctx->rsi; // go.itab.*net.TCPConn,net.Conn address diff --git a/tap/tlstapper/bpf/include/maps.h b/tap/tlstapper/bpf/include/maps.h index a04e9d922..366e2d7a6 100644 --- a/tap/tlstapper/bpf/include/maps.h +++ b/tap/tlstapper/bpf/include/maps.h @@ -21,9 +21,9 @@ Copyright (C) UP9 Inc. #define MAX_ENTRIES_LRU_HASH (1 << 14) // 16384 #define MAX_ENTRIES_RINGBUFF (1 << 24) // 16777216 -enum ChunkType { - OpenSSL_type=1, - Golang_type=2, +enum chunk_type { + openssl_type=1, + golang_type=2, }; // The same struct can be found in chunk.go @@ -38,7 +38,7 @@ struct tls_chunk { __u32 recorded; __u32 fd; __u32 flags; - enum ChunkType type; + enum chunk_type type; bool is_request; __u8 address[16]; __u8 data[CHUNK_SIZE]; // Must be N^2 diff --git a/tap/tlstapper/bpf/openssl_uprobes.c b/tap/tlstapper/bpf/openssl_uprobes.c index 2604ccc14..0fe820792 100644 --- a/tap/tlstapper/bpf/openssl_uprobes.c +++ b/tap/tlstapper/bpf/openssl_uprobes.c @@ -132,7 +132,7 @@ static __always_inline void output_ssl_chunk(struct pt_regs *ctx, struct ssl_inf return; } - chunk->type = OpenSSL_type; + chunk->type = openssl_type; chunk->flags = flags; chunk->pid = id >> 32; chunk->tgid = id; diff --git a/tap/tlstapper/tls_poller.go b/tap/tlstapper/tls_poller.go index f3cd75504..e0436a078 100644 --- a/tap/tlstapper/tls_poller.go +++ b/tap/tlstapper/tls_poller.go @@ -94,7 +94,7 @@ func (p *tlsPoller) pollSsllib(emitter api.Emitter, options *api.TrafficFilterin chunks := make(chan *tlsTapperTlsChunk) go p.pollChunksPerfBuffer(chunks) - go p.pollSysClose(p.sysCloses) + go p.pollSysClosesPerfBuffer(p.sysCloses) for { select { @@ -104,11 +104,11 @@ func (p *tlsPoller) pollSsllib(emitter api.Emitter, options *api.TrafficFilterin } switch chunk.Type { - case 1: - if err := p.handleOpenSslTlsChunk(chunk, p.extension, emitter, options, streamsMap); err != nil { + case tlsTapperChunkTypeOpensslType: + if err := p.handleOpensslTlsChunk(chunk, p.extension, emitter, options, streamsMap); err != nil { LogError(err) } - case 2: + case tlsTapperChunkTypeGolangType: if err := p.handleGolangTlsChunk(chunk, emitter, options, streamsMap); err != nil { LogError(err) } @@ -178,7 +178,7 @@ func (p *tlsPoller) handleGolangTlsChunk(chunk *tlsTapperTlsChunk, emitter api.E return nil } -func (p *tlsPoller) pollSysClose(rd *perf.Reader) { +func (p *tlsPoller) pollSysClosesPerfBuffer(rd *perf.Reader) { nativeEndian := p.getByteOrder() // tlsTapperSysClose is generated by bpf2go. var b tlsTapperSysClose @@ -248,7 +248,7 @@ func (p *tlsPoller) pollChunksPerfBuffer(chunks chan<- *tlsTapperTlsChunk) { } } -func (p *tlsPoller) handleOpenSslTlsChunk(chunk *tlsTapperTlsChunk, extension *api.Extension, emitter api.Emitter, +func (p *tlsPoller) handleOpensslTlsChunk(chunk *tlsTapperTlsChunk, extension *api.Extension, emitter api.Emitter, options *api.TrafficFilteringOptions, streamsMap api.TcpStreamMap) error { address, err := p.getSockfdAddressPair(chunk) diff --git a/tap/tlstapper/tls_tapper.go b/tap/tlstapper/tls_tapper.go index 405b63b6d..e29333c6b 100644 --- a/tap/tlstapper/tls_tapper.go +++ b/tap/tlstapper/tls_tapper.go @@ -12,7 +12,7 @@ import ( const GLOABL_TAP_PID = 0 -//go:generate go run github.com/cilium/ebpf/cmd/bpf2go@0d0727ef53e2f53b1731c73f4c61e0f58693083a -type tls_chunk -type sys_close tlsTapper bpf/tls_tapper.c -- -O2 -g -D__TARGET_ARCH_x86 +//go:generate go run github.com/cilium/ebpf/cmd/bpf2go@0d0727ef53e2f53b1731c73f4c61e0f58693083a -type chunk_type -type tls_chunk -type sys_close tlsTapper bpf/tls_tapper.c -- -O2 -g -D__TARGET_ARCH_x86 type TlsTapper struct { bpfObjects tlsTapperObjects diff --git a/tap/tlstapper/tlstapper_bpfeb.go b/tap/tlstapper/tlstapper_bpfeb.go index 4d85757df..8c5d724b7 100644 --- a/tap/tlstapper/tlstapper_bpfeb.go +++ b/tap/tlstapper/tlstapper_bpfeb.go @@ -13,6 +13,13 @@ import ( "github.com/cilium/ebpf" ) +type tlsTapperChunkType int32 + +const ( + tlsTapperChunkTypeOpensslType tlsTapperChunkType = 1 + tlsTapperChunkTypeGolangType tlsTapperChunkType = 2 +) + type tlsTapperSysClose struct{ Fd uint32 } type tlsTapperTlsChunk struct { @@ -23,7 +30,7 @@ type tlsTapperTlsChunk struct { Recorded uint32 Fd uint32 Flags uint32 - Type int32 + Type tlsTapperChunkType IsRequest bool Address [16]uint8 Data [4096]uint8 diff --git a/tap/tlstapper/tlstapper_bpfeb.o b/tap/tlstapper/tlstapper_bpfeb.o index 059d79f15..9b35383a7 100644 Binary files a/tap/tlstapper/tlstapper_bpfeb.o and b/tap/tlstapper/tlstapper_bpfeb.o differ diff --git a/tap/tlstapper/tlstapper_bpfel.go b/tap/tlstapper/tlstapper_bpfel.go index 970330c74..83d996c5f 100644 --- a/tap/tlstapper/tlstapper_bpfel.go +++ b/tap/tlstapper/tlstapper_bpfel.go @@ -13,6 +13,13 @@ import ( "github.com/cilium/ebpf" ) +type tlsTapperChunkType int32 + +const ( + tlsTapperChunkTypeOpensslType tlsTapperChunkType = 1 + tlsTapperChunkTypeGolangType tlsTapperChunkType = 2 +) + type tlsTapperSysClose struct{ Fd uint32 } type tlsTapperTlsChunk struct { @@ -23,7 +30,7 @@ type tlsTapperTlsChunk struct { Recorded uint32 Fd uint32 Flags uint32 - Type int32 + Type tlsTapperChunkType IsRequest bool Address [16]uint8 Data [4096]uint8 diff --git a/tap/tlstapper/tlstapper_bpfel.o b/tap/tlstapper/tlstapper_bpfel.o index f769c1d32..9c52ac46a 100644 Binary files a/tap/tlstapper/tlstapper_bpfel.o and b/tap/tlstapper/tlstapper_bpfel.o differ