#netlink #linux #ip

yanked netlink-socket

netlink sockets, with optional integration with mio and tokio

Uses old Rust 2015

0.0.2 Jul 11, 2018
0.0.1 Jul 11, 2018

#55 in #netlink


Used in iproute2

MIT license

27KB
429 lines

Build Status

netlink-rs

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 netlink protocol.

Documentation

Organization

  • the netlink_socket crate provides netlink sockets. Integration with mio and tokio is optional.
  • the rtnetlink crate provides types for netlink's route subprotocol (see man 7 rtnetlink). Integration with Tokio is optional.
  • the iproute2 provides higher level abstractions for the route protocol, like the iproute2 commands: it leverages the netlink route protocol to offer access to links, addresses, arp tables and route tables. It is fully asynchronous and built on top of tokio.

Before starting working on this library, I've checked a bunch of other projects but none seems to be really complete.

  • 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.

Credits

My main resource so far have 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:

Dependencies

~45–790KB
~12K SLoC