Slide 1

Slide 1 text

Aladdin & the eBPF lamp Travel in the kernel Donia Chaiehloudj, Software Engineer & Community Isovalent @Cisco

Slide 2

Slide 2 text

Living from hand to mouth without any visibility, security... (and money)

Slide 3

Slide 3 text

Living from hand to mouth without any visibility, security... (and money)

Slide 4

Slide 4 text

The Mysterious Cave The Kernel of Wonders...

Slide 5

Slide 5 text

The Mysterious Cave The Kernel of Wonders... Syscalls Sockets Packets Hooks Maps

Slide 6

Slide 6 text

The Mysterious Cave The Kernel of Wonders... with Rules To change the Kernel: Rebuild the kernel Load modules Risky for adventurers...

Slide 7

Slide 7 text

The Summons Aladdin is sent to the Cave....

Slide 8

Slide 8 text

The Summons Aladdin is sent to the Cave....

Slide 9

Slide 9 text

The Magic eBPF Lamp

Slide 10

Slide 10 text

The Magic eBPF Lamp And the eGenie...

Slide 11

Slide 11 text

Program App The Magic eBPF Lamp And Events Userspace Syscalls Linux Kernel

Slide 12

Slide 12 text

Program App The Magic eBPF Lamp And Events Userspace Syscalls Linux Kernel event

Slide 13

Slide 13 text

Program App The Magic eBPF Lamp And Events Events tracepoints kprobes (kernel) uprobes (user) TC (Traffic Control) XDP (Express Datapath) Userspace Syscalls Linux Kernel event

Slide 14

Slide 14 text

App Program Verifier The Magic eBPF Lamp is Safe eBPF programs are: verified sandboxed You can’t crash your kernel. Userspace Syscalls Linux Kernel load eBPF programs

Slide 15

Slide 15 text

App Program Verifier JIT Compiler approved The Magic eBPF Lamp is Safe eBPF programs are: verified sandboxed You can’t crash your kernel. Userspace Syscalls Linux Kernel load eBPF programs

Slide 16

Slide 16 text

The Magic eBPF Lamp has Maps for what’s is hidden in the cave Userspace Syscalls Linux Kernel App eBPF maps Program BPF_MAP_TYPE_HASH BPF_MAP_TYPE_ARRAY BPF_MAP_TYPE_PERCPU_HASH ...

Slide 17

Slide 17 text

The Magic eBPF Lamp has Maps for what’s is hidden in the cave Userspace Syscalls Linux Kernel App eBPF maps read Use Cases: kernel → userspace write Program BPF_MAP_TYPE_HASH BPF_MAP_TYPE_ARRAY BPF_MAP_TYPE_PERCPU_HASH ...

Slide 18

Slide 18 text

The Magic eBPF Lamp has Maps to load configuration in the cave... Use Cases: kernel → userspace userspace → kernel Userspace Syscalls Linux Kernel App eBPF maps read write Program BPF_MAP_TYPE_HASH BPF_MAP_TYPE_ARRAY BPF_MAP_TYPE_PERCPU_HASH ...

Slide 19

Slide 19 text

The Magic eBPF Lamp has Maps to transport information within the cave... Use Cases: kernel → userspace userspace → kernel kernel → kernel Userspace Syscalls Linux Kernel App eBPF maps write Program Program read BPF_MAP_TYPE_HASH BPF_MAP_TYPE_ARRAY BPF_MAP_TYPE_PERCPU_HASH ...

Slide 20

Slide 20 text

The Flying Carpet

Slide 21

Slide 21 text

→ SDKs like cilium/ebpf let you write networking/security tooling + = Go the companion to travel easy The Flying Carpet

Slide 22

Slide 22 text

Go the companion to travel easy The Flying Carpet Userspace Syscalls Linux Kernel App ELF Object load

Slide 23

Slide 23 text

Go the companion to travel easy The Flying Carpet Userspace Syscalls Linux Kernel App C Program ELF Object load clang

Slide 24

Slide 24 text

Go the companion to travel easy The Flying Carpet Userspace Syscalls Linux Kernel eBPF maps BPF_MAP_TYPE_HASH BPF_MAP_TYPE_ARRAY BPF_MAP_TYPE_PERCPU_HASH ... App C Program ELF Object load clang

Slide 25

Slide 25 text

Go the companion to travel easy The Flying Carpet Userspace Syscalls Linux Kernel eBPF maps BPF_MAP_TYPE_HASH BPF_MAP_TYPE_ARRAY BPF_MAP_TYPE_PERCPU_HASH ... App C Program ELF Object load clang write read

Slide 26

Slide 26 text

Wish #1: Becoming a Prince

Slide 27

Slide 27 text

Wish #1: Becoming a Prince

Slide 28

Slide 28 text

Wish #1: Becoming a Prince Tracing Capability Step 1: Write C program

Slide 29

Slide 29 text

Wish #1: Becoming a Prince Tracing Capability / Open file example Step 1: Write C program

Slide 30

Slide 30 text

Wish #1: Becoming a Prince Tracing Capability / Open file example Step 1: Write C program ✅

Slide 31

Slide 31 text

Wish #1: Becoming a Prince Tracing Capability / Open file example //go:generate go run github.com/cilium/ebpf/cmd/bpf2go tracing tracing.c Step 1: Write C program ✅ Step 2: Use friendly APIs to load programs cilium/ebpf library

Slide 32

Slide 32 text

Wish #1: Becoming a Prince Tracing Capability / Open file example //go:generate go run github.com/cilium/ebpf/cmd/bpf2go tracing tracing.c Step 1: Write C program ✅ Step 2: Use friendly APIs to load programs cilium/ebpf library type openfileObjects struct { openfilePrograms openfileMaps openfileVariables } eBPF Objects to manipulate

