support nlmon link type#26
Conversation
Introduce nlmon (Netlink monitor) interface support for both creation and query. Usage: ip link add name NAME type nlmon Integration test cases included. Signed-off-by: Gris Ge <cnfourt@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request adds support for the nlmon link type, including the necessary logic in LinkAddCommand and a new test suite in src/ip/link/tests/nlmon.rs. The reviewer suggested improving the with_nlmon_iface test helper by using std::panic::resume_unwind to preserve panic information during test failures and making the interface cleanup step more robust.
| let result = std::panic::catch_unwind(|| { | ||
| test(); | ||
| }); | ||
|
|
||
| // clean up | ||
| exec_cmd(&["ip", "link", "del", name]); | ||
| assert!(result.is_ok()) |
There was a problem hiding this comment.
The current implementation of with_nlmon_iface uses assert!(result.is_ok()) after catching a panic. This is suboptimal because it discards the original panic message and stack trace, making it difficult to debug test failures. Using std::panic::resume_unwind is preferred as it preserves the original panic information. Additionally, the cleanup step should ideally be robust against failures (e.g., if the interface was already removed by the test itself).
let result = std::panic::catch_unwind(test);
// clean up
let _ = exec_cmd(&["ip", "link", "del", name]);
if let Err(e) = result {
std::panic::resume_unwind(e);
}When creating VLAN parent dummy interface without `address` property defined, systemd/udevd will generate random MAC address and change it, hence we have race problem during creation and query. Fixed by explicitly set MAC address when creating VLAN parent interface in tests. Signed-off-by: Gris Ge <cnfourt@gmail.com>
Introduce nlmon (Netlink monitor) interface support for both creation
and query. Usage:
ip link add name NAME type nlmon
Integration test cases included.