This project aims at providing building blocks for the netlink
protocol (see man 7 netlink
).
The netlink protocol is huge but the two most widely used subprotocols are
the generic netlink protocol and the route
netlink protocol (see
man 7 rtnetlink
).
The project is in its early stages, and I'm currently focusing on the route and audit netlink protocols.
- the
netlink_sys
crate provides netlink sockets. Integration withmio
andtokio
is optional. - the
netlink_packet
crate defines the netlink messages, and method for serializing and deserializing them. - the
netlink_proto
crate provides the Tokio integration. - the
rtnetlink
crate provides higher level abstraction for the route protocol (seeman 7 rtnetlink
). This is probably what users want to use, if they want to manipulate IP addresses, route tables, etc. - the
audit
crate provides higher level abstractions for the audit protocol.
Before starting working on this library, I've checked a bunch of other projects but none seems to be really complete.
- https://github.com/achanda/netlink: rust bindings for netlink. Does not seem very usable as is, and does not seem to be developped anymore.
- https://github.com/polachok/pnetlink: very similar to this project, but built
on to of libpnet. The author seems to
be more knowledgeable about netlink than I am. It also has broader coverage
of the route netlink protocol (support for the
RTM_{NEW,DEL,GET}ROUTE
andRTM_{NEW,DEL,GET}ADDRESS
messages). However, many attributes supported byrtnetlink
are not covered. - https://github.com/crhino/netlink-rs: rust bindings for libnl. Very incomplete and not developed.
- https://github.com/jbaublitz/neli: generic netlink protocol. Pretty recent project, actively developed.
- https://github.com/carrotsrc/rsnl: bindings for libnl. Maintained but not actively developed.
- https://github.com/TaborKelly/nl-utils: a netlink packet parser. The goal is not that same than this project.
libnl
: netlink implementation in C. Very complete with awesome documentation.pyroute2
: a very complete and readable implementation in pure python.netlink
: a very complete and very actively maintained go project, seems to be widely used.
My main resource so far has been the source code of
pyroute2
and netlink
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).
These ideas are also being used in @m-labs's
smoltcp
project.
Thanks also to the people behing tokio, especially @carllerche, for the amazing tool they are building, and the support they provide. The project structure and code quality are mind blowing, and some parts of this projects are basically rip-offs from tokio's source code.
Finally, thanks to the Rust community, which helped me in multiple occations.
Other resources I particularly appreciated: