26 releases (breaking)

0.19.0 Jan 31, 2024
0.18.1 Dec 5, 2023
0.17.1 Aug 30, 2023
0.17.0 Jul 10, 2023
0.1.0 Dec 20, 2019

#26 in Network programming

Download history 76677/week @ 2023-12-06 68462/week @ 2023-12-13 49711/week @ 2023-12-20 37937/week @ 2023-12-27 63440/week @ 2024-01-03 70337/week @ 2024-01-10 76348/week @ 2024-01-17 77484/week @ 2024-01-24 77383/week @ 2024-01-31 80993/week @ 2024-02-07 82859/week @ 2024-02-14 81122/week @ 2024-02-21 83664/week @ 2024-02-28 84806/week @ 2024-03-06 87966/week @ 2024-03-13 83646/week @ 2024-03-20

355,480 downloads per month
Used in 308 crates (25 directly)

MIT license

1MB
22K SLoC

Rust crate for Netlink Route Protocol

The netlink-packet-route crate is designed to abstract Netlink route protocol(rtnetlink) packet into Rust data types. The goal of this crate is saving netlink user from reading Kernel Netlink codes.

This crate grouped Netlink route protocol into these modules:

  • link: NIC interface, similar to to ip link command.
  • address: IP address, similar to ip address command.
  • route: Route, similar to ip route command.
  • rule: Route rule, similar to ip rule command.
  • tc: Traffic control, similar to tc command.
  • neighbour: Neighbour, similar to ip neighbour command.
  • neighbour_table: Neighbour table, similar to ip ntable command.
  • nsid: Namespace, similar to ip netns command.

Normally, you should use rtnetlink instead of using this crate directly.

Development

  • Please use git commit --signoff to append Signed-off-by trailer to commit message.

  • For new source file, please append // SPDX-License-Identifier: MIT at the beginning with content of license new code to MIT license.

  • No panic is allowed, please use Result<> instead of unwrap() or expect().

  • Please run cargo fmt and cargo clippy before creating pull request.

  • All struct/enum should be decorated by #[non_exhaustive] to preserve API backwards compatibility unless explicit approval from maintainer.

  • Unknown netlink attribute should be stored into Other(DefaultNla) instead of breaking decoding.

  • Please use unit test case to cover the serialize and deserialize of the changed netlink attribute. To capture the netlink raw bytes, you may use tcpdump/wireshark again the nlmon interface. For example:

modprobe nlmon
ip link add nl0 type nlmon
ip link set nl0 up
tcpdump -i nl0 -w netlink_capture_file.cap
# Then use wireshark to open this `netlink_capture_file.cap`
# Find out the packet you are interested,
# right click -> "Copy" -> "...as Hex Dump".
# You may use https://github.com/cathay4t/hex_to_rust to convert this
# hexdump to rust u8 array
  • The integration test(play with linux kernel netlink interface) should be placed into rtnetlink crate. Current(netlink-packet-route) crate should only unit test case only.

  • For certain netlink message which cannot captured by nlmon, please use Rust Debug and explain every bits in comment.

  • Optionally, please run tools/test_cross_build.sh to make sure your code is compilable on other platforms.

Dependencies

~0.7–1.3MB
~28K SLoC