Conversation
Summary of ChangesHello @romainreignier, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces the capability to create and manage virtual CAN interfaces, expanding the library's network interface management features. It includes the necessary data structures and builder patterns for Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for vxcan interfaces, modeled after the existing veth implementation. The changes include updating the netlink-packet-route dependency, which brings in some related API improvements, and adding the LinkVxcan type with a corresponding example. The implementation is solid. I have one suggestion for the example code to improve its efficiency and fix a small typo.
examples/create_vxcan.rs
Outdated
| async fn set_link_up(handle: &Handle, name: String) -> Result<(), Error> { | ||
| let mut links = handle.link().get().match_name(name.clone()).execute(); | ||
| if let Some(link) = links.try_next().await? { | ||
| handle | ||
| .link() | ||
| .set(LinkUnspec::new_with_index(link.header.index).up().build()) | ||
| .execute() | ||
| .await? | ||
| } else { | ||
| println!("no link link {name} found"); | ||
| } | ||
| Ok(()) | ||
| } |
There was a problem hiding this comment.
The set_link_up function takes name by value (String), which forces callers to clone the string. It then clones the string again internally. It would be more efficient to take a string slice (&str) to avoid these clones. This would require updating the call sites on lines 21 and 25 to pass references (e.g., set_link_up(&handle, &link_name)). Also, there is a typo in the println! message.
| async fn set_link_up(handle: &Handle, name: String) -> Result<(), Error> { | |
| let mut links = handle.link().get().match_name(name.clone()).execute(); | |
| if let Some(link) = links.try_next().await? { | |
| handle | |
| .link() | |
| .set(LinkUnspec::new_with_index(link.header.index).up().build()) | |
| .execute() | |
| .await? | |
| } else { | |
| println!("no link link {name} found"); | |
| } | |
| Ok(()) | |
| } | |
| async fn set_link_up(handle: &Handle, name: &str) -> Result<(), Error> { | |
| let mut links = handle.link().get().match_name(name.to_string()).execute(); | |
| if let Some(link) = links.try_next().await? { | |
| handle | |
| .link() | |
| .set(LinkUnspec::new_with_index(link.header.index).up().build()) | |
| .execute() | |
| .await? | |
| } else { | |
| println!("no link {name} found"); | |
| } | |
| Ok(()) | |
| } |
Signed-off-by: Romain Reignier <romain.reignier@exail.com>
fa2960e to
c227c9c
Compare
Add vxcan based on veth implementation.
Needs a release of netlink-packet-route 0.29.0 after rust-netlink/netlink-packet-route#234 is merged.
So I did a separate commit to update the netlink-packet-route API to current main branch.