Slide 33

Slide 33 text

Wish #1: Becoming a Prince Tracing Capability / Open file example //go:generate go run github.com/cilium/ebpf/cmd/bpf2go tracing tracing.c Step 1: Write C program ✅ Step 2: Use friendly APIs to load programs cilium/ebpf library type openfileObjects struct { openfilePrograms openfileMaps openfileVariables } eBPF Objects to manipulate eBPF program bytecodes type openfilePrograms struct { TraceOpenat *ebpf.Program `ebpf:"trace_openat"` }

Slide 34

Slide 34 text

Wish #1: Becoming a Prince Tracing Capability / Open file example Step 1: Write C program ✅ Step 2: Use friendly APIs to load programs cilium/ebpf library ✅

Slide 35

Slide 35 text

Wish #1: Becoming a Prince Tracing Capability / Open file example Step 1: Write C program ✅ Step 2: Use friendly APIs to load programs cilium/ebpf library ✅ Step 3: Write Go program to load eBPF program

Slide 36

Slide 36 text

Wish #1: Becoming a Prince Tracing Capability / Open file example

Slide 37

Slide 37 text

Wish #1: Becoming a Prince Tracing Capability / Open file example Step 1: Write C program ✅ Step 2: Use friendly APIs to load programs cilium/ebpf library ✅ Step 3: Write Go program to load eBPF program ✅

Slide 38

Slide 38 text

Wish #1: Becoming a Prince Tracing Capability / Open file example

Slide 39

Slide 39 text

Wish #1: Becoming a Prince Observability Capability / Count packet numbers

Slide 40

Slide 40 text

Wish #1: Becoming a Prince Observability Capability / Count packet numbers

Slide 41

Slide 41 text

Moral #1 “We didn’t recompile the application. We didn’t stop the kingdom. We simply saw. Like Aladdin dressed in fine silk, we gain legitimacy, we can observe from the inside… with grace.”

Slide 42

Slide 42 text

🥷 The Threat: “Jafar Strikes” A noisy neighbor A suspicious IP A storm of a packets at the gate

Slide 43

Slide 43 text

Wish #2: Save me eGenie from the Deep

Slide 44

Slide 44 text

Wish #2: Save me eGenie from the Deep XDP Capability

Slide 45

Slide 45 text

Wish #2: Save me eGenie from the Deep XDP Capability - C Code

Slide 46

Slide 46 text

Wish #2: Save me eGenie from the Deep XDP Capability - Demo

Slide 47

Slide 47 text

Moral #2 When the sea turns rough, eBPF can pull you to the surface—not with blunt force, but with elegant control at the kernel’s edge.”

Slide 48

Slide 48 text

The Prince in the Kubernetes Palace

Slide 49

Slide 49 text

pods The Magic eBPF Lamp And Events One kernel for all the containers Userspace Syscalls Linux Kernel

Slide 50

Slide 50 text

pods The Magic eBPF Lamp And Events One kernel for all the containers Userspace Syscalls Linux Kernel event

Slide 51

Slide 51 text

Program pods The Magic eBPF Lamp And Events One kernel for all the containers Userspace Syscalls Linux Kernel event

Slide 52

Slide 52 text

The Prince in the Kubernetes Palace And the Power of eBPF

Slide 53

Slide 53 text

Wish #3: Freeing the eGenie From Tools to Ecosystem

Slide 54

Slide 54 text

Wish #3: Freeing the eGenie From Tools to Ecosystem in Networking

Slide 55

Slide 55 text

Wish #3: Freeing the eGenie Cilium as the default Cloud Networking Interface (CNI) Amazon EKS Anywhere Anthos GKE Dataplane v2 Azure Kubernetes Service Azure Kubernetes Service source: https://cilium.io/use-cases/cni/ Managed Kubernetes Service MetaKube

Slide 56

Slide 56 text

Wish #3: Freeing the eGenie From Tools to Ecosystem in Security - Tetragon

Slide 57

Slide 57 text

Moral #3 When the eGenie is free, standardized, open source, integrated, everyone benefits: platform teams, developers, security, and ultimately… users.”

Slide 58

Slide 58 text

Key Takeways Write tiny, safe eBPF Program without rebooting

Slide 59

Slide 59 text

Key Takeways Write tiny, safe eBPF Program without rebooting Abstract syscalls, make programs practical, maintainable.

Slide 60

Slide 60 text

Key Takeways Write tiny, safe eBPF Program without rebooting Abstract syscalls, make programs practical, maintainable. Wish #1: Tracing Wish #2: Security XDP Wish #3: Networking k8s Palace

Slide 61

Slide 61 text

It’s not about power, it’s about wisdom. Use the genie well. Free it into the ecosystem. Build tools that help everyone. Key Takeways Write tiny, safe eBPF Program without rebooting Abstract syscalls, make programs practical, maintainable. Wish #1: Tracing Wish #2: Security XDP Wish #3: Networking k8s Palace

Slide 62

Slide 62 text

The End...

Slide 63

Slide 63 text

@doniacld ebpf.io @ciliumproject @isovalent 🧪 isovalent.com/labs/ebpf-getting-started/ 👩🏾‍💻 github.com/doniacld/ebpf-4-gophers/ Resources & Credits

Slide 64

Slide 64 text

@doniacld ebpf.io @ciliumproject @isovalent 🧪 isovalent.com/labs/ebpf-getting-started/ 👩🏾‍💻 github.com/doniacld/ebpf-4-gophers/ Resources & Credits Feedback is a gift 🎁