Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/sensors: fix kprobeEntry.pinPathPrefix for multi kprobes
Browse files Browse the repository at this point in the history
Here is the issue, for example:
- In the case of simple kprobe: map name is: gkp-sensor-1-gkp-0-name_map
  with gk.pinPathPrefix = gkp-sensor-1-gkp-0
- In the case of multi kprobe: map name is gkp-sensor-1-multi_kprobe-name_map
  with gk.pinPathPrefix = gkp-sensor-1 in the second.

In the case of multi kprobe, the pinPathPrefix is wrong, it should be
gk.pinPathPrefix = gkp-sensor-1-multi_kprobe.

Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
mtardy committed Oct 11, 2023
1 parent af73cde commit 8c8c274
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/sensors/tracing/generickprobe.go
Original file line number Diff line number Diff line change
@@ -198,6 +198,10 @@ func getMetaValue(arg *v1alpha1.KProbeArg) (int, error) {
return meta, nil
}

func multiKprobePinPath(sensorPath string) string {
return sensors.PathJoin(sensorPath, "multi_kprobe")
}

func createMultiKprobeSensor(sensorPath string, multiIDs, multiRetIDs []idtable.EntryID) ([]*program.Program, []*program.Map) {
var progs []*program.Program
var maps []*program.Map
@@ -209,7 +213,7 @@ func createMultiKprobeSensor(sensorPath string, multiIDs, multiRetIDs []idtable.
loadProgRetName = "bpf_multi_retkprobe_v61.o"
}

pinPath := sensors.PathJoin(sensorPath, "multi_kprobe")
pinPath := multiKprobePinPath(sensorPath)

load := program.Builder(
path.Join(option.Config.HubbleLib, loadProgName),
@@ -756,10 +760,10 @@ func addKprobe(funcName string, f *v1alpha1.KProbeSpec, in *addKprobeIn) (out *a
genericKprobeTable.AddEntry(&kprobeEntry)
tidx := kprobeEntry.tableId.ID
out.tableEntryIndex = tidx
kprobeEntry.pinPathPrefix = sensors.PathJoin(in.sensorPath, fmt.Sprintf("gkp-%d", tidx))
config.FuncId = uint32(tidx)

if in.useMulti {
kprobeEntry.pinPathPrefix = multiKprobePinPath(in.sensorPath)
if setRetprobe {
out.multiRetIDs = append(out.multiRetIDs, kprobeEntry.tableId)
}
@@ -772,6 +776,7 @@ func addKprobe(funcName string, f *v1alpha1.KProbeSpec, in *addKprobeIn) (out *a
return out, nil
}

kprobeEntry.pinPathPrefix = sensors.PathJoin(in.sensorPath, fmt.Sprintf("gkp-%d", tidx))
pinPath := kprobeEntry.pinPathPrefix
pinProg := sensors.PathJoin(pinPath, fmt.Sprintf("%s_prog", kprobeEntry.funcName))

0 comments on commit 8c8c274

Please sign in to comment.