l3af-project / l3afd

L3AFD eBPF Programs control plane
Apache License 2.0
187 stars 38 forks source link

Undocumented contract between l3afd and ebpf programs #15

Open dthaler opened 2 years ago

dthaler commented 2 years ago

bpf.go implements

func (b *BPF) Start(ifaceName, direction string, chain bool) error

which appears to require that the command implement a specific set of command line options (iface, direction, map-name, log-dir, rules-file, etc). However these do not seem to be documented anywhere I can find.

Aryanryn09 commented 1 year ago

hey !! can we implement these changes,

The Start function in bpf.go is part of the BPF struct, which is a higher-level interface for managing eBPF programs, maps, and events in Go.

The Start function starts a BPF program on a specified network interface and direction (incoming or outgoing). The chain parameter is a boolean that indicates whether the program should be chained with any existing program on the interface.

To use this function, the caller needs to pass in the required parameters as command line arguments when running their Go program. The documentation for these command line arguments can be found in the flag package in the standard Go library. Here is a brief summary of the command line arguments that are relevant to Start:

iface: The name of the network interface on which to attach the program. direction: The direction in which the program should run, either "in" for incoming or "out" for outgoing traffic. map-name: The name of the map to use for the BPF program. log-dir: The directory where log files should be written. rules-file: The path to the file containing the BPF program code. The Start function also returns an error if the BPF program fails to start or if any of the required parameters are missing or invalid.

It's worth noting that the BPF struct is part of the ebpf package in the ebpf-go library. The ebpf package provides a set of low-level APIs for interacting with eBPF programs and maps in Go, while the BPF struct provides a higher-level interface for managing these components.