diff --git a/tap/tlstapper/bpf/include/maps.h b/tap/tlstapper/bpf/include/maps.h index f8c799d13..9168434ba 100644 --- a/tap/tlstapper/bpf/include/maps.h +++ b/tap/tlstapper/bpf/include/maps.h @@ -91,6 +91,7 @@ BPF_LRU_HASH(openssl_write_context, __u64, struct ssl_info); BPF_LRU_HASH(openssl_read_context, __u64, struct ssl_info); // Go specific +BPF_HASH(goid_offset, __u32, __u32); BPF_LRU_HASH(go_write_context, __u64, struct ssl_info); BPF_LRU_HASH(go_read_context, __u64, struct ssl_info); diff --git a/tap/tlstapper/go_hooks.go b/tap/tlstapper/go_hooks.go index 9a5af6669..424142540 100644 --- a/tap/tlstapper/go_hooks.go +++ b/tap/tlstapper/go_hooks.go @@ -87,6 +87,12 @@ func (s *goHooks) installHooks(bpfObjects *tlsTapperObjects, ex *link.Executable s.goReadExProbes = append(s.goReadExProbes, probe) } + // Pass goid offset to an eBPF map to retrieve it in eBPF context + goidOffsetMap := bpfObjects.tlsTapperMaps.GoidOffset + if err := goidOffsetMap.Put(0, offsets.GoidOffset); err != nil { + return errors.Wrap(err, 0) + } + return nil } diff --git a/tap/tlstapper/tlstapper_bpfel_x86.go b/tap/tlstapper/tlstapper_bpfel_x86.go index 941d0699e..00ffd8601 100644 --- a/tap/tlstapper/tlstapper_bpfel_x86.go +++ b/tap/tlstapper/tlstapper_bpfel_x86.go @@ -100,6 +100,7 @@ type tlsTapperMapSpecs struct { FileDescriptorToIpv4 *ebpf.MapSpec `ebpf:"file_descriptor_to_ipv4"` GoReadContext *ebpf.MapSpec `ebpf:"go_read_context"` GoWriteContext *ebpf.MapSpec `ebpf:"go_write_context"` + GoidOffset *ebpf.MapSpec `ebpf:"goid_offset"` Heap *ebpf.MapSpec `ebpf:"heap"` LogBuffer *ebpf.MapSpec `ebpf:"log_buffer"` OpensslReadContext *ebpf.MapSpec `ebpf:"openssl_read_context"` @@ -132,6 +133,7 @@ type tlsTapperMaps struct { FileDescriptorToIpv4 *ebpf.Map `ebpf:"file_descriptor_to_ipv4"` GoReadContext *ebpf.Map `ebpf:"go_read_context"` GoWriteContext *ebpf.Map `ebpf:"go_write_context"` + GoidOffset *ebpf.Map `ebpf:"goid_offset"` Heap *ebpf.Map `ebpf:"heap"` LogBuffer *ebpf.Map `ebpf:"log_buffer"` OpensslReadContext *ebpf.Map `ebpf:"openssl_read_context"` @@ -147,6 +149,7 @@ func (m *tlsTapperMaps) Close() error { m.FileDescriptorToIpv4, m.GoReadContext, m.GoWriteContext, + m.GoidOffset, m.Heap, m.LogBuffer, m.OpensslReadContext,