From 7713569381e8a8219dcf5d0cd956b9b2e9d868b5 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Mon, 31 Jan 2011 10:28:00 -0600 Subject: [PATCH 1/2] python-ethtool-libnl-1.0-support.patch --- python-ethtool/etherinfo.c | 46 ++++++++++++++++++++++++++++++++++++++ setup.py | 3 ++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/python-ethtool/etherinfo.c b/python-ethtool/etherinfo.c index 3f2a3e6..2cc6026 100644 --- a/python-ethtool/etherinfo.c +++ b/python-ethtool/etherinfo.c @@ -34,6 +34,52 @@ pthread_mutex_t nlc_counter_mtx = PTHREAD_MUTEX_INITIALIZER; +#ifdef LIBNL_1_0 +#define NLHDR_COMMON \ + int ce_refcnt; \ + struct nl_object_ops * ce_ops; \ + struct nl_cache * ce_cache; \ + struct nl_list_head ce_list; \ + int ce_msgtype; \ + int ce_flags; \ + uint32_t ce_mask; + +struct nl_cache +{ + struct nl_list_head c_items; + int c_nitems; + int c_iarg1; + int c_iarg2; + struct nl_cache_ops * c_ops; +}; + +struct nl_object +{ + NLHDR_COMMON +}; + +void nl_cache_free(struct nl_cache *cache) +{ + struct nl_object *obj, *tmp; + + if( !cache ) + return; + + nl_list_for_each_entry_safe(obj, tmp, &cache->c_items, ce_list) { + struct nl_cache *cache = obj->ce_cache; + if( !cache ) { + break; + } + + nl_list_del(&obj->ce_list); + obj->ce_cache = NULL; + nl_object_put(obj); + cache->c_nitems--; + } + free(cache); +} +#endif + /* * * Internal functions for working with struct etherinfo diff --git a/setup.py b/setup.py index 99dc718..4b2fcf3 100644 --- a/setup.py +++ b/setup.py @@ -64,7 +64,8 @@ def _str2list(pkgstr, onlystr): include_dirs = libnl['include'], library_dirs = libnl['libdirs'], libraries = libnl['libs'], - define_macros = [('VERSION', '"%s"' % version)] + define_macros = [('VERSION', '"%s"' % version), + ('LIBNL_1_0', None)] ) ] ) From b87b98478d1497a5fca1a19fd10e6fa5a9db3e93 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Tue, 13 May 2014 13:46:35 -0500 Subject: [PATCH 2/2] Revert "Force O_CLOEXEC on the NETLINK socket" This reverts commit 1680cbeb40e76dd975bc8ace756e74771901d607. --- python-ethtool/etherinfo.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/python-ethtool/etherinfo.c b/python-ethtool/etherinfo.c index 2cc6026..179f593 100644 --- a/python-ethtool/etherinfo.c +++ b/python-ethtool/etherinfo.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -457,13 +456,6 @@ int open_netlink(struct etherinfo_obj_data *data) *data->nlc = nl_handle_alloc(); nl_connect(*data->nlc, NETLINK_ROUTE); if( (*data->nlc != NULL) ) { - /* Force O_CLOEXEC flag on the NETLINK socket */ - if( fcntl(nl_socket_get_fd(*data->nlc), F_SETFD, FD_CLOEXEC) == -1 ) { - fprintf(stderr, - "**WARNING** Failed to set O_CLOEXEC on NETLINK socket: %s\n", - strerror(errno)); - } - /* Tag this object as an active user */ pthread_mutex_lock(&nlc_counter_mtx); (*data->nlc_users)++;