summaryrefslogtreecommitdiffstats
path: root/python-ethtool/etherinfo.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.c
parente9784985e3f7b72cc5f3210d60a88014625b2660 (diff)
downloadpython-ethtool-4c301d903dfc3d011e673a8772d4ac75e99bbd2a.tar.gz
python-ethtool-4c301d903dfc3d011e673a8772d4ac75e99bbd2a.tar.xz
python-ethtool-4c301d903dfc3d011e673a8772d4ac75e99bbd2a.zip
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.c')
-rw-r--r--python-ethtool/etherinfo.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/python-ethtool/etherinfo.c b/python-ethtool/etherinfo.c
index 74b30d4..509ae08 100644
--- a/python-ethtool/etherinfo.c
+++ b/python-ethtool/etherinfo.c
@@ -142,7 +142,7 @@ static void callback_nl_address(struct nl_object *obj, void *arg)
*
* @return Returns 1 on success, otherwise 0.
*/
-int get_etherinfo(struct etherinfo_obj_data *data, nlQuery query)
+int get_etherinfo(etherinfo_py *self, nlQuery query)
{
struct nl_cache *link_cache;
struct nl_cache *addr_cache;
@@ -153,13 +153,13 @@ int get_etherinfo(struct etherinfo_obj_data *data, nlQuery query)
int ret = 0;
- if( !data || !data->ethinfo ) {
+ if( !self || !self->data || !self->data->ethinfo ) {
return 0;
}
- ethinf = data->ethinfo;
+ ethinf = self->data->ethinfo;
/* Open a NETLINK connection on-the-fly */
- if( !open_netlink(data) ) {
+ if( !open_netlink(self) ) {
PyErr_Format(PyExc_RuntimeError,
"Could not open a NETLINK connection for %s",
ethinf->device);
@@ -171,7 +171,7 @@ int get_etherinfo(struct etherinfo_obj_data *data, nlQuery query)
* interface index if we have that
*/
if( ethinf->index < 0 ) {
- if( rtnl_link_alloc_cache(*data->nlc, AF_UNSPEC, &link_cache) < 0) {
+ if( rtnl_link_alloc_cache(get_nlc(), AF_UNSPEC, &link_cache) < 0) {
return 0;
}
@@ -195,7 +195,7 @@ int get_etherinfo(struct etherinfo_obj_data *data, nlQuery query)
switch( query ) {
case NLQRY_LINK:
/* Extract MAC/hardware address of the interface */
- if( rtnl_link_alloc_cache(*data->nlc, AF_UNSPEC, &link_cache) < 0) {
+ if( rtnl_link_alloc_cache(get_nlc(), AF_UNSPEC, &link_cache) < 0) {
return 0;
}
link = rtnl_link_alloc();
@@ -209,7 +209,7 @@ int get_etherinfo(struct etherinfo_obj_data *data, nlQuery query)
case NLQRY_ADDR4:
case NLQRY_ADDR6:
/* Extract IP address information */
- if( rtnl_addr_alloc_cache(*data->nlc, &addr_cache) < 0) {
+ if( rtnl_addr_alloc_cache(get_nlc(), &addr_cache) < 0) {
nl_cache_free(addr_cache);
return 0;
}