Skip to content

Instantly share code, notes, and snippets.

@luisgerhorst
Created August 28, 2024 07:36
Show Gist options
  • Save luisgerhorst/cb5c5d5c143bfaca533da35ee0e39d39 to your computer and use it in GitHub Desktop.
Save luisgerhorst/cb5c5d5c143bfaca533da35ee0e39d39 to your computer and use it in GitHub Desktop.
Overview of eBPF: Bytecode -> Verifier -> JIT -> Execution
# License: CC BY-SA 4.0 (Creative Commons Attribution-ShareAlike 4.0 International), Copyright 2024 Luis Gerhorst
\usepackage{tikz}
\usetikzlibrary{arrows, calc, positioning, patterns}
\usepackage{marvosym}
\usepackage{xcolor}
\definecolor{nBlue}{RGB}{144, 167, 198}
\definecolor{nLightBlue}{RGB}{221, 229, 240}
\definecolor{nLightYellow}{RGB}{243, 238, 223}
\definecolor{nYellow}{RGB}{217, 198, 137}
\definecolor{nGreen}{RGB}{170,207,189}
\definecolor{nLightGreen}{RGB}{229,239,234}
% Vibrant color scheme from https://personal.sron.nl/~pault/#qualitativescheme
\definecolor{Blue}{RGB}{0,119,187} % vibrant
\definecolor{Green}{RGB}{34,136,51}
\definecolor{DarkGreen}{RGB}{34,85,34}
\definecolor{Cyan}{RGB}{51,187,238}
\definecolor{Teal}{RGB}{0,153,136}
\definecolor{Yellow}{RGB}{221,170,51} % high contrast
\definecolor{Orange}{RGB}{238,119,51}
\definecolor{Red}{RGB}{204,51,17}
\definecolor{DarkRed}{RGB}{102,51,51}
\definecolor{Magenta}{RGB}{238,51,119}
\definecolor{Purple}{RGB}{170,51,119}
\definecolor{Gray}{RGB}{187,187,187}
\definecolor{DarkGray}{RGB}{85,85,85}
\definecolor{Black}{RGB}{0,0,0}
\definecolor{White}{RGB}{255,255,255}
\definecolor{Olive}{RGB}{153,153,51}
\definecolor{LightBlue}{RGB}{119,170,221}
\definecolor{LightCyan}{RGB}{153,221,255}
\begin{tikzpicture}[
font=\sffamily,
actor/.style={rectangle, draw, fill=Gray!20, text centered, minimum height=2em, minimum width=7em, thick, font={\sffamily}, anchor=south west},
connection/.style={->, thick}
]
% \draw[step=1em,Gray,thin] (-2em,0) grid (34em,15em);
\draw[dashed,thick,draw=DarkGray] (-1em,8em) node[color=DarkGray,anchor=north west,rotate=90] {Userspace} node[color=DarkGray,anchor=north east,rotate=90] {Kernel} -- (33em,8em);
\node[actor, minimum width=0em] at (1em,10em) (source) {Source};
\node[actor, fill=nLightGreen, minimum height=4em, minimum width=23em] at (9em,9em) (app) {Application};
\node[actor] at (10em,10em) (bytecode) {Bytecode};
\draw[connection] (source) -> (bytecode) node [midway, above, xshift=-0.5em] {\footnotesize Compiler};
\node[actor, fill=nLightBlue] at (10em,4em) (verifier) {Verifier};
\draw[connection] (bytecode) -> (verifier) node [midway, right, yshift=-1em] {\footnotesize \texttt{bpf()} Syscall};
\node[actor] at (10em,0) (jit) {JIT Compiler};
\draw[connection] (verifier) -> (jit) node [midway, right] {\footnotesize Safe Bytecode};
\node[actor, minimum width=9em, fill=nLightYellow] at (23em,0) (ebpf) {eBPF Program};
\draw[connection] (jit) -> (ebpf) node [midway, above] {\footnotesize Machine Code};
\node[actor, minimum width=4em] at (23em,4em) (events) {Events};
\draw[connection] (events) -> (25em,2em) node [midway, left] {\footnotesize Call};
\node[actor, minimum width=4em] at (28em,4em) (maps) {Maps};
\draw[connection] (30em,2em) -> (maps) node [midway, left] {\footnotesize Helpers};
\draw[connection] (30em,9em) -> (maps) node [midway, left, yshift=-0.5em] {\footnotesize Syscalls};
\end{tikzpicture}
@luisgerhorst
Copy link
Author

Screenshot from 2024-08-28 09-35-44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment