microsoft / ebpf-for-windows

eBPF implementation that runs on top of Windows
MIT License
2.92k stars 229 forks source link

Use Mermaid for Architecture Diagrams #995

Open nibanks opened 2 years ago

nibanks commented 2 years ago

Describe the feature you'd like supported

I noticed your architecture diagram and thought it would be possible to use Mermaid instead to represent it.

Proposed solution

See https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid for more details. For example:

  graph LR;
      source(eBPF program source)-->toolchain;
      nesh(netsh CLI)-->ebpfnetsh.dll;
      toolchain(existing toolchains)-->ebpfnetsh.dll;
      toolchain-->epbfapi.dll;
      ebpfnetsh.dll-->epbfapi.dll;
      epbfapi.dll-->|eBPF program bytecode|ebpfsvc.dll;

It's pretty powerful, and fairly well documented. I think you can completely represent everything you have in your existing diagram this way.

Additional context

https://mermaid-js.github.io/mermaid/#/flowchart

devplayer55221 commented 1 month ago

I created a mermaid flowchart for the architecture diagram. Here is the svg image file for the same. mermaid-diagram-2024-09-27-040548

Also the code for generating the same

%%{ init: { 'flowchart': { 'curve': 'linear' } } }%%
flowchart LR
        subgraph "User mode"
        direction LR
            A(eBPF program source) -->B("Existing eBPF toolchains (e.g., clang)")
            B -->|eBPF program bytecode|C("Netsh plugin (ebpfnetsh.dll)")
            B -->D("Any application (e.g., bpftool)")
            E("Netsh CLI (netsh.exe)") -->C
            C --> F("User-Mode API Library (ebpfapi.dll) Libbpf")
            subgraph "User-Mode Service (ebpfsvc.dll)"
            direction LR
                One(PREVAIL Verifier) --> Two(UBPF JIT Compiler)
            end
            F -->|eBPF program bytecode|One
        end
        subgraph "Kernel mode"
            direction LR
            G("TCP/IP stack (tcpip.sys)") --> I("eBPF Shim for networking prog-type, hooks & helpers (netebpfext.sys)")
            H("Layer 2 Network Driver Subsystem (ndis.sys)") --> I
            subgraph sub1 ["Kernel-Mode Execution Context (ebpfcore.sys)"]
            direction LR
                Three(uBPF Interpreter) --> Four(eBPF Program native code)
            end
            I --> sub1
            One -->|eBPF program bytecode|Three
            Two -- "eBPF program native code" --> Four
        end
        subgraph keys
            direction LR
            J(Unmodified Windows Component)
            K(Open source: ebpf-for-windows)
            L(Open source: other projects)
        end