-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The cilium events map is used by the monitor.Agent. In preparation of modularization of the agent, move the initialization of the eventsmap into the hive. Signed-off-by: David Bimmler <david.bimmler@isovalent.com>
- Loading branch information
1 parent
1c0e769
commit 80d30af
Showing
5 changed files
with
66 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Cilium | ||
|
||
package eventsmap | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/sirupsen/logrus" | ||
|
||
"github.com/cilium/cilium/pkg/bpf" | ||
"github.com/cilium/cilium/pkg/common" | ||
"github.com/cilium/cilium/pkg/hive" | ||
"github.com/cilium/cilium/pkg/hive/cell" | ||
) | ||
|
||
// Cell provides eventsmap.Map, which is the hive representation of the cilium | ||
// events perf event ring buffer. | ||
var Cell = cell.Module( | ||
"events-map", | ||
"eBPF ring buffer of cilium events", | ||
|
||
cell.Provide(newEventsMap), | ||
) | ||
|
||
var ( | ||
MaxEntries int | ||
) | ||
|
||
type Map interface{} | ||
|
||
func newEventsMap(log logrus.FieldLogger, lifecycle hive.Lifecycle) bpf.MapOut[Map] { | ||
eventsMap := &eventsMap{} | ||
|
||
lifecycle.Append(hive.Hook{ | ||
OnStart: func(context hive.HookContext) error { | ||
cpus := common.GetNumPossibleCPUs(log) | ||
err := eventsMap.init(cpus) | ||
if err != nil { | ||
return fmt.Errorf("initializing events map: %w", err) | ||
} | ||
return nil | ||
}, | ||
OnStop: func(context hive.HookContext) error { | ||
// We don't currently care for cleaning up. | ||
return nil | ||
}, | ||
}) | ||
|
||
return bpf.NewMapOut(Map(eventsMap)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters