#netlink #ip #linux

netlink-sys

netlink sockets, with optional integration with tokio

7 releases (breaking)

0.6.0 Jan 20, 2021
0.5.0 Nov 27, 2020
0.4.0 Aug 19, 2020
0.3.0 Jun 14, 2020
0.0.1 Jul 11, 2018

#408 in Network programming

Download history 1781/week @ 2020-11-04 1765/week @ 2020-11-11 2110/week @ 2020-11-18 1924/week @ 2020-11-25 2575/week @ 2020-12-02 3027/week @ 2020-12-09 2917/week @ 2020-12-16 1125/week @ 2020-12-23 1666/week @ 2020-12-30 3289/week @ 2021-01-06 3985/week @ 2021-01-13 4342/week @ 2021-01-20 3236/week @ 2021-01-27 4434/week @ 2021-02-03 5554/week @ 2021-02-10 4817/week @ 2021-02-17

10,413 downloads per month
Used in 13 crates (10 directly)

MIT license

48KB
696 lines

Build Status

Netlink

This project aims at providing building blocks for netlink (see man 7 netlink).

Organization

  • the netlink_sys crate provides netlink sockets. Integration with mio and tokio is optional.
  • Each netlink protocol has a netlink-packet-<protocol_name> crate that provides the packets for this protocol:
  • the netlink-packet-core is the glue for all the other netlink-packet-* crates. It provides a NetlinkMessage<T> type that represent any netlink message for any sub-protocol.
  • the netlink_proto crate is an asynchronous implementation of the netlink protocol. It only depends on netlink-packet-core for the NetlinkMessage type and netlink-sys for the socket.
  • the rtnetlink crate provides higher level abstraction for the route protocol
  • the audit crate provides higher level abstractions for the audit protocol.

Altnernatives

Credits

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 behing tokio for the amazing tool they are building, and the support they provide.

Dependencies

~0–1MB
~18K SLoC