pyroute2 release 0.4.0
Peter V. Saveliev
peter at svinota.eu
Sun May 8 09:32:14 EDT 2016
An important release  of the most comprehensive Python netlink library.
The library is focused on RTNL (though supports other netlink protocols
* Interfaces: bridge, bond, vlan, vxlan, vrf, veth, gre, ...
* Bridge vlan filters
* Routes: metrics, multipath, ...
* AF_MPLS routes and MPLS lwtunnel 
* Neighbours cache management
* Traffic controls: HTB, TBF, ...
* BPF support 
* Basic support: nftables, ipset, nl80211, taskstats, ...
* Netns support (not via netlink :)
On the low level the library provides socket-like objects. They support
all the normal socket methods like `sendmsg()`, `recv()`, `fileno()`,
can be used in `poll()`/`select()`. But they also provide utility
functions that implement specific protocol features, e.g.:
* `link()` -- manage network interfaces,
* `addr()` -- ... addresses,
* `route()` -- ... routes,
See more details in docs 
For the RTNL protocol the library provides also IPDB, a transactional
database. Instead of polling the system and loading all the objects,
IPDB relies on the netlink broadcasting. Every time some network object
changes its state, the event is being propagated by the kernel. So
despite the IPDB startup may be expensive (at that time it loads all the
system info), for the long-running programs it gives significant
performance improvement, providing fast cache of the network objects. It
is important when there are hundreds and thousands of routes,
neighbours, addresses etc.
All the changes made via IPDB are tracked and asserted; running any code
after the `commit()` call you can be sure that it works in the system
with certain settings. If IPDB meets some issues running `commit()`, it
rolls back all the changes made in the transaction and raises an exception::
with IPDB() as ipdb:
# assume here eth0 is down, w/o ipaddr, mtu == 1500
with ipdb.interfaces['eth0'] as i:
# here eth0 will be up AND with ipaddr AND with new macaddr
# AND with mtu 1460
# if something goes wrong, all the eth0 settings will be
# reverted to the last working state
Project home: https://github.com/svinota/pyroute2
Also in the text:
 in cooperation with https://github.com/iovisor/bcc
More information about the Python-announce-list