Change in vdsm[master]: netlink: User libnl-3 when available

nsoffer at redhat.com nsoffer at redhat.com
Wed Apr 9 08:18:56 UTC 2014


Nir Soffer has posted comments on this change.

Change subject: netlink: User libnl-3 when available
......................................................................


Patch Set 4: Code-Review-1

(4 comments)

Code is quite nice, may be cleaned up a bit.

-1 because it breaks supported version.

http://gerrit.ovirt.org/#/c/26514/4//COMMIT_MSG
Commit Message:

Line 15: 
Line 16: This change makes it necessary to require newer versions of
Line 17: python-ethtool (>= 0.9) since Fedora systems will have libnl3 and
Line 18: they could have an older python-ethtool (at release time it was
Line 19: 0.8.x).
But python-ethtool >= 0.9.1 is *not* available on Fedora 19, so this patch breaks compatibility with supported Fedora version.

I think the logic should be:

 if python-ethtool >= 0.9:
   # Fedora 20
    use libnl3
 else:
    # EL6/CentOS/Fedora 19
    use libnl
Line 20: 
Line 21: Change-Id: I45f043a8416e57d5fb550e2e817e6df38cd793b1
Line 22: Bug-Url: https://bugzilla.redhat.com/1078312


http://gerrit.ovirt.org/#/c/26514/4/lib/vdsm/netlink.py
File lib/vdsm/netlink.py:

Line 215:     """Returns the textual representation of the address."""
Line 216:     address = (c_char * CHARBUFFSIZE)()
Line 217:     return _nl_addr2str(_rtnl_addr_get_local(addr), address, sizeof(address))
Line 218: 
Line 219: 
It is hard to understand big chunk of code under "if has_libnl3", comparing it to the code for libnl. Separating to several logic sections will make it easier to understand and review.

Can you separate following code to sections:

 # libnl only

 # libnl3 only

 # common functions
Line 220: # C function prototypes
Line 221: # http://docs.python.org/2/library/ctypes.html#function-prototypes
Line 222: # This helps ctypes know the calling conventions it should use to communicate
Line 223: # with the binary interface of libnl and which types it should allocate and


Line 224: # cast. Without it ctypes fails when not running on the main thread.
Line 225: _int_proto = CFUNCTYPE(c_int, c_void_p)
Line 226: _char_proto = CFUNCTYPE(c_char_p, c_void_p)
Line 227: _void_proto = CFUNCTYPE(c_void_p, c_void_p)
Line 228: _none_proto = CFUNCTYPE(None, c_void_p)
Do we get None from ctypes?!
Line 229: 
Line 230: _nl_connect = CFUNCTYPE(c_int, c_void_p, c_int)(('nl_connect', LIBNL))
Line 231: _nl_geterror = CFUNCTYPE(c_char_p)(('nl_geterror', LIBNL))
Line 232: 


Line 301:             return _vlan_get_id(link)
Line 302:         else:
Line 303:             return -1
Line 304: 
Line 305: else:
Lets explain why: libnl3 is using "sock" instead of "handle". We are using the new term.
Line 306:     _nl_socket_alloc = CFUNCTYPE(c_void_p)(('nl_handle_alloc', LIBNL))
Line 307:     _nl_socket_free = _none_proto(('nl_handle_destroy', LIBNL))
Line 308: 
Line 309:     _rtnl_link_vlan_get_id = _int_proto(('rtnl_link_vlan_get_id', LIBNL))


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I45f043a8416e57d5fb550e2e817e6df38cd793b1
Gerrit-PatchSet: 4
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list