Added more bugfix patches
Also added missing %changelog entry for the previous build Signed-off-by: David Sommerseth <davids@redhat.com>
This commit is contained in:
parent
1973cda153
commit
eb9a146ca4
134
0001-Improve-error-handling-even-more.patch
Normal file
134
0001-Improve-error-handling-even-more.patch
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
From cb29a4277b2aa5b5c211979c1dd3cdb098e1fcb9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: David Sommerseth <davids@redhat.com>
|
||||||
|
Date: Tue, 1 Apr 2014 21:25:15 +0200
|
||||||
|
Subject: [PATCH 1/2] Improve error handling even more
|
||||||
|
|
||||||
|
Ensure that a Python exception is set on more places errors can occur.
|
||||||
|
|
||||||
|
Signed-off-by: David Sommerseth <davids@redhat.com>
|
||||||
|
---
|
||||||
|
python-ethtool/etherinfo.c | 32 ++++++++++++++++++--------------
|
||||||
|
1 file changed, 18 insertions(+), 14 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/python-ethtool/etherinfo.c b/python-ethtool/etherinfo.c
|
||||||
|
index 24147bc..14b4796 100644
|
||||||
|
--- a/python-ethtool/etherinfo.c
|
||||||
|
+++ b/python-ethtool/etherinfo.c
|
||||||
|
@@ -26,6 +26,7 @@
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <netlink/cache.h>
|
||||||
|
#include <netlink/addr.h>
|
||||||
|
+#include <netlink/errno.h>
|
||||||
|
#include <netlink/route/addr.h>
|
||||||
|
#include <netlink/route/link.h>
|
||||||
|
#include <netlink/route/rtnl.h>
|
||||||
|
@@ -111,34 +112,35 @@ static void callback_nl_address(struct nl_object *obj, void *arg)
|
||||||
|
* @param self A pointer the current PyEtherInfo Python object which contains the device name
|
||||||
|
* and the place where to save the corresponding index value.
|
||||||
|
*
|
||||||
|
- * @return Returns 1 on success, otherwise 0.
|
||||||
|
+ * @return Returns 1 on success, otherwise 0. On error, a Python error exception is set.
|
||||||
|
*/
|
||||||
|
static int _set_device_index(PyEtherInfo *self)
|
||||||
|
{
|
||||||
|
struct nl_cache *link_cache;
|
||||||
|
struct rtnl_link *link;
|
||||||
|
|
||||||
|
- /* Reset errno, as we will use it to report errors further on */
|
||||||
|
- errno = 0;
|
||||||
|
-
|
||||||
|
/* Find the interface index we're looking up.
|
||||||
|
* As we don't expect it to change, we're reusing a "cached"
|
||||||
|
* interface index if we have that
|
||||||
|
*/
|
||||||
|
if( self->index < 0 ) {
|
||||||
|
- if( rtnl_link_alloc_cache(get_nlc(), AF_UNSPEC, &link_cache) < 0) {
|
||||||
|
+ if( (errno = rtnl_link_alloc_cache(get_nlc(), AF_UNSPEC, &link_cache)) < 0) {
|
||||||
|
+ PyErr_SetString(PyExc_OSError, nl_geterror(errno));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
link = rtnl_link_get_by_name(link_cache, PyString_AsString(self->device));
|
||||||
|
if( !link ) {
|
||||||
|
errno = ENODEV;
|
||||||
|
+ PyErr_SetFromErrno(PyExc_IOError);
|
||||||
|
nl_cache_free(link_cache);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
self->index = rtnl_link_get_ifindex(link);
|
||||||
|
- if( self->index < 0 ) {
|
||||||
|
+ if( self->index <= 0 ) {
|
||||||
|
+ errno = ENODEV;
|
||||||
|
+ PyErr_SetFromErrno(PyExc_IOError);
|
||||||
|
rtnl_link_put(link);
|
||||||
|
nl_cache_free(link_cache);
|
||||||
|
return 0;
|
||||||
|
@@ -167,6 +169,7 @@ int get_etherinfo_link(PyEtherInfo *self)
|
||||||
|
{
|
||||||
|
struct nl_cache *link_cache;
|
||||||
|
struct rtnl_link *link;
|
||||||
|
+ int err = 0;
|
||||||
|
|
||||||
|
if( !self ) {
|
||||||
|
return 0;
|
||||||
|
@@ -181,18 +184,18 @@ int get_etherinfo_link(PyEtherInfo *self)
|
||||||
|
}
|
||||||
|
|
||||||
|
if( _set_device_index(self) != 1) {
|
||||||
|
- if( errno != 0 ) {
|
||||||
|
- PyErr_SetString(PyExc_IOError, strerror(errno));
|
||||||
|
- }
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Extract MAC/hardware address of the interface */
|
||||||
|
- if( rtnl_link_alloc_cache(get_nlc(), AF_UNSPEC, &link_cache) < 0) {
|
||||||
|
+ if( (err = rtnl_link_alloc_cache(get_nlc(), AF_UNSPEC, &link_cache)) < 0) {
|
||||||
|
+ PyErr_SetString(PyExc_OSError, nl_geterror(err));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
link = rtnl_link_alloc();
|
||||||
|
if( !link ) {
|
||||||
|
+ errno = ENOMEM;
|
||||||
|
+ PyErr_SetFromErrno(PyExc_OSError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
rtnl_link_set_ifindex(link, self->index);
|
||||||
|
@@ -220,6 +223,7 @@ PyObject * get_etherinfo_address(PyEtherInfo *self, nlQuery query)
|
||||||
|
struct nl_cache *addr_cache;
|
||||||
|
struct rtnl_addr *addr;
|
||||||
|
PyObject *addrlist = NULL;
|
||||||
|
+ int err = 0;
|
||||||
|
|
||||||
|
if( !self ) {
|
||||||
|
return NULL;
|
||||||
|
@@ -234,21 +238,21 @@ PyObject * get_etherinfo_address(PyEtherInfo *self, nlQuery query)
|
||||||
|
}
|
||||||
|
|
||||||
|
if( _set_device_index(self) != 1) {
|
||||||
|
- if( errno != 0 ) {
|
||||||
|
- return PyErr_SetFromErrno(PyExc_IOError);
|
||||||
|
- }
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Query the for requested info via NETLINK */
|
||||||
|
|
||||||
|
/* Extract IP address information */
|
||||||
|
- if( rtnl_addr_alloc_cache(get_nlc(), &addr_cache) < 0) {
|
||||||
|
+ if( (err = rtnl_addr_alloc_cache(get_nlc(), &addr_cache)) < 0) {
|
||||||
|
+ PyErr_SetString(PyExc_OSError, nl_geterror(err));
|
||||||
|
nl_cache_free(addr_cache);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
addr = rtnl_addr_alloc();
|
||||||
|
if( !addr ) {
|
||||||
|
+ errno = ENOMEM;
|
||||||
|
+ PyErr_SetFromErrno(PyExc_OSError);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
rtnl_addr_set_ifindex(addr, self->index);
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
From c49e4c1a9d36c28acc886793490794e86a955a04 Mon Sep 17 00:00:00 2001
|
||||||
|
From: David Sommerseth <davids@redhat.com>
|
||||||
|
Date: Tue, 1 Apr 2014 21:26:40 +0200
|
||||||
|
Subject: [PATCH 2/2] Don't try to increase reference counter on non-existing
|
||||||
|
hwaddress
|
||||||
|
|
||||||
|
Signed-off-by: David Sommerseth <davids@redhat.com>
|
||||||
|
---
|
||||||
|
python-ethtool/etherinfo_obj.c | 4 +++-
|
||||||
|
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/python-ethtool/etherinfo_obj.c b/python-ethtool/etherinfo_obj.c
|
||||||
|
index f620157..cd7f2e3 100644
|
||||||
|
--- a/python-ethtool/etherinfo_obj.c
|
||||||
|
+++ b/python-ethtool/etherinfo_obj.c
|
||||||
|
@@ -104,7 +104,9 @@ PyObject *_ethtool_etherinfo_getter(PyEtherInfo *self, PyObject *attr_o)
|
||||||
|
}
|
||||||
|
} else if( strcmp(attr, "mac_address") == 0 ) {
|
||||||
|
get_etherinfo_link(self);
|
||||||
|
- Py_INCREF(self->hwaddress);
|
||||||
|
+ if( self->hwaddress ) {
|
||||||
|
+ Py_INCREF(self->hwaddress);
|
||||||
|
+ }
|
||||||
|
return self->hwaddress;
|
||||||
|
} else if( strcmp(attr, "ipv4_address") == 0 ) {
|
||||||
|
addrlist = get_etherinfo_address(self, NLQRY_ADDR4);
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
||||||
@ -4,7 +4,7 @@
|
|||||||
Summary: Ethernet settings python bindings
|
Summary: Ethernet settings python bindings
|
||||||
Name: python-ethtool
|
Name: python-ethtool
|
||||||
Version: 0.10
|
Version: 0.10
|
||||||
Release: 2%{?dist}
|
Release: 3%{?dist}
|
||||||
URL: https://fedorahosted.org/python-ethtool/
|
URL: https://fedorahosted.org/python-ethtool/
|
||||||
Source: https://fedorahosted.org/releases/p/y/python-ethtool/python-ethtool-%{version}.tar.bz2
|
Source: https://fedorahosted.org/releases/p/y/python-ethtool/python-ethtool-%{version}.tar.bz2
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
@ -16,6 +16,8 @@ Patch1: 0001-Added-some-extra-error-checks-with-libnl-calls.patch
|
|||||||
Patch2: 0002-fix-get_module-errno-setting.patch
|
Patch2: 0002-fix-get_module-errno-setting.patch
|
||||||
Patch4: 0004-exceptions-Simplify-errno-derived-exception-handling.patch
|
Patch4: 0004-exceptions-Simplify-errno-derived-exception-handling.patch
|
||||||
Patch5: 0005-Report-invalid-non-existing-devices-as-ENODEV.patch
|
Patch5: 0005-Report-invalid-non-existing-devices-as-ENODEV.patch
|
||||||
|
Patch6: 0001-Improve-error-handling-even-more.patch
|
||||||
|
Patch7: 0002-Don-t-try-to-increase-reference-counter-on-non-exist.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Python bindings for the ethtool kernel interface, that allows querying and
|
Python bindings for the ethtool kernel interface, that allows querying and
|
||||||
@ -28,6 +30,8 @@ PCI locations.
|
|||||||
%patch2 -p1
|
%patch2 -p1
|
||||||
%patch4 -p1
|
%patch4 -p1
|
||||||
%patch5 -p1
|
%patch5 -p1
|
||||||
|
%patch6 -p1
|
||||||
|
%patch7 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%{__python} setup.py build
|
%{__python} setup.py build
|
||||||
@ -58,6 +62,12 @@ rm -rf %{buildroot}
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Apr 1 2014 David Sommerseth <davids@redhat.com> - 0.10-3
|
||||||
|
- Added patch 6 and 7, to improve error handling. Will be removed when released upstream
|
||||||
|
|
||||||
|
* Thu Mar 20 2014 David Sommerseth <davids@redhat.com> - 0.10-2
|
||||||
|
- Added patch 1, 2, 4 and 5; they have not appeared in an upstream release yet
|
||||||
|
|
||||||
* Thu Jan 09 2014 David Sommerseth <davids@redhat.com> - 0.10-1
|
* Thu Jan 09 2014 David Sommerseth <davids@redhat.com> - 0.10-1
|
||||||
- Updated to v0.10
|
- Updated to v0.10
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user