-
Notifications
You must be signed in to change notification settings - Fork 5
[ddmd] add --no-state-machine flag for test fixtures and Linux build #729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zeeshanlakhani
wants to merge
2
commits into
main
Choose a base branch
from
zl/ddmd-no-state-machine
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| //! This module implements the ddm router discovery mechanisms. These | ||
| //! mechanisms are responsible for three primary things | ||
| //! | ||
| //! 1. Soliciting other routers through UDP/IPv6 link local multicast. | ||
| //! 2. Sending out router advertisements in response to solicitations. | ||
| //! 3. Continuously soliciting link-local at a configurable rate to keep | ||
| //! sessions alive and sending out notifications when peering arrangements | ||
| //! expire due to not getting a solicitation response within a configurable | ||
| //! time threshold. | ||
| //! | ||
| //! [`Version`] and [`DiscoveryError`] are platform-agnostic and stay in this | ||
| //! module so the state machine type definitions in [`crate::sm`] continue to | ||
| //! compile when the routing runtime is gated out (e.g. Linux test fixtures | ||
| //! running ddmd with `--no-state-machine`). The runtime helpers that drive | ||
| //! the protocol over UDPv6 sockets live in the [`runtime`] submodule and | ||
| //! are illumos-only. | ||
| //! | ||
| //! ## Protocol | ||
| //! | ||
| //! The general sequence of events is depicted in the following diagram. | ||
| //! | ||
| //! *==========* *==========* | ||
| //! | violin | | piano | | ||
| //! *==========* *==========* | ||
| //! | | | ||
| //! | solicit(ff02::dd) | | ||
| //! |-------------------------->| | ||
| //! | advertise(fe80::47) | | ||
| //! |<--------------------------| | ||
| //! | | | ||
| //! | ... | | ||
| //! | | | ||
| //! | | | ||
| //! | solicit(ff02::dd) | | ||
| //! |-------------------------->| | ||
| //! | advertise(fe80::47) | | ||
| //! |<--------------------------| | ||
| //! | | | ||
| //! | solicit(ff02::dd) | | ||
| //! |-------------------------->| | ||
| //! | solicit(ff02::dd) | | ||
| //! |-------------------------->| | ||
| //! | solicit(ff02::dd) | | ||
| //! |-------------------------->| | ||
| //! | | | ||
| //! +----| | | ||
| //! expire | | | | ||
| //! piano | | | | ||
| //! +--->| | | ||
| //! | ||
| //! This shows violin sending a link-local multicast solicitation over the wire. | ||
| //! That solicitation is received by piano and piano respons with an | ||
| //! advertisement to violin's link-local unicast address. From this point | ||
| //! forward solicitations and responses continue. Each time violin gets a | ||
| //! response from piano, it updates the last seen timestamp for piano. If at | ||
| //! some point piano stops responding to solicitations and the last seen | ||
| //! timestamp is older than the expiration threshold, violin will expire the | ||
| //! session and send out a notification to the ddm state machine that started | ||
| //! it. Violin will continue to send out solicitations in case piano comes back. | ||
| //! | ||
| //! In the event that piano undergoes renumbering e.g. it's link-local unicast | ||
| //! address changes, this will be detected by violin and an advertisement update | ||
| //! will be sent to the ddm state machine through the notification channel | ||
| //! provided to the discovery subsystem. | ||
| //! | ||
| //! The DDM discovery multicast address is ff02::dd. Discovery packets are sent | ||
| //! over UDP using port number 0xddd. | ||
| //! | ||
| //! ## Packets | ||
| //! | ||
| //! Discovery packets follow a very simple format | ||
| //! | ||
| //! 1 2 3 | ||
| //! 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | ||
| //! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
| //! | version |S A r r r r r r| router kind | hostname len | | ||
| //! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
| //! | hostname : | ||
| //! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
| //! : .... : | ||
| //! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
| //! | ||
| //! The first byte indicates the version. The only valid version at present is | ||
| //! version 1. The second byte is a flags bitfield. The first position `S` | ||
| //! indicates a solicitation. The second position `A` indicates and | ||
| //! advertisement. All other positions are reserved for future use. The third | ||
| //! byte indicates the kind of router. Current values are 0 for a server router | ||
| //! and 1 for a transit routers. The fourth byte is a hostname length followed | ||
| //! directly by a hostname of up to 255 bytes in length. | ||
|
|
||
| use thiserror::Error; | ||
|
|
||
| #[cfg(all(feature = "illumos", target_os = "illumos"))] | ||
| mod runtime; | ||
|
|
||
| #[cfg(all(feature = "illumos", target_os = "illumos"))] | ||
| pub(crate) use runtime::handler; | ||
|
|
||
| #[derive(Debug, Copy, Clone)] | ||
| #[repr(u8)] | ||
| pub enum Version { | ||
| V2 = 2, | ||
| V3 = 3, | ||
| } | ||
|
|
||
| #[derive(Error, Debug)] | ||
| pub enum DiscoveryError { | ||
| #[error("io error: {0}")] | ||
| Io(#[from] std::io::Error), | ||
|
|
||
| #[error("serialization error: {0}")] | ||
| Serialization(#[from] ispf::Error), | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.