Dan Kenigsberg has submitted this change and it was merged.

Change subject: netlink: add route retrieval capability
......................................................................


netlink: add route retrieval capability

Currenlty we use iproute2 external processes and parsing to retrieve
the ip routes and rules that are on the system. This patch implements
the information retrieval using libnl, lowering the resource needs
and increasing the performance.

As an example, to retrieve the the routes that we are interested in
for source routing we would now do:

    In [9]: list((route for route in netlink.iter_routes() if route['oif'] == 
'dummy_90' and route['scope'] == 'universe' and route['family'] == 'inet')
    )
    Out[10]:
    [{'destination': '240.0.0.0/24',
      'destination_length': 24,
      'family': 'inet',
      'gateway': '240.0.0.1',
      'oif': 'dummy_90',
      'scope': 'universe',
      'source': None,
      'source_length': 0,
      'table': 252},
     {'destination': 'none',
      'destination_length': 0,
      'family': 'inet',
      'gateway': '240.0.0.254',
      'oif': 'dummy_90',
      'scope': 'universe',
      'source': None,
      'source_length': 0,
      'table': 252}]

Note that it would be easy to extend for the inet6 family and that
the table number is wrong in el6 because libnl-1 only has an uint8
for the table instead of the 32bits of rta_table. For this reason,
on el6.5 the filtering by table is not possible (as we report None).
Libnl3 distros, on the other hand, can do a fast and correct
filtering just checking the table number.

The performance as measured by ipython is:
    %timeit list((route for route in netlink.iter_routes() if route['oif'] == 
'dummy_90' and route['scope'] == 'universe' and route['family'] == 'inet'))
    1000 loops, best of 3: 907 us per loop

While the current solution, before parsing and filtering is:
    In [16]: %timeit ipwrapper.routeShowTable('4026531841')
    1000 loops, best of 3: 1.81 ms per loop

Change-Id: I47d9eb4818d418ab5604a9530c26f93ef7e8e322
Signed-off-by: Antoni S. Puimedon <[email protected]>
Reviewed-on: http://gerrit.ovirt.org/27317
Reviewed-by: Dan Kenigsberg <[email protected]>
---
M debian/vdsm-python.install
M lib/vdsm/netlink/Makefile.am
M lib/vdsm/netlink/link.py
A lib/vdsm/netlink/route.py
M vdsm.spec.in
5 files changed, 117 insertions(+), 1 deletion(-)

Approvals:
  Antoni Segura Puimedon: Verified
  Dan Kenigsberg: Looks good to me, approved



-- 
To view, visit http://gerrit.ovirt.org/27317
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I47d9eb4818d418ab5604a9530c26f93ef7e8e322
Gerrit-PatchSet: 13
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <[email protected]>
Gerrit-Reviewer: Antoni Segura Puimedon <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: [email protected]
Gerrit-Reviewer: oVirt Jenkins CI Server
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to