Add dst_ip and dst_port fields to tls_hello_event BPF struct and populate them in tc_capture.c. Update Go TLS event handler with new byte offsets (payload[2048]+src_ip(4)+dst_ip(4)+src_port(2)+dst_port(2)+payload_len(2)+ timestamp_ns(8) = 2070 bytes). Read dst_ip/dst_port from HTTP plain events and use them to populate L3L4 when SYN was not captured, ensuring dst_ip and dst_port are always available in ClickHouse for both TLS and HTTP sessions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
212 lines
4.7 KiB
Go
212 lines
4.7 KiB
Go
// Code generated by bpf2go; DO NOT EDIT.
|
|
//go:build 386 || amd64
|
|
|
|
package loader
|
|
|
|
import (
|
|
"bytes"
|
|
_ "embed"
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/cilium/ebpf"
|
|
)
|
|
|
|
type Ja4TcAcceptEvent struct {
|
|
PidTgid uint64
|
|
Fd uint32
|
|
SrcIp uint32
|
|
SrcPort uint16
|
|
TimestampNs uint64
|
|
}
|
|
|
|
type Ja4TcAcceptKey struct {
|
|
PidTgid uint64
|
|
Fd uint32
|
|
}
|
|
|
|
type Ja4TcHttpPlainEvent struct {
|
|
Payload [4096]uint8
|
|
SrcIp uint32
|
|
DstIp uint32
|
|
SrcPort uint16
|
|
DstPort uint16
|
|
PayloadLen uint16
|
|
TimestampNs uint64
|
|
}
|
|
|
|
type Ja4TcSslConnInfo struct {
|
|
Fd uint32
|
|
SrcIp uint32
|
|
SrcPort uint16
|
|
}
|
|
|
|
type Ja4TcSslDataEvent struct {
|
|
PidTgid uint64
|
|
Fd uint32
|
|
SrcIp uint32
|
|
SrcPort uint16
|
|
Data [4096]uint8
|
|
DataLen uint32
|
|
TimestampNs uint64
|
|
Direction uint8
|
|
}
|
|
|
|
type Ja4TcSslReadArgs struct {
|
|
SslPtr uint64
|
|
BufPtr uint64
|
|
Num uint32
|
|
}
|
|
|
|
type Ja4TcTlsHelloEvent struct {
|
|
Payload [2048]uint8
|
|
SrcIp uint32
|
|
DstIp uint32
|
|
SrcPort uint16
|
|
DstPort uint16
|
|
PayloadLen uint16
|
|
TimestampNs uint64
|
|
}
|
|
|
|
// LoadJa4Tc returns the embedded CollectionSpec for Ja4Tc.
|
|
func LoadJa4Tc() (*ebpf.CollectionSpec, error) {
|
|
reader := bytes.NewReader(_Ja4TcBytes)
|
|
spec, err := ebpf.LoadCollectionSpecFromReader(reader)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("can't load Ja4Tc: %w", err)
|
|
}
|
|
|
|
return spec, err
|
|
}
|
|
|
|
// LoadJa4TcObjects loads Ja4Tc and converts it into a struct.
|
|
//
|
|
// The following types are suitable as obj argument:
|
|
//
|
|
// *Ja4TcObjects
|
|
// *Ja4TcPrograms
|
|
// *Ja4TcMaps
|
|
//
|
|
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
|
|
func LoadJa4TcObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
|
|
spec, err := LoadJa4Tc()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return spec.LoadAndAssign(obj, opts)
|
|
}
|
|
|
|
// Ja4TcSpecs contains maps and programs before they are loaded into the kernel.
|
|
//
|
|
// It can be passed ebpf.CollectionSpec.Assign.
|
|
type Ja4TcSpecs struct {
|
|
Ja4TcProgramSpecs
|
|
Ja4TcMapSpecs
|
|
}
|
|
|
|
// Ja4TcSpecs contains programs before they are loaded into the kernel.
|
|
//
|
|
// It can be passed ebpf.CollectionSpec.Assign.
|
|
type Ja4TcProgramSpecs struct {
|
|
CaptureTc *ebpf.ProgramSpec `ebpf:"capture_tc"`
|
|
}
|
|
|
|
// Ja4TcMapSpecs contains maps before they are loaded into the kernel.
|
|
//
|
|
// It can be passed ebpf.CollectionSpec.Assign.
|
|
type Ja4TcMapSpecs struct {
|
|
HttpBuf *ebpf.MapSpec `ebpf:"__http_buf"`
|
|
SslBuf *ebpf.MapSpec `ebpf:"__ssl_buf"`
|
|
TlsBuf *ebpf.MapSpec `ebpf:"__tls_buf"`
|
|
AcceptMap *ebpf.MapSpec `ebpf:"accept_map"`
|
|
FdConnMap *ebpf.MapSpec `ebpf:"fd_conn_map"`
|
|
PbAccept *ebpf.MapSpec `ebpf:"pb_accept"`
|
|
PbHttpPlain *ebpf.MapSpec `ebpf:"pb_http_plain"`
|
|
PbSslData *ebpf.MapSpec `ebpf:"pb_ssl_data"`
|
|
PbTcpSyn *ebpf.MapSpec `ebpf:"pb_tcp_syn"`
|
|
PbTlsHello *ebpf.MapSpec `ebpf:"pb_tls_hello"`
|
|
SslArgsMap *ebpf.MapSpec `ebpf:"ssl_args_map"`
|
|
SslConnMap *ebpf.MapSpec `ebpf:"ssl_conn_map"`
|
|
TcStats *ebpf.MapSpec `ebpf:"tc_stats"`
|
|
}
|
|
|
|
// Ja4TcObjects contains all objects after they have been loaded into the kernel.
|
|
//
|
|
// It can be passed to LoadJa4TcObjects or ebpf.CollectionSpec.LoadAndAssign.
|
|
type Ja4TcObjects struct {
|
|
Ja4TcPrograms
|
|
Ja4TcMaps
|
|
}
|
|
|
|
func (o *Ja4TcObjects) Close() error {
|
|
return _Ja4TcClose(
|
|
&o.Ja4TcPrograms,
|
|
&o.Ja4TcMaps,
|
|
)
|
|
}
|
|
|
|
// Ja4TcMaps contains all maps after they have been loaded into the kernel.
|
|
//
|
|
// It can be passed to LoadJa4TcObjects or ebpf.CollectionSpec.LoadAndAssign.
|
|
type Ja4TcMaps struct {
|
|
HttpBuf *ebpf.Map `ebpf:"__http_buf"`
|
|
SslBuf *ebpf.Map `ebpf:"__ssl_buf"`
|
|
TlsBuf *ebpf.Map `ebpf:"__tls_buf"`
|
|
AcceptMap *ebpf.Map `ebpf:"accept_map"`
|
|
FdConnMap *ebpf.Map `ebpf:"fd_conn_map"`
|
|
PbAccept *ebpf.Map `ebpf:"pb_accept"`
|
|
PbHttpPlain *ebpf.Map `ebpf:"pb_http_plain"`
|
|
PbSslData *ebpf.Map `ebpf:"pb_ssl_data"`
|
|
PbTcpSyn *ebpf.Map `ebpf:"pb_tcp_syn"`
|
|
PbTlsHello *ebpf.Map `ebpf:"pb_tls_hello"`
|
|
SslArgsMap *ebpf.Map `ebpf:"ssl_args_map"`
|
|
SslConnMap *ebpf.Map `ebpf:"ssl_conn_map"`
|
|
TcStats *ebpf.Map `ebpf:"tc_stats"`
|
|
}
|
|
|
|
func (m *Ja4TcMaps) Close() error {
|
|
return _Ja4TcClose(
|
|
m.HttpBuf,
|
|
m.SslBuf,
|
|
m.TlsBuf,
|
|
m.AcceptMap,
|
|
m.FdConnMap,
|
|
m.PbAccept,
|
|
m.PbHttpPlain,
|
|
m.PbSslData,
|
|
m.PbTcpSyn,
|
|
m.PbTlsHello,
|
|
m.SslArgsMap,
|
|
m.SslConnMap,
|
|
m.TcStats,
|
|
)
|
|
}
|
|
|
|
// Ja4TcPrograms contains all programs after they have been loaded into the kernel.
|
|
//
|
|
// It can be passed to LoadJa4TcObjects or ebpf.CollectionSpec.LoadAndAssign.
|
|
type Ja4TcPrograms struct {
|
|
CaptureTc *ebpf.Program `ebpf:"capture_tc"`
|
|
}
|
|
|
|
func (p *Ja4TcPrograms) Close() error {
|
|
return _Ja4TcClose(
|
|
p.CaptureTc,
|
|
)
|
|
}
|
|
|
|
func _Ja4TcClose(closers ...io.Closer) error {
|
|
for _, closer := range closers {
|
|
if err := closer.Close(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Do not access this directly.
|
|
//
|
|
//go:embed ja4tc_x86_bpfel.o
|
|
var _Ja4TcBytes []byte
|