This repository has been archived by the owner on Oct 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some information of `ethtool <nic_name>` is from link mode, like link speed, duplex mode and etc. Example code and integration test case included. Signed-off-by: Gris Ge <cnfourt@gmail.com>
- Loading branch information
Showing
12 changed files
with
418 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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,29 @@ | ||
use ethtool; | ||
use futures::stream::TryStreamExt; | ||
use tokio; | ||
|
||
// Once we find a way to load netsimdev kernel module in CI, we can convert this | ||
// to a test | ||
fn main() { | ||
let rt = tokio::runtime::Builder::new_current_thread() | ||
.enable_io() | ||
.build() | ||
.unwrap(); | ||
rt.block_on(get_link_mode(None)); | ||
} | ||
|
||
async fn get_link_mode(iface_name: Option<&str>) { | ||
let (connection, mut handle, _) = ethtool::new_connection().unwrap(); | ||
tokio::spawn(connection); | ||
|
||
let mut link_mode_handle = handle.link_mode().get(iface_name).execute().await; | ||
|
||
let mut msgs = Vec::new(); | ||
while let Some(msg) = link_mode_handle.try_next().await.unwrap() { | ||
msgs.push(msg); | ||
} | ||
assert!(msgs.len() > 0); | ||
for msg in msgs { | ||
println!("{:?}", msg); | ||
} | ||
} |
This file contains 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 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 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 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.