-
Notifications
You must be signed in to change notification settings - Fork 9
more cli extensions #1356
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
Merged
Merged
more cli extensions #1356
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f7f9093
feat(cli): reorder command codes
Fredi-raspall a23af07
feat(flow-filter): add heading to display
Fredi-raspall b568f50
feat(cli): add show tech command
Fredi-raspall f1f3df4
feat(routing): handle show tech cli command
Fredi-raspall 665d57d
feat(tracectl): use common utils for Display
Fredi-raspall 2c4745b
feat(routing): use common utils for Display
Fredi-raspall 97596d1
feat(net,flow-entry): improve Display of flows
Fredi-raspall 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,80 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright Open Network Fabric Authors | ||
|
|
||
| //! Flow keys | ||
|
|
||
| use super::flow_info::{FlowInfo, FlowInfoLocked}; | ||
| use super::flow_key::{FlowKey, FlowKeyData}; | ||
|
|
||
| use std::fmt::Display; | ||
| use std::time::Instant; | ||
|
|
||
| impl Display for FlowKeyData { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| if let Some(vpcd) = self.src_vpcd() { | ||
| write!(f, "from: {vpcd},")?; | ||
| } | ||
| let ports = self.ports(); | ||
| let proto = self.proto(); | ||
| let src_ip = self.src_ip(); | ||
| let dst_ip = self.dst_ip(); | ||
| if let Some((src_port, dst_port)) = ports { | ||
| write!(f, "{src_ip}:{src_port} -> {dst_ip}:{dst_port} {proto}")?; | ||
| } else { | ||
| write!(f, "{src_ip} -> {dst_ip} {proto}")?; | ||
| } | ||
| if let Some(id) = self.icmp_id() { | ||
| write!(f, " id:{id}")?; | ||
| } | ||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| impl Display for FlowKey { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| match self { | ||
| FlowKey::Unidirectional(data) => write!(f, "{data}"), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl Display for FlowInfoLocked { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| if let Some(data) = &self.dst_vpcd { | ||
| writeln!(f, " dst-vpcd:{data}")?; | ||
| } | ||
| if let Some(data) = &self.port_fw_state { | ||
| writeln!(f, " port-forwarding:{data}")?; | ||
| } | ||
| if let Some(data) = &self.nat_state { | ||
| writeln!(f, " nat-state:{data}")?; | ||
| } | ||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| impl Display for FlowInfo { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| let expires_at = self.expires_at(); | ||
| let expires_in = expires_at.saturating_duration_since(Instant::now()); | ||
| let genid = self.genid(); | ||
|
|
||
| if let Ok(info) = self.locked.try_read() { | ||
| write!(f, "{info}")?; | ||
| } else { | ||
| write!(f, "could not lock!")?; | ||
| } | ||
| let has_related = self | ||
| .related | ||
| .as_ref() | ||
| .and_then(std::sync::Weak::upgrade) | ||
| .map_or("no", |_| "yes"); | ||
|
|
||
| writeln!( | ||
| f, | ||
| " status: {:?}, expires in {}s, related: {has_related}, genid: {genid}", | ||
| self.status(), | ||
| expires_in.as_secs(), | ||
| ) | ||
| } | ||
| } | ||
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.
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.