ebpf

Interacting With Maps

Table of Contents Interacting with eBPF maps happens through lookup/update/delete primitives. Userspace The userspace API map helpers for eBPF are defined in tools/lib/bpf/bpf.h and include the following functions: /* Userspace helpers */ int bpf_map_lookup_elem(int fd, void *key, void *value); int bpf_map_update_elem(int fd, void *key, void *value, __u64 flags); int bpf_map_delete_elem(int fd, void *key); /* Only userspace: */ int bpf_map_get_next_key(int …

Interacting With Maps Read More »

BPF Maps

Table of Contents The program is designed to be attached to an XDP (eXpress Data Path) hook, which is a high-performance data path in the Linux kernel for fast packet processing. The goal of this program is to count the number of packets that pass through the XDP hook and store the statistics in a BPF hash map. …

BPF Maps Read More »

How-to-run-the-program

sudo -s export BPF_CLANG=clang go build ip link is a command in Linux used to display and manage network interfaces. When used without any arguments, the ip link command displays a list of available network interfaces on the system along with their status, state, and hardware addresses Here is an example output of the ip link command: In this example, lo and wlp0s20f3 are …

How-to-run-the-program Read More »

ebpf library

Table of Contents Cilium is an open-source project that provides a networking and security solution for containerized applications that leverages eBPF technology. The Cilium eBPF library provides a Go interface to the eBPF subsystem, making it easier to write eBPF programs in Go. The Cilium eBPF library is a Go library that provides abstractions over eBPF programs …

ebpf library Read More »

Repository-Structure

Table of Contents $ebpf-network |==go.mod |==go.sum |==Readme.md |==headers |——–bpf_endian.h |——–bpf_helper_defs.h |——–bpf_helpers.h |——–bpf_tracing.h |——–common.h |——–update.sh |===xdp |——–bpf_bpfeb.go |——–bpf_bpfeb.o |——–bpf_bpfel.go |——–bpf_bpfel.o |——–main.go |________xdp.c go.mod and go.sum go.mod and go.sum are two files used by the Go programming language to manage dependencies of a project. go.mod file defines the module’s dependencies and metadata, including the module’s name, version, and requirements for other …

Repository-Structure Read More »

Userspace program

Major components you might find in this userspace eBPF program written using the Cilium eBPF library in Go are as follows: Loading pre-compiled eBPF programs into the kernel Attaching the eBPF program to a network interface using XDP (eXpress Data Path) Printing the contents of the BPF hash map (source IP address -> packet count) to stdout every …

Userspace program Read More »

Kernel Space eBPF program for XDP hook

//go:build ignore This is a build constraint for Go. It specifies that this file should be ignored by the Go build system. #include “bpf_endian.h” #include “common.h” Header files that provide some utility functions and macros that are used in the program defined in the Cilium eBPF library. bpf_endian.h: This header file defines macros for converting between …

Kernel Space eBPF program for XDP hook Read More »

What is XDP

eBPF (extended Berkeley Packet Filter) XDP (Express Data Path) programs are a type of eBPF program that are attached to a network interface using the XDP hook. The XDP hook is a low-level hook that allows eBPF programs to be executed early in the packet receive path, before the packet is passed up the network …

What is XDP Read More »

Scroll to Top