local-gadget: Remove workaround for pinned maps
The workaround that ensures that maps can be pinned is not needed
anymore because after local-gadget will not use any pinned map
anymore (as it should have been).
@@ -28,8 +28,6 @@ import (
containersmap "github.com/kinvolk/inspektor-gadget/pkg/gadgettracermanager/containers-map"
"github.com/kinvolk/inspektor-gadget/pkg/gadgettracermanager/pubsub"
tracercollection "github.com/kinvolk/inspektor-gadget/pkg/tracer-collection"
- log "github.com/sirupsen/logrus"
- "golang.org/x/sys/unix"
"github.com/cilium/ebpf"
"github.com/cilium/ebpf/rlimit"
@@ -302,34 +300,6 @@ func (l *LocalGadgetManager) Dump() string {
return out
}
-// ensureBPFMount ensures /sys/fs/bpf is of type bpf. It is necessary to be able
-// to pin eBPF maps. TODO: Remove the need of using pinning, see issues #619 and
-// #620.
-func ensureBPFMount() error {
- const bpfPinPath string = "/sys/fs/bpf"
- var buf unix.Statfs_t
-
- if err := unix.Statfs(bpfPinPath, &buf); err != nil {
- return fmt.Errorf("error checking type of %s: %w", bpfPinPath, err)
- }
-
- if buf.Type == unix.BPF_FS_MAGIC {
- // It is already bpf type. Nothing to do.
- return nil
- }
-
- log.Debugf("%s is of type %#x but we were expecting %#x (BPF_FS_MAGIC)",
- bpfPinPath, buf.Type, unix.BPF_FS_MAGIC)
-
- log.Infof("Remounting %q as bpf", bpfPinPath)
-
- if err := unix.Mount("bpf", bpfPinPath, "bpf", 0, ""); err != nil {
- return fmt.Errorf("error remounting %s as bpf: %w", bpfPinPath, err)
- }
-
- return nil
-}
-
func NewManager(runtimes []*containerutils.RuntimeConfig) (*LocalGadgetManager, error) {
l := &LocalGadgetManager{
traceFactories: gadgetcollection.TraceFactoriesForLocalGadget(),
@@ -346,10 +316,6 @@ func NewManager(runtimes []*containerutils.RuntimeConfig) (*LocalGadgetManager,
return nil, err
}
- if err := ensureBPFMount(); err != nil {
- return nil, err
- }
-
l.containersMap, err = containersmap.NewContainersMap("")
if err != nil {
return nil, fmt.Errorf("error creating containers map: %w", err)
