Skip to content

Add support of nlmon#165

Merged
cathay4t merged 1 commit into
rust-netlink:mainfrom
cathay4t:nlmon
May 24, 2026
Merged

Add support of nlmon#165
cathay4t merged 1 commit into
rust-netlink:mainfrom
cathay4t:nlmon

Conversation

@cathay4t
Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Gris Ge <cnfourt@gmail.com>
@cathay4t cathay4t merged commit 9b4536a into rust-netlink:main May 24, 2026
6 checks passed
@cathay4t cathay4t deleted the nlmon branch May 24, 2026 12:57
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for nlmon (Netlink monitoring) interfaces by adding the LinkNlmon struct and its builder implementation. The reviewer suggested including unit tests in src/link/test.rs to verify the lifecycle of nlmon interfaces, ensuring that the kernel correctly handles the creation and deletion of this interface type.

Comment thread src/link/nlmon.rs
Comment on lines +1 to +38
// SPDX-License-Identifier: MIT

use crate::{link::LinkMessageBuilder, packet_route::link::InfoKind};

/// Represent nlmon interface.
/// Example code on creating a nlmon interface
/// ```no_run
/// use rtnetlink::{new_connection, LinkNlmon};
/// #[tokio::main]
/// async fn main() -> Result<(), String> {
/// let (connection, handle, _) = new_connection().unwrap();
/// tokio::spawn(connection);
///
/// handle
/// .link()
/// .add(LinkNlmon::new("nl0").build())
/// .execute()
/// .await
/// .map_err(|e| format!("{e}"))
/// }
/// ```
#[derive(Debug)]
pub struct LinkNlmon;

impl LinkNlmon {
/// Equal to `LinkMessageBuilder::<LinkNlmon>::new()`
pub fn new(name: &str) -> LinkMessageBuilder<Self> {
LinkMessageBuilder::<LinkNlmon>::new(name)
}
}

impl LinkMessageBuilder<LinkNlmon> {
/// Create [LinkMessageBuilder] for nlmon interface type
pub fn new(name: &str) -> Self {
LinkMessageBuilder::<LinkNlmon>::new_with_info_kind(InfoKind::Nlmon)
.name(name.to_string())
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While the implementation of LinkNlmon correctly follows the library's patterns, it is missing corresponding unit tests in src/link/test.rs. Adding a test case (e.g., create_get_delete_nlmon) would ensure that the InfoKind::Nlmon variant is correctly handled and that the kernel accepts the interface creation request, similar to existing tests for LinkNetkit or LinkVrf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant