Skip to content

Commit

Permalink
tetragon: Rename unloader.PinUnloader to unloader.ProgUnloader
Browse files Browse the repository at this point in the history
It unloads program and it fits better next to the existing
LinkUnloader type.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Nov 7, 2024
1 parent f7bf402 commit 1d055c6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
26 changes: 13 additions & 13 deletions pkg/sensors/program/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func RawAttachWithFlags(targetFD int, flags uint32) AttachFunc {
return nil, fmt.Errorf("attaching '%s' failed: %w", spec.Name, err)
}
return unloader.ChainUnloader{
unloader.PinUnloader{
unloader.ProgUnloader{
Prog: prog,
},
&unloader.RawDetachUnloader{
Expand Down Expand Up @@ -103,7 +103,7 @@ func TracepointAttach(load *Program, bpfDir string) AttachFunc {
return nil, err
}
return &unloader.RelinkUnloader{
UnloadProg: unloader.PinUnloader{Prog: prog}.Unload,
UnloadProg: unloader.ProgUnloader{Prog: prog}.Unload,
IsLinked: true,
Link: tpLink,
RelinkFn: func() (link.Link, error) {
Expand Down Expand Up @@ -132,7 +132,7 @@ func RawTracepointAttach(load *Program) AttachFunc {
return nil, fmt.Errorf("attaching '%s' failed: %w", spec.Name, err)
}
return unloader.ChainUnloader{
unloader.PinUnloader{
unloader.ProgUnloader{
Prog: prog,
},
unloader.LinkUnloader{
Expand Down Expand Up @@ -193,7 +193,7 @@ func kprobeAttach(load *Program, prog *ebpf.Program, spec *ebpf.ProgramSpec,
}
load.Link = lnk
return &unloader.RelinkUnloader{
UnloadProg: unloader.PinUnloader{Prog: prog}.Unload,
UnloadProg: unloader.ProgUnloader{Prog: prog}.Unload,
IsLinked: true,
Link: lnk,
RelinkFn: linkFn,
Expand Down Expand Up @@ -274,7 +274,7 @@ func fmodretAttachOverride(load *Program, bpfDir string,
}

load.unloaderOverride = &unloader.RelinkUnloader{
UnloadProg: unloader.PinUnloader{Prog: prog}.Unload,
UnloadProg: unloader.ProgUnloader{Prog: prog}.Unload,
IsLinked: true,
Link: lnk,
RelinkFn: linkFn,
Expand Down Expand Up @@ -325,7 +325,7 @@ func UprobeAttach(load *Program) AttachFunc {
return nil, fmt.Errorf("attaching '%s' failed: %w", spec.Name, err)
}
return &unloader.RelinkUnloader{
UnloadProg: unloader.PinUnloader{Prog: prog}.Unload,
UnloadProg: unloader.ProgUnloader{Prog: prog}.Unload,
IsLinked: true,
Link: lnk,
RelinkFn: linkFn,
Expand Down Expand Up @@ -367,7 +367,7 @@ func MultiUprobeAttach(load *Program) AttachFunc {

return &unloader.MultiRelinkUnloader{
UnloadProg: unloader.ChainUnloader{
unloader.PinUnloader{
unloader.ProgUnloader{
Prog: prog,
},
}.Unload,
Expand All @@ -382,7 +382,7 @@ func NoAttach() AttachFunc {
return func(_ *ebpf.Collection, _ *ebpf.CollectionSpec,
prog *ebpf.Program, _ *ebpf.ProgramSpec) (unloader.Unloader, error) {
return unloader.ChainUnloader{
unloader.PinUnloader{
unloader.ProgUnloader{
Prog: prog,
},
}, nil
Expand All @@ -402,7 +402,7 @@ func TracingAttach() AttachFunc {
return nil, fmt.Errorf("attaching '%s' failed: %w", spec.Name, err)
}
return &unloader.RelinkUnloader{
UnloadProg: unloader.PinUnloader{Prog: prog}.Unload,
UnloadProg: unloader.ProgUnloader{Prog: prog}.Unload,
IsLinked: true,
Link: lnk,
RelinkFn: linkFn,
Expand Down Expand Up @@ -437,7 +437,7 @@ func LSMAttach() AttachFunc {
return nil, fmt.Errorf("attaching '%s' failed: %w", spec.Name, err)
}
return &unloader.RelinkUnloader{
UnloadProg: unloader.PinUnloader{Prog: prog}.Unload,
UnloadProg: unloader.ProgUnloader{Prog: prog}.Unload,
IsLinked: true,
Link: lnk,
RelinkFn: linkFn,
Expand Down Expand Up @@ -467,7 +467,7 @@ func multiKprobeAttach(load *Program, prog *ebpf.Program,
}
load.Link = lnk
return unloader.ChainUnloader{
unloader.PinUnloader{
unloader.ProgUnloader{
Prog: prog,
},
unloader.LinkUnloader{
Expand Down Expand Up @@ -553,7 +553,7 @@ func KprobeAttachMany(load *Program, syms []string, bpfDir string) AttachFunc {
prog *ebpf.Program, spec *ebpf.ProgramSpec) (unloader.Unloader, error) {

unloader := unloader.ChainUnloader{
unloader.PinUnloader{
unloader.ProgUnloader{
Prog: prog,
},
}
Expand Down Expand Up @@ -610,7 +610,7 @@ func LoadFmodRetProgram(bpfDir string, load *Program, progName string, verbose i
return nil, fmt.Errorf("attaching '%s' failed: %w", spec.Name, err)
}
return &unloader.RelinkUnloader{
UnloadProg: unloader.PinUnloader{Prog: prog}.Unload,
UnloadProg: unloader.ProgUnloader{Prog: prog}.Unload,
IsLinked: true,
Link: lnk,
RelinkFn: linkFn,
Expand Down
8 changes: 4 additions & 4 deletions pkg/sensors/unloader/unloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ func (cu ChainUnloader) Unload(unpin bool) error {
return nil
}

// PinUnloader unpins and closes a BPF program.
type PinUnloader struct {
// ProgUnloader unpins and closes a BPF program.
type ProgUnloader struct {
Prog *ebpf.Program
}

func (pu PinUnloader) Unload(unpin bool) error {
func (pu ProgUnloader) Unload(unpin bool) error {
defer pu.Prog.Close()
if unpin {
return pu.Prog.Unpin()
}
return nil
}

// PinUnloader unpins and closes a BPF program.
// ProgUnloader unpins and closes a BPF program.
type LinkUnloader struct {
Link link.Link
}
Expand Down

0 comments on commit 1d055c6

Please sign in to comment.