summaryrefslogtreecommitdiffstats
path: root/python-ethtool/etherinfo_obj.c
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2013-12-17 21:07:36 +0100
committerDavid Sommerseth <davids@redhat.com>2013-12-17 21:15:24 +0100
commit4c301d903dfc3d011e673a8772d4ac75e99bbd2a (patch)
tree379b0bd747c1ab4330d7641df5d1a108ca27604f /python-ethtool/etherinfo_obj.c
parente9784985e3f7b72cc5f3210d60a88014625b2660 (diff)
Reduce the NETLINK pointer complexity
Make the NETLINK connection pointer and user counter local global variables inside netlink.c only. Where NETLINK calls via libnl is required, rather use get_nlc() to get a NETLINK connection. This also prepares the next step, to get rid of the struct etherinfo_obj_data wrapper. Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'python-ethtool/etherinfo_obj.c')
-rw-r--r--python-ethtool/etherinfo_obj.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/python-ethtool/etherinfo_obj.c b/python-ethtool/etherinfo_obj.c
index 55a42db..97a06be 100644
--- a/python-ethtool/etherinfo_obj.c
+++ b/python-ethtool/etherinfo_obj.c
@@ -41,7 +41,7 @@ extern PyTypeObject ethtool_etherinfoIPv6Type;
void _ethtool_etherinfo_dealloc(etherinfo_py *self)
{
if( self->data ) {
- close_netlink(self->data);
+ close_netlink(self);
if( self->data->ethinfo ) {
free_etherinfo(self->data->ethinfo);
@@ -151,11 +151,11 @@ PyObject *_ethtool_etherinfo_getter(etherinfo_py *self, PyObject *attr_o)
return Py_INCREF(Py_None), Py_None;
}
} else if( strcmp(attr, "mac_address") == 0 ) {
- get_etherinfo(self->data, NLQRY_LINK);
+ get_etherinfo(self, NLQRY_LINK);
Py_INCREF(self->data->ethinfo->hwaddress);
return self->data->ethinfo->hwaddress;
} else if( strcmp(attr, "ipv4_address") == 0 ) {
- get_etherinfo(self->data, NLQRY_ADDR4);
+ get_etherinfo(self, NLQRY_ADDR4);
/* For compatiblity with old approach, return last IPv4 address: */
py_addr = get_last_ipv4_address(self);
if (py_addr) {
@@ -166,14 +166,14 @@ PyObject *_ethtool_etherinfo_getter(etherinfo_py *self, PyObject *attr_o)
}
Py_RETURN_NONE;
} else if( strcmp(attr, "ipv4_netmask") == 0 ) {
- get_etherinfo(self->data, NLQRY_ADDR4);
+ get_etherinfo(self, NLQRY_ADDR4);
py_addr = get_last_ipv4_address(self);
if (py_addr) {
return PyInt_FromLong(py_addr->prefixlen);
}
return PyInt_FromLong(0);
} else if( strcmp(attr, "ipv4_broadcast") == 0 ) {
- get_etherinfo(self->data, NLQRY_ADDR4);
+ get_etherinfo(self, NLQRY_ADDR4);
py_addr = get_last_ipv4_address(self);
if (py_addr) {
if (py_addr->ipv4_broadcast) {
@@ -215,14 +215,14 @@ PyObject *_ethtool_etherinfo_str(etherinfo_py *self)
{
PyObject *ret = NULL;
- if( !self || !self->data || !self->data->nlc || !self->data->ethinfo ) {
+ if( !self || !self->data || !self->data->ethinfo ) {
PyErr_SetString(PyExc_AttributeError, "No data available");
return NULL;
}
- get_etherinfo(self->data, NLQRY_LINK);
- get_etherinfo(self->data, NLQRY_ADDR4);
- get_etherinfo(self->data, NLQRY_ADDR6);
+ get_etherinfo(self, NLQRY_LINK);
+ get_etherinfo(self, NLQRY_ADDR4);
+ get_etherinfo(self, NLQRY_ADDR6);
ret = PyString_FromFormat("Device %s:\n", self->data->ethinfo->device);
if( self->data->ethinfo->hwaddress ) {
@@ -281,7 +281,7 @@ static PyObject *_ethtool_etherinfo_get_ipv4_addresses(etherinfo_py *self, PyObj
return NULL;
}
- get_etherinfo(self->data, NLQRY_ADDR4);
+ get_etherinfo(self, NLQRY_ADDR4);
/* Transfer ownership of reference: */
ret = self->data->ethinfo->ipv4_addresses;
@@ -307,7 +307,7 @@ static PyObject *_ethtool_etherinfo_get_ipv6_addresses(etherinfo_py *self, PyObj
return NULL;
}
- get_etherinfo(self->data, NLQRY_ADDR6);
+ get_etherinfo(self, NLQRY_ADDR6);
/* Transfer ownership of reference: */
ret = self->data->ethinfo->ipv6_addresses;