Ido Barkan has uploaded a new change for review.
Change subject: net: remove el65 support for libnl binding
..
net: remove el65 support for libnl binding
Since 3.6 does not support el6 this commits reverts 2 other commits:
02ab984 vdsm: Fix memory leak in netlink/link.py
66aa7d8 libnl: workaround for _rtnl_link_get_kernel on el6
The workaround is no longer needed hence also the fix for the memory
leak it created.
Change-Id: I146744a1346b56b7064d841370c7fbfea2a4a0ef
Signed-off-by: Ido Barkan
---
M lib/vdsm/netlink/link.py
1 file changed, 21 insertions(+), 52 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/40571/1
diff --git a/lib/vdsm/netlink/link.py b/lib/vdsm/netlink/link.py
index 605da6e..1797902 100644
--- a/lib/vdsm/netlink/link.py
+++ b/lib/vdsm/netlink/link.py
@@ -16,7 +16,6 @@
#
# Refer to the README and COPYING files for full details of the license
#
-from contextlib import contextmanager
from ctypes import (CFUNCTYPE, byref, c_char, c_char_p, c_int, c_void_p,
c_size_t, sizeof)
from functools import partial
@@ -25,19 +24,18 @@
from . import _cache_manager, _nl_cache_get_first, _nl_cache_get_next
from . import _char_proto, _int_char_proto, _int_proto, _void_proto
-from . import LIBNL_ROUTE, _nl_geterror, _pool, _none_proto
+from . import LIBNL_ROUTE, _nl_geterror, _pool
from . import _addr_to_str, CHARBUFFSIZE
def get_link(name):
"""Returns the information dictionary of the name specified link."""
with _pool.socket() as sock:
-with _get_link(name=name, sock=sock) as link:
-if not link:
-raise IOError(errno.ENODEV, '%s is not present in the system' %
- name)
-link_info = _link_info(link)
-return link_info
+link = _get_link(name=name, sock=sock)
+if not link:
+raise IOError(errno.ENODEV, '%s is not present in the system' %
+ name)
+return _link_info(link)
def iter_links():
@@ -97,12 +95,11 @@
name = (c_char * CHARBUFFSIZE)()
if cache is None:
-with _get_link(index=link_index) as link:
-if link is None:
-raise IOError(errno.ENODEV, 'Dev with index %s is not present '
-'in the system' % link_index)
-name = _rtnl_link_get_name(link)
-return name
+link = _get_link(index=link_index)
+if link is None:
+raise IOError(errno.ENODEV, 'Dev with index %s is not present in '
+'the system' % link_index)
+return _rtnl_link_get_name(link)
else:
return _rtnl_link_i2name(cache, link_index, name, sizeof(name))
@@ -146,52 +143,25 @@
return -1
-# workaround for el6
-def _rtnl_link_get_kernel_workaround(sock, name):
-with _nl_link_cache(sock) as cache:
-return _rtnl_link_get_by_name(cache, name)
-
-
-@contextmanager
def _get_link(name=None, index=0, sock=None):
""" If defined both name and index, index is primary """
# libnl/incluede/netlink/errno.h
-NLE_INVAL = 7
NLE_NODEV = 31
-NLE_OPNOTSUPP = 10
-NLE_SUCCESS = 0
if name is None and index == 0:
raise ValueError('Must specify either a name or an index')
link = c_void_p()
-
-# related to workaroud for el6
-ref_count = False
-
-try:
-if sock is None:
-with _pool.socket() as sock:
-err = _rtnl_link_get_kernel(sock, index, name, byref(link))
-if -err in (NLE_INVAL, NLE_OPNOTSUPP) and index == 0:
-link = _rtnl_link_get_kernel_workaround(sock, name)
-ref_count = True
-err = NLE_SUCCESS
-else:
+if sock is None:
+with _pool.socket() as sock:
err = _rtnl_link_get_kernel(sock, index, name, byref(link))
-if -err in (NLE_INVAL, NLE_OPNOTSUPP) and index == 0:
-link = _rtnl_link_get_kernel_workaround(sock, name)
-ref_count = True
-err = NLE_SUCCESS
-if err:
-if -err == NLE_NODEV:
-link = None
-else:
-raise IOError(-err, _nl_geterror())
-yield link
-finally:
-if ref_count:
-_rtnl_link_put(link)
-
+else:
+err = _rtnl_link_get_kernel(sock, index, name, byref(link))
+if err:
+if -err == NLE_NODEV:
+link = None
+else:
+raise IOError(-err, _nl_geterror())
+return link
_nl_link_cache = partial(_cache_manager, _rtnl_link_alloc_cache)
@@ -210,4 +180,3 @@
'rtnl_link_i2name', LIBNL_ROUTE))
_rtnl_link_operstate2str = _int_char_proto(('rtnl_link_operstate2str',
LIBNL_ROUTE))
-_rtnl_link_put = _none_proto(('rtnl