-
Notifications
You must be signed in to change notification settings - Fork 10
/
innerouter_map_spec.go
37 lines (32 loc) · 1.24 KB
/
innerouter_map_spec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package manager
import "fmt"
// InnerOuterMapSpec - An InnerOuterMapSpec defines the map that should be used as the inner map of the provided outer map.
type InnerOuterMapSpec struct {
// OuterMapName - Name of the BPF_MAP_TYPE_ARRAY_OF_MAPS or BPF_MAP_TYPE_HASH_OF_MAPS map, as defined in its
// section SEC("maps/[OuterMapName]")
OuterMapName string
// InnerMapName - Name of the inner map of the provided outer map, as defined in its section SEC("maps/[InnerMapName]")
InnerMapName string
}
// editInnerOuterMapSpecs - Update the inner maps of the maps of maps in the collection spec
func (m *Manager) editInnerOuterMapSpec(spec InnerOuterMapSpec) error {
// find the outer map
outerSpec, exists, err := m.GetMapSpec(spec.OuterMapName)
if err != nil {
return err
}
if !exists {
return fmt.Errorf("failed to set inner map for maps/%s: couldn't find outer map: %w", spec.OuterMapName, ErrUnknownSection)
}
// find the inner map
innerMap, exists, err := m.GetMapSpec(spec.InnerMapName)
if err != nil {
return err
}
if !exists {
return fmt.Errorf("failed to set inner map for maps/%s: couldn't find inner map %s: %w", spec.OuterMapName, spec.InnerMapName, ErrUnknownSection)
}
// set inner map
outerSpec.InnerMap = innerMap
return nil
}