Skip to content

Commit

Permalink
USM: add exported attach and detach functions for GoTLS (#25767)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yumasi authored May 21, 2024
1 parent 0106f7f commit 09b95e4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/network/usm/ebpf_gotls.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,26 @@ var (
ErrInternalDDogProcessRejected = errors.New("internal datadog process rejected")
)

// GoTLSAttachPID attaches Go TLS hooks on the binary of process with
// provided PID, if Go TLS is enabled.
func GoTLSAttachPID(pid pid) error {
if goTLSSpec.Instance == nil {
return errors.New("GoTLS is not enabled")
}

return goTLSSpec.Instance.(*goTLSProgram).AttachPID(pid)
}

// GoTLSDetachPID detaches Go TLS hooks on the binary of process with
// provided PID, if Go TLS is enabled.
func GoTLSDetachPID(pid pid) error {
if goTLSSpec.Instance == nil {
return errors.New("GoTLS is not enabled")
}

return goTLSSpec.Instance.(*goTLSProgram).DetachPID(pid)
}

// AttachPID attaches the provided PID to the eBPF program.
func (p *goTLSProgram) AttachPID(pid uint32) error {
if p.cfg.GoTLSExcludeSelf && pid == uint32(os.Getpid()) {
Expand Down

0 comments on commit 09b95e4

Please sign in to comment.