From 351e7de981ae392affb1288951f402f47c6ed296 Mon Sep 17 00:00:00 2001 From: Daniel Noland Date: Fri, 7 Feb 2025 22:32:04 -0700 Subject: [PATCH] scratch docs rework --- .cargo/config.toml | 3 + design-docs/src/mdbook/book.toml | 4 - .../mdbook/src/build/.gen/build-sequence.svg | 1 + .../src/mdbook/src/build/.gen/compile-env.svg | 1 + .../src/mdbook/src/build/.gen/fake-nix.svg | 1 + .../src/mdbook/src/build/build-sequence.puml | 33 +++ .../src/mdbook/src/build/compile-env.md | 42 +-- .../src/mdbook/src/build/compile-env.puml | 35 +++ design-docs/src/mdbook/src/build/fake-nix.md | 42 +-- .../src/mdbook/src/build/fake-nix.puml | 39 +++ design-docs/src/mdbook/src/build/index.md | 81 ++--- .../src/mdbook/src/build/just-cargo-build.md | 2 +- .../src/mdbook/src/build/prerequisites.md | 4 +- .../src/dataplane/.gen/gen/map-of-dpdk.svg | 1 + .../src/mdbook/src/dataplane/map-of-dpdk.md | 81 +---- .../src/mdbook/src/dataplane/map-of-dpdk.puml | 69 +++++ .../mdbook/src/design/.gen/component-map.svg | 1 + ...r-facing-feature-dependencies-internal.svg | 279 ++++++++++++++++++ .../.gen/user-facing-feature-dependencies.svg | 160 ++++++++++ .../src/mdbook/src/design/component-map.puml | 99 +++++++ design-docs/src/mdbook/src/design/index.md | 106 +------ design-docs/src/mdbook/src/design/mvp.md | 98 +----- ...-facing-feature-dependencies-internal.puml | 55 ++++ .../user-facing-feature-dependencies.puml | 33 +++ net/src/encap/test.md | 13 + net/src/packet.rs | 45 ++- 26 files changed, 896 insertions(+), 432 deletions(-) create mode 100644 design-docs/src/mdbook/src/build/.gen/build-sequence.svg create mode 100644 design-docs/src/mdbook/src/build/.gen/compile-env.svg create mode 100644 design-docs/src/mdbook/src/build/.gen/fake-nix.svg create mode 100644 design-docs/src/mdbook/src/build/build-sequence.puml create mode 100644 design-docs/src/mdbook/src/build/compile-env.puml create mode 100644 design-docs/src/mdbook/src/build/fake-nix.puml create mode 100644 design-docs/src/mdbook/src/dataplane/.gen/gen/map-of-dpdk.svg create mode 100644 design-docs/src/mdbook/src/dataplane/map-of-dpdk.puml create mode 100644 design-docs/src/mdbook/src/design/.gen/component-map.svg create mode 100644 design-docs/src/mdbook/src/design/.gen/user-facing-feature-dependencies-internal.svg create mode 100644 design-docs/src/mdbook/src/design/.gen/user-facing-feature-dependencies.svg create mode 100644 design-docs/src/mdbook/src/design/component-map.puml create mode 100644 design-docs/src/mdbook/src/design/user-facing-feature-dependencies-internal.puml create mode 100644 design-docs/src/mdbook/src/design/user-facing-feature-dependencies.puml create mode 100644 net/src/encap/test.md diff --git a/.cargo/config.toml b/.cargo/config.toml index e44b40a0..f73d0e54 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -5,6 +5,9 @@ LIBCLANG_PATH = { value = "compile-env/lib", relative = true, force = true } [build] target = "x86_64-unknown-linux-gnu" +rustdocflags = [ + "--cfg", "doc", +] [alias] just = ["just", "cargo"] diff --git a/design-docs/src/mdbook/book.toml b/design-docs/src/mdbook/book.toml index b828a4ac..6cb78034 100644 --- a/design-docs/src/mdbook/book.toml +++ b/design-docs/src/mdbook/book.toml @@ -5,10 +5,6 @@ multilingual = false src = "src" title = "Hedgehog Dataplane Design Notes" -[preprocessor.plantuml] -plantuml-cmd = "/bin/plantuml" -after = ["links"] - [preprocessor.mermaid] after = ["links"] diff --git a/design-docs/src/mdbook/src/build/.gen/build-sequence.svg b/design-docs/src/mdbook/src/build/.gen/build-sequence.svg new file mode 100644 index 00000000..11af2c18 --- /dev/null +++ b/design-docs/src/mdbook/src/build/.gen/build-sequence.svg @@ -0,0 +1 @@ +hedgehog stuffdataplanedpdk-sysnixpkgscontainerexternaldataplanedataplanedpdk-sysdpdk-sysnixpkgsnixpkgscontainerregistrycontainerregistryexternalsource reposexternalsource reposbuild instructions plzhere ya gofetch codehere ya gofollow build instructionsThis is alongbuildpush compile-envgot itcompile-env plzhere ya goput compile-envin a dir named "compile-env"just sterile-buildcargo build(called byjust sterile-build) now hasaccess to the many.afiles required to compileand link the dataplane.It also has a consistent version of LLVM and clang towork with.push containergot it \ No newline at end of file diff --git a/design-docs/src/mdbook/src/build/.gen/compile-env.svg b/design-docs/src/mdbook/src/build/.gen/compile-env.svg new file mode 100644 index 00000000..9f167953 --- /dev/null +++ b/design-docs/src/mdbook/src/build/.gen/compile-env.svg @@ -0,0 +1 @@ +nix{the actual files}binllvm-*clanglldlibbuild dep libssysrootx86_64-unknown-linux-gnudebuglibdpdk-libsrdma-libsdepsreleaselibdpdk-libsrdma-libsdepsx86_64-unknown-linux-musldebuglibdpdk-libsrdma-libsdepsreleaselibdpdk-libsrdma-libsdepscompile-env \ No newline at end of file diff --git a/design-docs/src/mdbook/src/build/.gen/fake-nix.svg b/design-docs/src/mdbook/src/build/.gen/fake-nix.svg new file mode 100644 index 00000000..b0cf167f --- /dev/null +++ b/design-docs/src/mdbook/src/build/.gen/fake-nix.svg @@ -0,0 +1 @@ +/nix...$project-dircompile-envnixbinllvm-*clanglldlibbuild dep libssysrootx86_64-unknown-linux-gnudebuglibdpdk-libsrdma-libsdepsreleaselibdpdk-libsrdma-libsdepsx86_64-unknown-linux-musldebuglibdpdk-libsrdma-libsdepsreleaselibdpdk-libsrdma-libsdeps/ \ No newline at end of file diff --git a/design-docs/src/mdbook/src/build/build-sequence.puml b/design-docs/src/mdbook/src/build/build-sequence.puml new file mode 100644 index 00000000..2e36838a --- /dev/null +++ b/design-docs/src/mdbook/src/build/build-sequence.puml @@ -0,0 +1,33 @@ +@startuml +!pragma toez true +box "hedgehog stuff" #e0eeee +participant dataplane +participant "dpdk-sys" as dpdk_sys +end box +participant nixpkgs +participant "container\nregistry" as container_registry +participant "external\nsource repos" as external +dpdk_sys -> nixpkgs : build instructions plz +nixpkgs -> dpdk_sys : here ya go +dpdk_sys -> external: fetch code +external -> dpdk_sys: here ya go +dpdk_sys -> dpdk_sys : follow build instructions +note left +This is a **long** build +end note +dpdk_sys -> container_registry : push compile-env +container_registry -> dpdk_sys : got it +dataplane -> container_registry : compile-env plz +container_registry -> dataplane : here ya go +dataplane -> dataplane : put compile-env\nin a dir named "compile-env" +dataplane -> dataplane : ""just sterile-build"" +note right +""cargo build"" (called by ""just sterile-build"") now has +access to the many "".a"" files required to compile +and link the dataplane. +It also has a consistent version of LLVM and clang to +work with. +end note +dataplane -> container_registry : push container +container_registry -> dataplane : got it +@enduml diff --git a/design-docs/src/mdbook/src/build/compile-env.md b/design-docs/src/mdbook/src/build/compile-env.md index 1c75ebe3..6936fb5b 100644 --- a/design-docs/src/mdbook/src/build/compile-env.md +++ b/design-docs/src/mdbook/src/build/compile-env.md @@ -17,7 +17,7 @@ This command will use docker to pull the sysroots and compile tools which match > Q: Why use docker here? What's wrong with a tar.zst? > > A: Because of layers! -> The compile env is fairly large (~6GB) and the layers allow for incremental updates. +> The compile env is fairly large (~6GB), and the layers allow for incremental updates. > If you end up downloading multiple compile-env versions, they will likely share many of the same layers and only require a (comparatively) small amount of additional disk space. @@ -30,47 +30,11 @@ The `compile-env` directory basically looks like this:
-```puml -@startwbs -!pragma toez true -* compile-env -** "nix" as nix -*** {the actual files} -** bin -***_ llvm-* -***_ clang -***_ lld -** lib -***_ build dep libs -** sysroot -*** x86_64-unknown-linux-gnu -**** debug -***** lib -******_ dpdk-libs -******_ rdma-libs -******_ deps -**** release -***** lib -******_ dpdk-libs -******_ rdma-libs -******_ deps -*** x86_64-unknown-linux-musl -**** debug -***** lib -******_ dpdk-libs -******_ rdma-libs -******_ deps -**** release -***** lib -******_ dpdk-libs -******_ rdma-libs -******_ deps -@endwbs -``` +![compile-env](.gen/compile-env.svg) > High-level anatomy of the `compile-env`.
-With that we have distributed (to the developer) all the necessary libraries to link against as well as the exact verison of llvm/clang used to link them. +With that we have distributed (to the developer) all the necessary libraries to link against as well as the exact version of llvm/clang used to link them. Unfortunately, for reasons well outside of scope here, the files in `compile-env` are broken symlinks at this point. diff --git a/design-docs/src/mdbook/src/build/compile-env.puml b/design-docs/src/mdbook/src/build/compile-env.puml new file mode 100644 index 00000000..0e252add --- /dev/null +++ b/design-docs/src/mdbook/src/build/compile-env.puml @@ -0,0 +1,35 @@ +@startwbs +!pragma toez true +* compile-env +** "nix" as nix +*** {the actual files} +** bin +***_ llvm-* +***_ clang +***_ lld +** lib +***_ build dep libs +** sysroot +*** x86_64-unknown-linux-gnu +**** debug +***** lib +******_ dpdk-libs +******_ rdma-libs +******_ deps +**** release +***** lib +******_ dpdk-libs +******_ rdma-libs +******_ deps +*** x86_64-unknown-linux-musl +**** debug +***** lib +******_ dpdk-libs +******_ rdma-libs +******_ deps +**** release +***** lib +******_ dpdk-libs +******_ rdma-libs +******_ deps +@endwbs diff --git a/design-docs/src/mdbook/src/build/fake-nix.md b/design-docs/src/mdbook/src/build/fake-nix.md index a1b89a77..3355e158 100644 --- a/design-docs/src/mdbook/src/build/fake-nix.md +++ b/design-docs/src/mdbook/src/build/fake-nix.md @@ -20,47 +20,7 @@ After running `just fake-nix` you get this type of effect.
-```puml -@startwbs -!pragma toez true -* / -**_ "/nix" as nix_sym -** ... -*** $project-dir -**** compile-env -***** "nix" as nix -***** bin -******_ llvm-* -******_ clang -******_ lld -***** lib -******_ build dep libs -***** sysroot -****** x86_64-unknown-linux-gnu -******* debug -******** lib -*********_ dpdk-libs -*********_ rdma-libs -*********_ deps -******* release -******** lib -*********_ dpdk-libs -*********_ rdma-libs -*********_ deps -****** x86_64-unknown-linux-musl -******* debug -******** lib -*********_ dpdk-libs -*********_ rdma-libs -*********_ deps -******* release -******** lib -*********_ dpdk-libs -*********_ rdma-libs -*********_ deps -nix_sym -> nix -@endwbs -``` +![fake-nix](.gen/fake-nix.svg) > High-level anatomy of the `compile-env`.
diff --git a/design-docs/src/mdbook/src/build/fake-nix.puml b/design-docs/src/mdbook/src/build/fake-nix.puml new file mode 100644 index 00000000..28e4cbc6 --- /dev/null +++ b/design-docs/src/mdbook/src/build/fake-nix.puml @@ -0,0 +1,39 @@ +@startwbs +!pragma toez true +* / +**_ "/nix" as nix_sym +** ... +*** $project-dir +**** compile-env +***** "nix" as nix +***** bin +******_ llvm-* +******_ clang +******_ lld +***** lib +******_ build dep libs +***** sysroot +****** x86_64-unknown-linux-gnu +******* debug +******** lib +*********_ dpdk-libs +*********_ rdma-libs +*********_ deps +******* release +******** lib +*********_ dpdk-libs +*********_ rdma-libs +*********_ deps +****** x86_64-unknown-linux-musl +******* debug +******** lib +*********_ dpdk-libs +*********_ rdma-libs +*********_ deps +******* release +******** lib +*********_ dpdk-libs +*********_ rdma-libs +*********_ deps +nix_sym -> nix +@endwbs diff --git a/design-docs/src/mdbook/src/build/index.md b/design-docs/src/mdbook/src/build/index.md index 73e1610b..ae878075 100644 --- a/design-docs/src/mdbook/src/build/index.md +++ b/design-docs/src/mdbook/src/build/index.md @@ -14,58 +14,24 @@ As a result, much effort has gone into creating a simple development experience. ### Non goals: -1. Easy development environment on non-Linux systems. Sorry. DPDK doesn't really like Windows or Mac. -2. Easy development environment on non x86_64 systems. We may change in the future to support ARM. +1. Easy development environment on non-Linux systems. Sorry. DPDK doesn't really like Windows or Mac. +2. Easy development environment on non x86_64 systems. We may change in the future to support ARM. ## How it works The build is split into two main parts. 1. [`dpdk-sys`] - - The job of `dpdk-sys` is to compile a [sysroot](https://www.baeldung.com/linux/sysroot) which `dataplane` can consume.[^um-actually] + + The job of `dpdk-sys` is to compile a [sysroot](https://www.baeldung.com/linux/sysroot) which `dataplane` can consume[^um-actually]. 2. [`dataplane`] The job of `dataplane` is to consume the sysroots and other build tools provided by `dpdk-sys` to actually compile and build the `dataplane` binary we will ship. -
- -```puml -@startuml -!pragma toez true -box "hedgehog stuff" #e0eeee -participant dataplane -participant "dpdk-sys" as dpdk_sys -end box -participant nixpkgs -participant "container\nregistry" as container_registry -participant "external\nsource repos" as external -dpdk_sys -> nixpkgs : build instructions plz -nixpkgs -> dpdk_sys : here ya go -dpdk_sys -> external: fetch code -external -> dpdk_sys: here ya go -dpdk_sys -> dpdk_sys : follow build instructions -note left -This is a **long** build -end note -dpdk_sys -> container_registry : push compile-env -container_registry -> dpdk_sys : got it -dataplane -> container_registry : compile-env plz -container_registry -> dataplane : here ya go -dataplane -> dataplane : put compile-env\nin a dir named "compile-env" -dataplane -> dataplane : ""just sterile-build"" -note right -""cargo build"" (called by ""just sterile-build"") now has -access to the many "".a"" files required to compile -and link the dataplane. -It also has a consistent version of LLVM and clang to -work with. -end note -dataplane -> container_registry : push container -container_registry -> dataplane : got it -@enduml -``` +
+ +![build sequence](./.gen/build-sequence.svg) > Sequence diagram for dpdk-sys / dataplane interaction.
@@ -121,16 +87,16 @@ resulting compile-env image is pulled from the dataplane repository. #### CI - build.yml: - 1. Generate matrix from builds.yml (updated with bump.sh) - 2. `just [...] push` - 1. Builds sysroot - 2. Builds frr, compile-env, doc-env containers - 3. pushes: - - dpdk-sys/compile-env -> compilation environment for dataplane - - dpdk-sys/doc-env -> docs generation - - dpdk-sys/frr -> (unused at the moment) - 4. Generate SBOM - 3. (For PRs: print summary of outdated/vulnerable packages) + 1. Generate matrix from builds.yml (updated with bump.sh) + 2. `just [...] push` + 1. Builds sysroot + 2. Builds frr, compile-env, doc-env containers + 3. pushes: + - dpdk-sys/compile-env -> compilation environment for dataplane + - dpdk-sys/doc-env -> docs generation + - dpdk-sys/frr -> (unused at the moment) + 4. Generate SBOM + 3. (For PRs: print summary of outdated/vulnerable packages) - bump.yml: Update external dependencies @@ -147,8 +113,7 @@ objects, and on the related lookups #### Notes -- Currently a private repository, but there's no reason to keep it private and - it will be published soon +- Currently, a private repository, but there's no reason to keep it private, and it will be published soon - Meant to be a temporary repository; should be merged into dataplane soon - Motivation: Developer couldn't build code from dataplane repository on macOS, so created a separate repository in the meantime for experimenting and @@ -162,9 +127,9 @@ objects, and on the related lookups One parent repository calls the other three as Git submodules: - - - - - - - + - + - + - #### Role @@ -179,6 +144,8 @@ Control plane components - No CI to date [`dpdk-sys`]: + [`dataplane`]: -[^um-actually]: In fact, `dpdk-sys` produces four sysroots. One for each combination of dev/release builds and gnu64 and musl64 builds. + +[^um-actually]: In fact, `dpdk-sys` produces four sysroots. One for each combination of dev/release builds and gnu64 and musl64 builds. diff --git a/design-docs/src/mdbook/src/build/just-cargo-build.md b/design-docs/src/mdbook/src/build/just-cargo-build.md index 2d7d6143..da476da3 100644 --- a/design-docs/src/mdbook/src/build/just-cargo-build.md +++ b/design-docs/src/mdbook/src/build/just-cargo-build.md @@ -24,7 +24,7 @@ just cargo build --release > [!WARNING] > [^release-mode]: Release builds may not work on your development machine! > -> The release build's dependencies are compiled with `-march=x86-64-v4` because we expect to release with a very new processor. +> The release build's dependencies are compiled with `-march=x86-64-v3` because we expect to release with a very new processor. > As a result, getting `SIGILL` on an older chip is no surprise. > We test release builds in CI, but they may not work on your dev box ¯\\\_(ツ)\_\/¯ diff --git a/design-docs/src/mdbook/src/build/prerequisites.md b/design-docs/src/mdbook/src/build/prerequisites.md index d1fa928d..efd9035c 100644 --- a/design-docs/src/mdbook/src/build/prerequisites.md +++ b/design-docs/src/mdbook/src/build/prerequisites.md @@ -2,8 +2,8 @@ You will need the following before we can begin. -- A recent `x86_64` linux machine of some kind required for development. -- Bash (you very likely have this, but if not you will need to install it). +- A recent `x86_64` linux machine of some kind is required for development. +- Bash (you very likely have this, but if not, you will need to install it). - [Docker](https://www.docker.com/) (install through your package manager) - Cargo / Rust (I recommend installing via [`rustup`](https://rustup.rs/)) diff --git a/design-docs/src/mdbook/src/dataplane/.gen/gen/map-of-dpdk.svg b/design-docs/src/mdbook/src/dataplane/.gen/gen/map-of-dpdk.svg new file mode 100644 index 00000000..ca8b5a62 --- /dev/null +++ b/design-docs/src/mdbook/src/dataplane/.gen/gen/map-of-dpdk.svg @@ -0,0 +1 @@ +flow_itemflow_item_templateflow_actionflow_action_templateflow_action_indirectflow_action_indirect_listswitch_domainflow_tableflowhairpin_queuemembufmempoolsocket_ideth_devqueue_rxqueue_txsocket_index \ No newline at end of file diff --git a/design-docs/src/mdbook/src/dataplane/map-of-dpdk.md b/design-docs/src/mdbook/src/dataplane/map-of-dpdk.md index 48182b36..f11091c6 100644 --- a/design-docs/src/mdbook/src/dataplane/map-of-dpdk.md +++ b/design-docs/src/mdbook/src/dataplane/map-of-dpdk.md @@ -3,87 +3,11 @@ This document provides a map of the various abstractions in [DPDK], and how they relate to each other. This is intended to help new developers understand the structure of [DPDK], and how the various components fit together. -
- -```puml -@startuml -!pragma use toez -skinparam linetype ortho -skinparam hyperlinkUnderline false -hide empty description -hide empty members -hide circle - -' the string escape in plantuml is absurd -!$dumb = { "quote": "\"" } - -!unquoted function $link($name, $url) -!return $dumb.quote + "[[" + $url + " " + $name + "]]" + $dumb.quote -!endfunction - -!unquoted function $linked($name) - !return $link($name, $doc_links[$name]) + " as " + $name -!endfunction - -!$doc_links = { - "flow_item": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#pattern-item", - "flow_item_template": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#pattern-templates", - "flow_action": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#actions", - "flow_action_template": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#actions-templates", - "flow_action_indirect": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#action-indirect", - "flow_action_indirect_list": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#action-indirect-list", - "switch_domain": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/switch_representation.html", - "flow_table": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#attribute-group", - "flow": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html", - "hairpin_queue": "https://inbox.dpdk.org/dev/1565703468-55617-1-git-send-email-orika@mellanox.com/", - "membuf": "https://doc.dpdk.org/guides/prog_guide/mbuf_lib.html", - "mempool": "https://doc.dpdk.org/guides/prog_guide/mempool_lib.html", - "socket_id": "#define/socket_id", - "eth_dev": "https://doc.dpdk.org/guides/nics/index.html", - "queue_rx": "https://doc.dpdk.org/guides/prog_guide/ring_lib.html", - "queue_tx": "https://doc.dpdk.org/guides/prog_guide/ring_lib.html", - "socket_index": "#define/socket_index" -} - -!foreach $key in %get_json_keys($doc_links) - entity $linked($key) -!endfor - -' -'' NOTES: -'' technically socket_id }o--o{ ethdev -'' but we aren't using "socket direct" cards so we can ignore this rarely useful subtlety -' -eth_dev }|---o| switch_domain -eth_dev ||--o{ queue_rx -eth_dev ||---o{ queue_tx -eth_dev ||--{ flow_table -flow ||--{ flow_action -flow ||--{ flow_item -flow_action ||--o| flow_action_indirect -flow_action }o--o| flow_action_indirect_list -flow_action_indirect_list |o-o{ flow_action_indirect -flow_table ||---o| flow_action_template -flow_table ||---o| flow_item_template -flow_table ||--o{ flow -mempool ||--o{ membuf -mempool }--o{ queue_rx -queue_rx ||--o| hairpin_queue -queue_tx ||--o| hairpin_queue -socket_id |o--o{ eth_dev -socket_id ||--o{ mempool -socket_index ||-|| socket_id -switch_domain ||--o| hairpin_queue -@enduml -``` - +![.puml](.puml/map-of-dpdk.svg) > The relationships between the various abstractions in DPDK -
## Glossary -
- * `socket_index` A 0-based index into the list of `socket_id`s in the system. @@ -99,9 +23,6 @@ switch_domain ||--o| hairpin_queue See [warning](#socket_id_is_not_socket_index) and [note](#socket_id_bit_rep) for more information. -
- - > [!Warning] > > `socket_id` and `socket_index` are not the same thing. diff --git a/design-docs/src/mdbook/src/dataplane/map-of-dpdk.puml b/design-docs/src/mdbook/src/dataplane/map-of-dpdk.puml new file mode 100644 index 00000000..924b8d96 --- /dev/null +++ b/design-docs/src/mdbook/src/dataplane/map-of-dpdk.puml @@ -0,0 +1,69 @@ +@startuml gen/map-of-dpdk +!pragma use toez +skinparam linetype ortho +skinparam hyperlinkUnderline false +hide empty description +hide empty members +hide circle + +' the string escape in plantuml is absurd +!$dumb = { "quote": "\"" } + +!unquoted function $link($name, $url) +!return $dumb.quote + "[[" + $url + " " + $name + "]]" + $dumb.quote +!endfunction + +!unquoted function $linked($name) + !return $link($name, $doc_links[$name]) + " as " + $name +!endfunction + +!$doc_links = { + "flow_item": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#pattern-item", + "flow_item_template": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#pattern-templates", + "flow_action": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#actions", + "flow_action_template": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#actions-templates", + "flow_action_indirect": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#action-indirect", + "flow_action_indirect_list": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#action-indirect-list", + "switch_domain": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/switch_representation.html", + "flow_table": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html#attribute-group", + "flow": "https://doc.dpdk.org/guides-24.11/prog_guide/ethdev/flow_offload.html", + "hairpin_queue": "https://inbox.dpdk.org/dev/1565703468-55617-1-git-send-email-orika@mellanox.com/", + "membuf": "https://doc.dpdk.org/guides/prog_guide/mbuf_lib.html", + "mempool": "https://doc.dpdk.org/guides/prog_guide/mempool_lib.html", + "socket_id": "#define/socket_id", + "eth_dev": "https://doc.dpdk.org/guides/nics/index.html", + "queue_rx": "https://doc.dpdk.org/guides/prog_guide/ring_lib.html", + "queue_tx": "https://doc.dpdk.org/guides/prog_guide/ring_lib.html", + "socket_index": "#define/socket_index" +} + +!foreach $key in %get_json_keys($doc_links) + entity $linked($key) +!endfor + +' +'' NOTES: +'' technically socket_id }o--o{ ethdev +'' but we aren't using "socket direct" cards so we can ignore this rarely useful subtlety +' +eth_dev }|---o| switch_domain +eth_dev ||--o{ queue_rx +eth_dev ||---o{ queue_tx +eth_dev ||--{ flow_table +flow ||--{ flow_action +flow ||--{ flow_item +flow_action ||--o| flow_action_indirect +flow_action }o--o| flow_action_indirect_list +flow_action_indirect_list |o-o{ flow_action_indirect +flow_table ||---o| flow_action_template +flow_table ||---o| flow_item_template +flow_table ||--o{ flow +mempool ||--o{ membuf +mempool }--o{ queue_rx +queue_rx ||--o| hairpin_queue +queue_tx ||--o| hairpin_queue +socket_id |o--o{ eth_dev +socket_id ||--o{ mempool +socket_index ||-|| socket_id +switch_domain ||--o| hairpin_queue +@enduml diff --git a/design-docs/src/mdbook/src/design/.gen/component-map.svg b/design-docs/src/mdbook/src/design/.gen/component-map.svg new file mode 100644 index 00000000..2afcba90 --- /dev/null +++ b/design-docs/src/mdbook/src/design/.gen/component-map.svg @@ -0,0 +1 @@ +management planecontrol planezebradataplanesister dataplaneGateway AgentConfiguration Storerouting daemonsFRR agentZebraplugincontrol plane interfacemanagement plane interfacedataplane modelrouting managernat managerstate syncinterface managerdataplane workers...state synckernelnicsdpdknetlink socketunix socketrdmanetlink socket \ No newline at end of file diff --git a/design-docs/src/mdbook/src/design/.gen/user-facing-feature-dependencies-internal.svg b/design-docs/src/mdbook/src/design/.gen/user-facing-feature-dependencies-internal.svg new file mode 100644 index 00000000..7b1895de --- /dev/null +++ b/design-docs/src/mdbook/src/design/.gen/user-facing-feature-dependencies-internal.svg @@ -0,0 +1,279 @@ + + + + + + +features + + +Feature map +(major features) + + + +BGP_underlay + +BGP underlay + + + +EVPN_overlay + +EVPN overlay + + + +BGP_underlay->EVPN_overlay + + + + + +VPC_routing + +VPC routing +(aka RIOT) + + + +EVPN_overlay->VPC_routing + + + + + +state_sync + +state sync + + + +EVPN_overlay->state_sync + + + + + +hardware_offloaded_vpc + +VPC route offload + + + +EVPN_overlay->hardware_offloaded_vpc + + + + + +VPC_nat44_66 + +VPC nat44/66 + + + +VPC_routing->VPC_nat44_66 + + + + + +VPC_nat64 + +VPC nat64 + + + +VPC_routing->VPC_nat64 + + + + + +telemetry + +Telemetry/observability + + + +VPC_routing->telemetry + + + + + +rate_limiting + +Rate limiting + + + +VPC_routing->rate_limiting + + + + + +VPC_nat44_66->telemetry + + +weak + + + +VPC_nat64->telemetry + + +weak + + + +rate_limiting->telemetry + + +weak + + + +fault_tolerance + +Fault tolerance + + + +fault_tolerance->VPC_nat44_66 + + + + + +fault_tolerance->VPC_nat64 + + + + + +Management_API + +Management API + + + +all + +* + + + +Management_API->all + + + + + +control_plane_integration + +control plane integration + + + +control_plane_integration->BGP_underlay + + + + + +state_sync->fault_tolerance + + + + + +hardware_offloaded_nat + +offload nat + + + +hardware_offloaded_nat->VPC_nat44_66 + + + + + +hardware_offloaded_nat->VPC_nat64 + + + + + +hardware_offloaded_routing + +Underlay route offload + + + +hardware_offloaded_routing->BGP_underlay + + + + + +hardware_offloaded_vpc->rate_limiting + + + + + +hardware_offloaded_vpc->hardware_offloaded_nat + + + + + +hardware_offloading_basic + +basic offloading + + + +hardware_offloading_basic->hardware_offloaded_routing + + + + + +hardware_offloading_basic->hardware_offloaded_vpc + + + + + +datastore_integration + +datastore integration + + + +datastore_integration->control_plane_integration + + + + + +datastore_integration->hardware_offloaded_routing + + + + + +all->Management_API + + + + + diff --git a/design-docs/src/mdbook/src/design/.gen/user-facing-feature-dependencies.svg b/design-docs/src/mdbook/src/design/.gen/user-facing-feature-dependencies.svg new file mode 100644 index 00000000..814cb246 --- /dev/null +++ b/design-docs/src/mdbook/src/design/.gen/user-facing-feature-dependencies.svg @@ -0,0 +1,160 @@ + + + + + + +features + + + +BGP_underlay + +BGP underlay + + + +EVPN_overlay + +EVPN overlay + + + +BGP_underlay->EVPN_overlay + + + + + +VPC_routing + +VPC routing + + + +EVPN_overlay->VPC_routing + + + + + +Fault_tolerance + +Fault tolerance + + + +EVPN_overlay->Fault_tolerance + + + + + +VPC_nat44_66 + +VPC nat44/66 + + + +VPC_routing->VPC_nat44_66 + + + + + +VPC_nat64 + +VPC nat64 + + + +VPC_routing->VPC_nat64 + + + + + +Telemetry + +Telemetry/observability + + + +VPC_routing->Telemetry + + + + + +rate_limiting + +Rate limiting + + + +VPC_routing->rate_limiting + + + + + +VPC_nat44_66->Telemetry + + +weak + + + +VPC_nat64->Telemetry + + +weak + + + +rate_limiting->Telemetry + + +weak + + + +Fault_tolerance->VPC_nat44_66 + + + + + +Fault_tolerance->VPC_nat64 + + + + + +Management_API + +Management API + + + +all + +* + + + +Management_API->all + + + + + +all->Management_API + + + + + diff --git a/design-docs/src/mdbook/src/design/component-map.puml b/design-docs/src/mdbook/src/design/component-map.puml new file mode 100644 index 00000000..63e5b87e --- /dev/null +++ b/design-docs/src/mdbook/src/design/component-map.puml @@ -0,0 +1,99 @@ +@startuml +skinparam hyperlinkUnderline false +skinparam linetype ortho +!unquoted function $link($name, $url) +!return "[[" + $url + " " + $name + "]]" +!endfunction + + + +!$q = { "uote": "\"" } + +!$doc_links = { + "config_store": { "text": "Configuration Store", "url": "#configuration-store" }, + "gateway_agent": { "text": "Gateway Agent", "url": "#gateway-agent" }, + "frr_agent": { "text": "FRR agent", "url": "#frr-agent" }, + "zebra": { "text": "zebra", "url": "https://docs.frrouting.org/en/latest/zebra.html" }, + "routing_daemons": { "text": "routing daemons", "url": "#routing-daemons" }, + "zebra_plugin": { "text": "Zebra\\nplugin", "url": "#zebra-plugin" }, + "kernel": { "text": "kernel", "url": "https://en.wikipedia.org/wiki/Linux_kernel" }, + "interface_manager": { "text": "interface manager", "url": "#interface-manager" }, + "routing_manager": { "text": "routing manager", "url": "#routing-manager" }, + "dataplane_workers": { "text": "dataplane workers", "url": "#dataplane-workers" }, + "nat_manager": { "text": "nat manager", "url": "#nat-manager" }, + "control_plane_interface": { "text": "control plane interface", "url": "#control-plane-interface" }, + "management_plane_interface": { "text": "management plane interface", "url": "#management-plane-interface" }, + "state_sync": { "text": "state sync", "url": "#state-sync" }, + "dataplane_model": { "text": "dataplane model", "url": "#dataplane-model" }, + "management_plane": { "text": "management plane", "url": "#management-plane" }, + "control_plane": { "text": "control plane", "url": "#control-plane" }, + "dataplane": { "text": "dataplane", "url": "#dataplane" } +} + +!unquoted function $linked($key) + !return $link($doc_links[$key].text, $doc_links[$key].url) +!endfunction + +!unquoted function $r($key) + !return "rectangle " + $key + " as " + $q.uote + $linked($key) + $q.uote +!endfunction + +!unquoted function $db($key) + !return "database " + $key + " as " + $q.uote + $linked($key) + $q.uote +!endfunction + +$r(management_plane) { + $r(gateway_agent) + $db(config_store) +} + +$r(kernel) + +$r(control_plane) { + $r(routing_daemons) + $r(zebra) { + $r(zebra_plugin) + } + $r(frr_agent) +} + +$r(dataplane) { + $r(control_plane_interface) + $r(management_plane_interface) + $db(dataplane_model) + $r(routing_manager) + $r(nat_manager) + $r(state_sync) + $r(interface_manager) + $r(dataplane_workers) +} + +rectangle sister_dataplane as "sister dataplane" { + rectangle rest as "..." + rectangle sister_state_sync as "state sync" +} + +rectangle nics + +control_plane_interface -- dataplane_model +dataplane_workers <--> nics : [[ https://www.dpdk.org/ dpdk ]] +frr_agent <--> routing_daemons +frr_agent <--> zebra +gateway_agent -- frr_agent +gateway_agent -- management_plane_interface +config_store -- gateway_agent +interface_manager -- dataplane_model +interface_manager <--> kernel : [[ https://man7.org/linux/man-pages/man7/netlink.7.html netlink socket ]] +dataplane_model - state_sync +dataplane_model <--> nat_manager +dataplane_model <--> routing_manager +management_plane_interface -- dataplane_model +nat_manager <--> dataplane_workers +zebra_plugin --- control_plane_interface : [[ https://en.wikipedia.org/wiki/Unix_domain_socket unix socket ]] +routing_daemons <-> zebra +routing_manager <--> dataplane_workers +state_sync <-> sister_state_sync : [[ https://en.wikipedia.org/wiki/Remote_direct_memory_access rdma]] +zebra <-> kernel : [[ https://man7.org/linux/man-pages/man7/netlink.7.html netlink socket ]] + +@enduml diff --git a/design-docs/src/mdbook/src/design/index.md b/design-docs/src/mdbook/src/design/index.md index 658f1162..7936467c 100644 --- a/design-docs/src/mdbook/src/design/index.md +++ b/design-docs/src/mdbook/src/design/index.md @@ -1,111 +1,9 @@ -# High level design +# High-level design
-```puml -@startuml -skinparam hyperlinkUnderline false -skinparam linetype ortho -!unquoted function $link($name, $url) -!return "[[" + $url + " " + $name + "]]" -!endfunction - - - -!$q = { "uote": "\"" } - -!$doc_links = { - "config_store": { "text": "Configuration Store", "url": "#configuration-store" }, - "gateway_agent": { "text": "Gateway Agent", "url": "#gateway-agent" }, - "frr_agent": { "text": "FRR agent", "url": "#frr-agent" }, - "zebra": { "text": "zebra", "url": "https://docs.frrouting.org/en/latest/zebra.html" }, - "routing_daemons": { "text": "routing daemons", "url": "#routing-daemons" }, - "zebra_plugin": { "text": "Zebra\\nplugin", "url": "#zebra-plugin" }, - "kernel": { "text": "kernel", "url": "https://en.wikipedia.org/wiki/Linux_kernel" }, - "interface_manager": { "text": "interface manager", "url": "#interface-manager" }, - "routing_manager": { "text": "routing manager", "url": "#routing-manager" }, - "dataplane_workers": { "text": "dataplane workers", "url": "#dataplane-workers" }, - "nat_manager": { "text": "nat manager", "url": "#nat-manager" }, - "control_plane_interface": { "text": "control plane interface", "url": "#control-plane-interface" }, - "management_plane_interface": { "text": "management plane interface", "url": "#management-plane-interface" }, - "state_sync": { "text": "state sync", "url": "#state-sync" }, - "dataplane_model": { "text": "dataplane model", "url": "#dataplane-model" }, - "management_plane": { "text": "management plane", "url": "#management-plane" }, - "control_plane": { "text": "control plane", "url": "#control-plane" }, - "dataplane": { "text": "dataplane", "url": "#dataplane" } -} - -!unquoted function $linked($key) - !return $link($doc_links[$key].text, $doc_links[$key].url) -!endfunction - -!unquoted function $r($key) - !return "rectangle " + $key + " as " + $q.uote + $linked($key) + $q.uote -!endfunction - -!unquoted function $db($key) - !return "database " + $key + " as " + $q.uote + $linked($key) + $q.uote -!endfunction - -$r(management_plane) { - $r(gateway_agent) - $db(config_store) -} - -$r(kernel) - -$r(control_plane) { - $r(routing_daemons) - $r(zebra) { - $r(zebra_plugin) - } - $r(frr_agent) -} - -$r(dataplane) { - $r(control_plane_interface) - $r(management_plane_interface) - $db(dataplane_model) - $r(routing_manager) - $r(nat_manager) - $r(state_sync) - $r(interface_manager) - $r(dataplane_workers) -} - -rectangle sister_dataplane as "sister dataplane" { - rectangle rest as "..." - rectangle sister_state_sync as "state sync" -} - -rectangle nics - -control_plane_interface -- dataplane_model -dataplane_workers <--> nics : [[ https://www.dpdk.org/ dpdk ]] -frr_agent <--> routing_daemons -frr_agent <--> zebra -gateway_agent -- frr_agent -gateway_agent -- management_plane_interface -config_store -- gateway_agent -interface_manager -- dataplane_model -interface_manager <--> kernel : [[ https://man7.org/linux/man-pages/man7/netlink.7.html netlink socket ]] -dataplane_model - state_sync -dataplane_model <--> nat_manager -dataplane_model <--> routing_manager -management_plane_interface -- dataplane_model -nat_manager <--> dataplane_workers -zebra_plugin --- control_plane_interface : [[ https://en.wikipedia.org/wiki/Unix_domain_socket unix socket ]] -routing_daemons <-> zebra -routing_manager <--> dataplane_workers -state_sync <-> sister_state_sync : [[ https://en.wikipedia.org/wiki/Remote_direct_memory_access rdma]] -zebra <-> kernel : [[ https://man7.org/linux/man-pages/man7/netlink.7.html netlink socket ]] - -@enduml -``` - +![component-map](.gen/component-map.svg) > Map of the relationships between planned dataplane components -
diff --git a/design-docs/src/mdbook/src/design/mvp.md b/design-docs/src/mdbook/src/design/mvp.md index 40cf84b9..6a9d1f63 100644 --- a/design-docs/src/mdbook/src/design/mvp.md +++ b/design-docs/src/mdbook/src/design/mvp.md @@ -16,112 +16,18 @@ At a very high level, these are the _user facing_ features that we require to re
-```plantuml -@startdot -digraph features { -labelloc=t -graph [ranksep=0.6] - -node[shape="rect"] -BGP_underlay [ label="BGP underlay", style=filled, color="lightblue"] -EVPN_overlay [ label="EVPN overlay", style=filled, color="lightblue"] -VPC_routing [ label="VPC routing", style=filled, color="lightblue"] -VPC_nat44_66 [ label="VPC nat44/66", style=filled, color="lightblue"] -VPC_nat64 [ label="VPC nat64", style=filled, color="lightblue"] -Telemetry [ label="Telemetry/observability", style=filled, color="lightblue"] -rate_limiting [ label="Rate limiting", style=filled, color="lightblue"] -Fault_tolerance [ label="Fault tolerance", style=filled, color="lightblue"] -Management_API [label="Management API", style=filled, color="lightblue"] -all [label="*"] -all -> Management_API -Management_API -> all - -BGP_underlay -> EVPN_overlay; -EVPN_overlay -> VPC_routing; -VPC_routing -> VPC_nat44_66; -VPC_routing -> VPC_nat64; -VPC_routing -> rate_limiting; -EVPN_overlay -> Fault_tolerance; -Fault_tolerance -> VPC_nat64; -Fault_tolerance -> VPC_nat44_66; -VPC_routing -> Telemetry; -VPC_nat44_66 -> Telemetry [xlabel="weak"]; -VPC_nat64 -> Telemetry [xlabel="weak"]; -rate_limiting -> Telemetry [xlabel="weak"]; -} -@enddot -``` - +![user facing feature dependencies](.gen/user-facing-feature-dependencies.svg) > A graph of the functional dependencies between the required _user facing_ features. > Each node on the graph represents a feature. > No feature can be _completed_ without all of the other features which point to it. -
-```plantuml -@startdot -digraph features { - labelloc=t - node [shape="box"] - graph [ranksep=0.8] - label=< Feature map
(major features)
> - - BGP_underlay [ label="BGP underlay", style=filled, color="lightblue" ] - EVPN_overlay [ label="EVPN overlay", style=filled, color="lightblue" ] - VPC_routing [ label="VPC routing\n(aka RIOT)", style=filled, color="lightblue" ] - VPC_nat44_66 [ label="VPC nat44/66", style=filled, color="lightblue" ] - VPC_nat64 [ label="VPC nat64", style=filled, color="lightblue" ] - telemetry [ label="Telemetry/observability", style=filled, color="lightblue" ] - rate_limiting [ label="Rate limiting", style=filled, color="lightblue" ] - fault_tolerance [ label="Fault tolerance", style=filled, color="lightblue" ] - Management_API [ label="Management API", style=filled, color="lightblue" ] - - control_plane_integration [ label="control plane integration"] - state_sync [ label="state sync" ] - hardware_offloaded_nat [ label="offload nat" ] - hardware_offloaded_routing [ label="Underlay route offload" ] - hardware_offloaded_vpc [ label="VPC route offload" ] - hardware_offloading_basic [ label="basic offloading" ] - datastore_integration [ label="datastore integration" ] - - all [label="*"] - Management_API -> all - all -> Management_API - - datastore_integration -> control_plane_integration - datastore_integration -> hardware_offloaded_routing - hardware_offloading_basic -> hardware_offloaded_routing - hardware_offloaded_routing -> BGP_underlay - fault_tolerance -> VPC_nat44_66 - fault_tolerance -> VPC_nat64 - BGP_underlay -> EVPN_overlay - EVPN_overlay -> VPC_routing - EVPN_overlay -> state_sync - EVPN_overlay -> hardware_offloaded_vpc - hardware_offloaded_nat -> VPC_nat44_66 - hardware_offloaded_nat -> VPC_nat64 - VPC_nat44_66 -> telemetry [xlabel="weak"] - VPC_nat64 -> telemetry [xlabel="weak"] - VPC_routing -> telemetry - VPC_routing -> VPC_nat44_66 - VPC_routing -> VPC_nat64 - VPC_routing -> rate_limiting - control_plane_integration -> BGP_underlay - state_sync -> fault_tolerance - hardware_offloaded_vpc -> hardware_offloaded_nat - hardware_offloaded_vpc -> rate_limiting - hardware_offloading_basic -> hardware_offloaded_vpc - rate_limiting -> telemetry [xlabel="weak"] -} -@enddot -``` - +![user facing feature dependencies (with internal)](.gen/user-facing-feature-dependencies-internal.svg) > Here is a _very_ high-level graph of the functional dependencies between the required features. > Each node on the graph represents a feature. > No feature can be _completed_ without all the other features which point to it. > Features shown in blue are user facing. > All other features represent internal implementation concerns. -
diff --git a/design-docs/src/mdbook/src/design/user-facing-feature-dependencies-internal.puml b/design-docs/src/mdbook/src/design/user-facing-feature-dependencies-internal.puml new file mode 100644 index 00000000..3b615ae2 --- /dev/null +++ b/design-docs/src/mdbook/src/design/user-facing-feature-dependencies-internal.puml @@ -0,0 +1,55 @@ +@startdot +digraph features { + labelloc=t + node [shape="box"] + graph [ranksep=0.8] + label=< Feature map
(major features)
> + + BGP_underlay [ label="BGP underlay", style=filled, color="lightblue" ] + EVPN_overlay [ label="EVPN overlay", style=filled, color="lightblue" ] + VPC_routing [ label="VPC routing\n(aka RIOT)", style=filled, color="lightblue" ] + VPC_nat44_66 [ label="VPC nat44/66", style=filled, color="lightblue" ] + VPC_nat64 [ label="VPC nat64", style=filled, color="lightblue" ] + telemetry [ label="Telemetry/observability", style=filled, color="lightblue" ] + rate_limiting [ label="Rate limiting", style=filled, color="lightblue" ] + fault_tolerance [ label="Fault tolerance", style=filled, color="lightblue" ] + Management_API [ label="Management API", style=filled, color="lightblue" ] + + control_plane_integration [ label="control plane integration"] + state_sync [ label="state sync" ] + hardware_offloaded_nat [ label="offload nat" ] + hardware_offloaded_routing [ label="Underlay route offload" ] + hardware_offloaded_vpc [ label="VPC route offload" ] + hardware_offloading_basic [ label="basic offloading" ] + datastore_integration [ label="datastore integration" ] + + all [label="*"] + Management_API -> all + all -> Management_API + + datastore_integration -> control_plane_integration + datastore_integration -> hardware_offloaded_routing + hardware_offloading_basic -> hardware_offloaded_routing + hardware_offloaded_routing -> BGP_underlay + fault_tolerance -> VPC_nat44_66 + fault_tolerance -> VPC_nat64 + BGP_underlay -> EVPN_overlay + EVPN_overlay -> VPC_routing + EVPN_overlay -> state_sync + EVPN_overlay -> hardware_offloaded_vpc + hardware_offloaded_nat -> VPC_nat44_66 + hardware_offloaded_nat -> VPC_nat64 + VPC_nat44_66 -> telemetry [xlabel="weak"] + VPC_nat64 -> telemetry [xlabel="weak"] + VPC_routing -> telemetry + VPC_routing -> VPC_nat44_66 + VPC_routing -> VPC_nat64 + VPC_routing -> rate_limiting + control_plane_integration -> BGP_underlay + state_sync -> fault_tolerance + hardware_offloaded_vpc -> hardware_offloaded_nat + hardware_offloaded_vpc -> rate_limiting + hardware_offloading_basic -> hardware_offloaded_vpc + rate_limiting -> telemetry [xlabel="weak"] +} +@enddot diff --git a/design-docs/src/mdbook/src/design/user-facing-feature-dependencies.puml b/design-docs/src/mdbook/src/design/user-facing-feature-dependencies.puml new file mode 100644 index 00000000..da919e63 --- /dev/null +++ b/design-docs/src/mdbook/src/design/user-facing-feature-dependencies.puml @@ -0,0 +1,33 @@ +@startdot +digraph features { +labelloc=t +graph [ranksep=0.6] + +node[shape="rect"] +BGP_underlay [ label="BGP underlay", style=filled, color="lightblue"] +EVPN_overlay [ label="EVPN overlay", style=filled, color="lightblue"] +VPC_routing [ label="VPC routing", style=filled, color="lightblue"] +VPC_nat44_66 [ label="VPC nat44/66", style=filled, color="lightblue"] +VPC_nat64 [ label="VPC nat64", style=filled, color="lightblue"] +Telemetry [ label="Telemetry/observability", style=filled, color="lightblue"] +rate_limiting [ label="Rate limiting", style=filled, color="lightblue"] +Fault_tolerance [ label="Fault tolerance", style=filled, color="lightblue"] +Management_API [label="Management API", style=filled, color="lightblue"] +all [label="*"] +all -> Management_API +Management_API -> all + +BGP_underlay -> EVPN_overlay; +EVPN_overlay -> VPC_routing; +VPC_routing -> VPC_nat44_66; +VPC_routing -> VPC_nat64; +VPC_routing -> rate_limiting; +EVPN_overlay -> Fault_tolerance; +Fault_tolerance -> VPC_nat64; +Fault_tolerance -> VPC_nat44_66; +VPC_routing -> Telemetry; +VPC_nat44_66 -> Telemetry [xlabel="weak"]; +VPC_nat64 -> Telemetry [xlabel="weak"]; +rate_limiting -> Telemetry [xlabel="weak"]; +} +@enddot diff --git a/net/src/encap/test.md b/net/src/encap/test.md new file mode 100644 index 00000000..8f3e1741 --- /dev/null +++ b/net/src/encap/test.md @@ -0,0 +1,13 @@ +
+ +![puml](alice-bob.puml.svg) + +
puml + +```plantuml +@startuml{alice-bob} +Alice -> Bob +@enduml +``` +
+
diff --git a/net/src/packet.rs b/net/src/packet.rs index 3b3b117e..498c5381 100644 --- a/net/src/packet.rs +++ b/net/src/packet.rs @@ -25,6 +25,7 @@ use tracing::debug; const MAX_VLANS: usize = 4; const MAX_NET_EXTENSIONS: usize = 2; +// TODO: remove `pub` from all fields #[derive(Debug, Clone, PartialEq, Eq)] pub struct Packet { pub eth: Eth, @@ -310,12 +311,7 @@ impl Packet { } let old_eth_type = self.eth.ether_type(); self.eth.set_ether_type(EthType::VLAN); - let new_vlan_header = Vlan::new( - vid, - old_eth_type, - Pcp::default(), - false, - ); + let new_vlan_header = Vlan::new(vid, old_eth_type, Pcp::default(), false); self.vlan.push(new_vlan_header); Ok(()) } @@ -337,7 +333,6 @@ impl Packet { } } } - } #[cfg(any(test, feature = "arbitrary"))] @@ -345,10 +340,12 @@ mod contract { use crate::eth::ethertype::EthType; use crate::eth::mac::{DestinationMac, SourceMac}; use crate::eth::Eth; - use crate::packet::Header; + use crate::ipv4::Ipv4; + use crate::packet::{Header, Net, Packet, Transport, MAX_VLANS}; use crate::parse::DeParse; use arbitrary::{Arbitrary, Unstructured}; use arrayvec::ArrayVec; + use etherparse::IpNumber; #[repr(transparent)] pub struct Noise(T); @@ -373,6 +370,38 @@ mod contract { let next_eth_type = *u.choose(&[EthType::IPV4, EthType::IPV6])?; let eth = Eth::new(source_mac.inner(), dest_mac.inner(), next_eth_type) .unwrap_or_else(|e| unreachable!("{e:?}")); + let mut packet = Packet::new(eth); + + let num_vlans = u.int_in_range(0..=MAX_VLANS)?; + for _ in 0..num_vlans { + // TODO: allow adjusting pcp and dei of pushed vlan headers + packet + .push_vlan(u.arbitrary()?) + .unwrap_or_else(|e| unreachable!("{e:?}")); + } + + match next_eth_type { + EthType::IPV4 => { + let net_layer: Ipv4 = u.arbitrary()?; + let next_proto = net_layer.protocol(); + packet.net = Some(Net::Ipv4(net_layer)); + match next_proto { + IpNumber::TCP => { + packet.transport = Some(Transport::Tcp(u.arbitrary()?)); + } + IpNumber::UDP => { + packet.transport = Some(Transport::Udp(u.arbitrary()?)); + } + _ => {} + } + let transport_proto = + *u.choose(&[IpNumber::TCP, IpNumber::UDP, IpNumber::ICMP])?; + } + EthType::IPV6 => { + packet.net = Some(Net::Ipv6(u.arbitrary()?)); + } + _ => unreachable!(), + } todo!() }