This project aims at providing building blocks for netlink (see
man 7 netlink).
If you seeking crates to communication with linux netlink, please try:
- The
rtnetlinkcrate provides higher level abstraction for the route protocol - The
auditcrate provides higher level abstractions for the audit protocol. - The
genetlinkcrate provides higher level abstraction for the generic netlink protocol - The
ethtoolcrate provides higher level abstraction for ethtool netlink protocol - The
mptcp-pmcrate provides MPTCP path manager netlink protocol - The
wl-nl80211crate provides wireless nl80211 netlink protocol
If you seeking crates to parsing or emitting netlink packet, please try:
- Each netlink protocol has a
netlink-packet-<protocol_name>crate that provides the packets for this protocol:- The
netlink-packet-wireguardcrate provide netlink message for wireguard. netlink-packet-routeprovides messages for the route protocolnetlink-packet-auditprovides messages for the audit protocolnetlink-packet-sock-diagprovides messages for the sock-diag protocolnetlink-packet-genericprovides message for the generic netlink protocolnetlink-packet-netfilterprovides message for theNETLINK_NETFILTERprotocolnetlink-packet-xfrmprovides message for IPsec
- The
Shared crates but designed for internal usage:
- The
netlink_syscrate provides netlink sockets. Integration withmioandtokiois optional. - The
netlink-packet-coreis the glue for all the othernetlink-packet-*crates. It provides aNetlinkMessage<T>type that represent any netlink message for any sub-protocol. - The
netlink-protocrate is an asynchronous implementation of the netlink protocol. It only depends onnetlink-packet-corefor theNetlinkMessagetype andnetlink-sysfor the socket.
If you want to add more netlink related crates into this organization, please open pull request to rust-netlink/new-crate-review.
- https://github.com/jbaublitz/neli: the main alternative to these crates, as it is actively developed.
- https://github.com/one-d-wide/netlink-bindings: Rust bindings for encoding/decoding Netlink messages generated from Linux kernel YAML netlink API
- Other but less actively developed alternatives:
The architecture desion records are stored in https://github.com/rust-netlink/.github/tree/main/architecture_decisions
My main resource so far has been the source code of pyroute2
(python) and netlink (golang) a lot. These two projects are
great, and very nicely written. As someone who does not read C fluently, and
that does not know much about netlink, they have been invaluable.
I'd also like to praise libnl for its documentation. It helped me a
lot in understanding the protocol basics.
The whole packet parsing logic is inspired by @whitequark excellent blog posts (part 1, part 2 and part 3, although I've only really used the concepts described in the first blog post).
Thanks also to the people behind tokio for the amazing tool they are building, and the support they provide.
- Crate github issue
- Use Matrix room:
#rust-netlink:fedora.im