Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions pkg/api/tracingapi/client_kprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,14 +589,6 @@ type MsgGenericKprobeUnix struct {
Args []MsgGenericKprobeArg
}

type KprobeArgs struct {
Args0 []byte
Args1 []byte
Args2 []byte
Args3 []byte
Args4 []byte
}

type ConfigBTFArg struct {
Offset uint32 `align:"offset"`
IsPointer uint16 `align:"is_pointer"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/sensors/program/loader_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,8 @@ func doLoadProgram(
pinPath = pm.PinPath
}
if m, ok := coll.Maps[mapLoad.Name]; ok {
if err := mapLoad.Load(m, pinPath, mapLoad.Index); err != nil {
return nil, err
if err := mapLoad.Load(m, pinPath); err != nil {
return nil, fmt.Errorf("map load for %s failed: %w", mapLoad.Name, err)
}
} else {
return nil, fmt.Errorf("populating map failed as map '%s' was not found from collection", mapLoad.Name)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sensors/program/loader_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func doLoadProgram(
pinPath = pm.PinPath
}
if m, ok := coll.Maps[mapLoad.Name]; ok {
if err := mapLoad.Load(m, pinPath, mapLoad.Index); err != nil {
if err := mapLoad.Load(m, pinPath); err != nil {
return nil, err
}
} else {
Expand Down
5 changes: 2 additions & 3 deletions pkg/sensors/program/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ func GetProgramInfo(l *Program) (program, label, prog string) {
}

type MapLoad struct {
Index uint32
Name string
Load func(m *ebpf.Map, pinPathPrefix string, index uint32) error
Name string
Load func(m *ebpf.Map, pinPathPrefix string) error
}

type MultiKprobeAttachData struct {
Expand Down
14 changes: 6 additions & 8 deletions pkg/sensors/tracing/generickprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -1109,10 +1109,9 @@ func loadSingleKprobeSensor(id idtable.EntryID, bpfDir string, load *program.Pro
var configData bytes.Buffer
binary.Write(&configData, binary.LittleEndian, gk.loadArgs.config)
config := &program.MapLoad{
Index: 0,
Name: "config_map",
Load: func(m *ebpf.Map, _ string, index uint32) error {
return m.Update(index, configData.Bytes()[:], ebpf.UpdateAny)
Name: "config_map",
Load: func(m *ebpf.Map, _ string) error {
return m.Update(uint32(0), configData.Bytes()[:], ebpf.UpdateAny)
},
}
load.MapLoad = append(load.MapLoad, config)
Expand Down Expand Up @@ -1141,10 +1140,9 @@ func loadMultiKprobeSensor(ids []idtable.EntryID, bpfDir string, load *program.P

binary.Write(&bin_buf[index], binary.LittleEndian, gk.loadArgs.config)
config := &program.MapLoad{
Index: uint32(index),
Name: "config_map",
Load: func(m *ebpf.Map, _ string, index uint32) error {
return m.Update(index, bin_buf[index].Bytes()[:], ebpf.UpdateAny)
Name: "config_map",
Load: func(m *ebpf.Map, _ string) error {
return m.Update(uint32(index), bin_buf[index].Bytes()[:], ebpf.UpdateAny)
},
}
load.MapLoad = append(load.MapLoad, config)
Expand Down
7 changes: 3 additions & 4 deletions pkg/sensors/tracing/genericlsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ func (k *observerLsmSensor) LoadProbe(args sensors.LoadProbeArgs) error {
var configData bytes.Buffer
binary.Write(&configData, binary.LittleEndian, gl.config)
config := &program.MapLoad{
Index: 0,
Name: "config_map",
Load: func(m *ebpf.Map, _ string, index uint32) error {
return m.Update(index, configData.Bytes()[:], ebpf.UpdateAny)
Name: "config_map",
Load: func(m *ebpf.Map, _ string) error {
return m.Update(uint32(0), configData.Bytes()[:], ebpf.UpdateAny)
},
}
args.Load.MapLoad = append(args.Load.MapLoad, config)
Expand Down
7 changes: 3 additions & 4 deletions pkg/sensors/tracing/generictracepoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,10 +788,9 @@ func LoadGenericTracepointSensor(bpfDir string, load *program.Program, maps []*p
var binBuf bytes.Buffer
binary.Write(&binBuf, binary.LittleEndian, *config)
cfg := &program.MapLoad{
Index: 0,
Name: "config_map",
Load: func(m *ebpf.Map, _ string, index uint32) error {
return m.Update(index, binBuf.Bytes()[:], ebpf.UpdateAny)
Name: "config_map",
Load: func(m *ebpf.Map, _ string) error {
return m.Update(uint32(0), binBuf.Bytes()[:], ebpf.UpdateAny)
},
}
load.MapLoad = append(load.MapLoad, cfg)
Expand Down
28 changes: 12 additions & 16 deletions pkg/sensors/tracing/genericuprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,15 @@ func loadSingleUprobeSensor(uprobeEntry *genericUprobe, args sensors.LoadProbeAr

mapLoad := []*program.MapLoad{
{
Index: 0,
Name: "config_map",
Load: func(m *ebpf.Map, _ string, index uint32) error {
return m.Update(index, configData.Bytes()[:], ebpf.UpdateAny)
Name: "config_map",
Load: func(m *ebpf.Map, _ string) error {
return m.Update(uint32(0), configData.Bytes()[:], ebpf.UpdateAny)
},
},
{
Index: 0,
Name: "filter_map",
Load: func(m *ebpf.Map, _ string, index uint32) error {
return m.Update(index, selBuff[:], ebpf.UpdateAny)
Name: "filter_map",
Load: func(m *ebpf.Map, _ string) error {
return m.Update(uint32(0), selBuff[:], ebpf.UpdateAny)
},
},
}
Expand Down Expand Up @@ -172,17 +170,15 @@ func loadMultiUprobeSensor(ids []idtable.EntryID, args sensors.LoadProbeArgs) er

mapLoad := []*program.MapLoad{
{
Index: uint32(index),
Name: "config_map",
Load: func(m *ebpf.Map, _ string, index uint32) error {
return m.Update(index, configData.Bytes()[:], ebpf.UpdateAny)
Name: "config_map",
Load: func(m *ebpf.Map, _ string) error {
return m.Update(uint32(index), configData.Bytes()[:], ebpf.UpdateAny)
},
},
{
Index: uint32(index),
Name: "filter_map",
Load: func(m *ebpf.Map, _ string, index uint32) error {
return m.Update(index, selBuff[:], ebpf.UpdateAny)
Name: "filter_map",
Load: func(m *ebpf.Map, _ string) error {
return m.Update(uint32(index), selBuff[:], ebpf.UpdateAny)
},
},
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/sensors/tracing/policyhandler_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ func (pi *policyInfo) policyConfMap(prog *program.Program) *program.Map {
}
pi.policyConf = program.MapBuilderPolicy("policy_conf", prog)
prog.MapLoad = append(prog.MapLoad, &program.MapLoad{
Index: 0,
Name: policyconf.PolicyConfMapName,
Load: func(m *ebpf.Map, _ string, _ uint32) error {
Name: policyconf.PolicyConfMapName,
Load: func(m *ebpf.Map, _ string) error {
mode := policyconf.EnforceMode
if pi.specOpts != nil {
mode = pi.specOpts.policyMode
Expand Down
95 changes: 38 additions & 57 deletions pkg/sensors/tracing/selectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,121 +22,102 @@ func selectorsMaploads(ks *selectors.KernelSelectorState, index uint32) []*progr
selBuff := ks.Buffer()
maps := []*program.MapLoad{
{
Index: index,
Name: "filter_map",
Load: func(m *ebpf.Map, _ string, index uint32) error {
Name: "filter_map",
Load: func(m *ebpf.Map, _ string) error {
return m.Update(index, selBuff[:], ebpf.UpdateAny)
},
}, {
Index: 0,
Name: "argfilter_maps",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "argfilter_maps",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateArgFilterMaps(ks, pinPathPrefix, outerMap)
},
}, {
Index: 0,
Name: "addr4lpm_maps",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "addr4lpm_maps",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateAddr4FilterMaps(ks, pinPathPrefix, outerMap)
},
}, {
Index: 0,
Name: "addr6lpm_maps",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "addr6lpm_maps",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateAddr6FilterMaps(ks, pinPathPrefix, outerMap)
},
}, {
Index: 0,
Name: "tg_mb_sel_opts",
Load: func(outerMap *ebpf.Map, _ string, _ uint32) error {
Name: "tg_mb_sel_opts",
Load: func(outerMap *ebpf.Map, _ string) error {
return populateMatchBinariesMaps(ks, outerMap)
},
}, {
Index: 0,
Name: "tg_mb_paths",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "tg_mb_paths",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateMatchBinariesPathsMaps(ks, pinPathPrefix, outerMap)
},
}, {
Index: 0,
Name: "string_prefix_maps",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "string_prefix_maps",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateStringPrefixFilterMaps(ks, pinPathPrefix, outerMap)
},
}, {
Index: 0,
Name: "string_postfix_maps",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "string_postfix_maps",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateStringPostfixFilterMaps(ks, pinPathPrefix, outerMap)
},
}, {
Index: 0,
Name: "string_maps_0",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "string_maps_0",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateStringFilterMaps(ks, pinPathPrefix, outerMap, 0)
},
}, {
Index: 0,
Name: "string_maps_1",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "string_maps_1",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateStringFilterMaps(ks, pinPathPrefix, outerMap, 1)
},
}, {
Index: 0,
Name: "string_maps_2",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "string_maps_2",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateStringFilterMaps(ks, pinPathPrefix, outerMap, 2)
},
}, {
Index: 0,
Name: "string_maps_3",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "string_maps_3",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateStringFilterMaps(ks, pinPathPrefix, outerMap, 3)
},
}, {
Index: 0,
Name: "string_maps_4",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "string_maps_4",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateStringFilterMaps(ks, pinPathPrefix, outerMap, 4)
},
}, {
Index: 0,
Name: "string_maps_5",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "string_maps_5",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateStringFilterMaps(ks, pinPathPrefix, outerMap, 5)
},
}, {
Index: 0,
Name: "string_maps_6",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "string_maps_6",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateStringFilterMaps(ks, pinPathPrefix, outerMap, 6)
},
}, {
Index: 0,
Name: "string_maps_7",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "string_maps_7",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateStringFilterMaps(ks, pinPathPrefix, outerMap, 7)
},
},
}
if kernels.MinKernelVersion("5.11") {
maps = append(maps, []*program.MapLoad{
{
Index: 0,
Name: "string_maps_8",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "string_maps_8",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateStringFilterMaps(ks, pinPathPrefix, outerMap, 8)
},
}, {
Index: 0,
Name: "string_maps_9",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "string_maps_9",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateStringFilterMaps(ks, pinPathPrefix, outerMap, 9)
},
}, {
Index: 0,
Name: "string_maps_10",
Load: func(outerMap *ebpf.Map, pinPathPrefix string, _ uint32) error {
Name: "string_maps_10",
Load: func(outerMap *ebpf.Map, pinPathPrefix string) error {
return populateStringFilterMaps(ks, pinPathPrefix, outerMap, 10)
},
},
Expand Down
Loading