bpfbak

package module
v0.0.0-...-8932bbf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

bpfbak: a tiny tool to backup bpf objects under bpffs

Currently, bpffs does not support cp pinned bpf objects. This tool is a workaround to backup pinned bpf objects under bpffs.

Usage

bpfbak can be used as a library:

    opts := bpfbak.BackupOpts{
        Src:            rootFlags.src,
        UnpinSrc:       rootFlags.srcUnpin,
        Dst:            rootFlags.dst,
        AutoMountBpffs: rootFlags.autoMount,
        BpffsPath:      rootFlags.mountBpffs,
    }
    err := bpfbak.Backup(opts)
    if err != nil {
        log.Fatalf("Failed to backup bpf object: %v", err)
    }

Or as a command line tool:

$ ./bpfbak -h
bpfbak is a tool to backup eBPF objects

Usage:
  bpfbak [flags]

Flags:
      --auto-mount           automatically mount bpffs at the destination directory or --mount-bpffs
  -d, --dst string           destination filepath to backup the bpf object
  -h, --help                 help for bpfbak
      --mount-bpffs string   path to the directory where bpffs is mounted
  -s, --src string           source bpf object to be backed up
      --unpin-src            unpin the source bpf object after backing up

License

Licensed under the Apache License, Version 2.0.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backup

func Backup(opts BackupOpts) error

Backup backs up a bpf object, such as bpf program, bpf map or bpf link.

Types

type BackupOpts

type BackupOpts struct {
	// Src is the path to the bpf object to be backed up.
	Src string

	// UnpinSrc specifies whether to unpin the bpf object after backing up.
	UnpinSrc bool

	// Dst is the path to the directory where the bpf object will be pinned to.
	Dst string

	// AutoMountBpffs specifies whether to automatically mount bpffs at:
	// 1. BpffsPath if it is not empty and not already mounted.
	// 2. Dirname(Dst) if BpffsPath is empty.
	AutoMountBpffs bool

	// BpffsPath is the path to the backup directory where bpffs is mounted.
	BpffsPath string
}

BackupOpts specifies the options for backing up a bpf object.

type Pinner

type Pinner interface {
	Pin(string) error
	Unpin() error
	Close() error
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL