summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Fix a memleak which would happen if querying for a non-existing devicev0.9David Sommerseth2013-12-111-0/+8
| | | | Signed-off-by: David Sommerseth <davids@redhat.com>
* Add missing new file in MANIFESTDavid Sommerseth2013-12-111-0/+1
| | | | | | Needed for 'make rpmdev' Signed-off-by: David Sommerseth <davids@redhat.com>
* Merge append_object_for_netlink_address() and callback_nl_address()David Sommerseth2013-12-101-49/+19
| | | | | | | This is to simplify and clearify the code furhter. Simply reduce the call chain. Signed-off-by: David Sommerseth <davids@redhat.com>
* Split out generic NETLINK functions from etherinfo.c to netlink.cDavid Sommerseth2013-12-103-86/+114
| | | | | | Primarily just to clean up the code Signed-off-by: David Sommerseth <davids@redhat.com>
* Updated RPM spec file with the new dependenciesDavid Sommerseth2013-09-161-2/+2
| | | | Signed-off-by: David Sommerseth <davids@redhat.com>
* Remove a memory leakDavid Sommerseth2013-09-131-0/+1
| | | | | | | This happened each time it was needed to look up the 'ifindex' of an interface via the get_interfaces_info() API. Signed-off-by: David Sommerseth <davids@redhat.com>
* Merge PyNetlinkIPv4Address and PyNetlinkIPv6Address classesDavid Sommerseth2013-09-134-167/+123
| | | | | | | | | Simplify the overall implementation by reusing code more efficiently. The differences between the IPv4 and IPv6 implementation in libnl is minimal and can more easily be differentiated those few places its needed instead. Signed-off-by: David Sommerseth <davids@redhat.com>
* Fix missing error checking when reading /proc/net/devDavid Sommerseth2013-09-131-2/+8
| | | | Signed-off-by: David Sommerseth <davids@redhat.com>
* Re-implement the IPv6 supportDavid Sommerseth2013-09-135-13/+194
| | | | | | This uses the same approach as IPv4 uses. Signed-off-by: David Sommerseth <davids@redhat.com>
* Rip out the old IPv6 implementation completelyDavid Sommerseth2013-09-137-462/+3
| | | | | | | The whole IPv6 support will be re-implemented using a simliar strategy as the newer IPv4 support uses. Signed-off-by: David Sommerseth <davids@redhat.com>
* Migrated from libnl-1 to libnl-3David Sommerseth2013-09-126-82/+71
| | | | | | | | This ports the current functionality from libnl-1 to libnl-3.0. At the current stage, it should be functional but more patches cleaning up the code will come. Signed-off-by: David Sommerseth <davids@redhat.com>
* Fix get_active_devices() for IPv6 only interfacesBohuslav Kabrda2013-09-111-41/+11
| | | | | | | | | | | | The old ioctl() calls will only return active interaces which is configured with IPv4 addresses. Thus an interface with only IPv6 configured will not be returned. This modifies get_active_devices() to use a newer API to retrieve the needed information. Bugzilla: RH#855920 Signed-off-by: David Sommerseth <davids@redhat.com>
* update "Source:" URL within specfilev0.8David Malcolm2013-02-191-1/+1
|
* bump version to 0.8David Malcolm2013-02-192-2/+2
|
* update URL within specfile to point to git.fedorahosted.org repoDavid Malcolm2013-02-191-1/+1
|
* add a test suiteDavid Malcolm2013-02-054-0/+1199
| | | | | This is based on a suite I wrote internally at Red Hat for python-ethtool, later modified by Braňo Náter <bnater@redhat.com>.
* add python-ethtool/netlink-address.c to MANIFESTDavid Malcolm2013-02-051-0/+1
| | | | | It's not clear to me that we need a handcoded MANIFEST file, but if we're going to have it, it ought to be complete.
* "char *devname" -> "const char *devname" throughoutDavid Malcolm2013-02-011-12/+12
| | | | | | | | | | | | Calling PyArg_ParseTuple(args, "s", &devname) populates devname with a pointer to the internal storage of an (supposedly) immutable string. Make sure the buffer doesn't get mutated by making these pointers be "const char *", rather than just "char *". Found using cpychecker
* Support devices with multiple IPv4 addressesDavid Malcolm2013-01-306-64/+330
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a get_ipv4_addresses() method to ethtool.etherinfo to support devices with multiple IPv4 addresses (rhbz#759150) Previously, get_etherinfo() made queries to NETLINK with NLQRY_ADDR, and callback_nl_address handled responses of family AF_INET (IPv4) by writing to fields within a struct etherinfo. If multiple AF_INET responses come back, each overwrote the last, and the last one won. This patch generalizes things by moving the relevant fields: char *ipv4_address; /**< Configured IPv4 address */ int ipv4_netmask; /**< Configured IPv4 netmask */ char *ipv4_broadcast; from (struct etherinfo) into a new Python class, currently named PyNetlinkIPv4Address. This object has a sane repr(): >>> ethtool.get_interfaces_info('eth1')[0].get_ipv4_addresses() [ethtool.NetlinkIPv4Address(address='192.168.1.10', netmask=24, broadcast='192.168.1.255')] and attributes: >>> print [iface.address for iface in ethtool.get_interfaces_info('eth1')[0].get_ipv4_addresses()] ['192.168.1.10'] >>> print [iface.netmask for iface in ethtool.get_interfaces_info('eth1')[0].get_ipv4_addresses()] [24] >>> print [iface.broadcast for iface in ethtool.get_interfaces_info('eth1')[0].get_ipv4_addresses()] ['192.168.1.255'] The (struct etherinfo) then gains a new field: PyObject *ipv4_addresses; /**< list of PyNetlinkIPv4Address instances */ which is created before starting the query, and populated by the callback as responses come in. All direct usage of the old fields (which assumed a single IPv4 address) are changed to use the last entry in the list (if any), to mimic the old behavior. dump_etherinfo() and _ethtool_etherinfo_str() are changed to loop over all of the IPv4 addresses when outputting, rather than just outputting one. Caveats: * the exact terminology is probably incorrect: I'm not a networking specialist * the relationship between each of devices, get_interfaces_info() results, and addresses seems both unclear and messy to me: how changable is the API? >>> ethtool.get_interfaces_info('eth1')[0].get_ipv4_addresses() [ethtool.NetlinkIPv4Address(address='192.168.1.10', netmask=24, broadcast='192.168.1.255')] It seems that an etherinfo object relates to a device: perhaps it should be named as such? But it may be too late to make this change. Notes: The _ethtool_etherinfo_members array within python-ethtool/etherinfo_obj.c was broken: it defined 4 attributes of type PyObject*, to be extracted from etherinfo_py->data, which is of a completed different type. If these PyMemberDef fields were ever used, Python would segfault. Thankfully _ethtool_etherinfo_getter() has handlers for these attributes, and gets called first. This is a modified version of the patch applied downstream in RHEL 6.4 within python-ethtool-0.6-3.el6: python-ethtool-0.6-add-get_ipv4_addresses-method.patch ported to take account of 508ffffbb3c48eeeb11eeab2bf971180fe4e1940
* Eliminate "ret" within _ethtool_etherinfo_getterDavid Malcolm2013-01-151-9/+6
| | | | | | This variable was confusing cppcheck and potentially could introduce a read of an uninitialized variable if the code were carelessly modified - simplify it.
* Fix memory leaks in get_interfaces_info()David Malcolm2013-01-151-4/+5
| | | | | | | | | | | | | | | | | | | | | The first half of get_interfaces_info() potentially allocates fetch_devs using calloc, setting fetch_devs_len to a value which may or may not be non-zero. In particular, given a tuple argument containing all non-strings, allocation occurs, but fetch_devs_len is set to zero, so it's not correct to use (fetch_devs_len > 0) as the condition for freeing the memory on the primary exit path, as this would leak fetch_devs (introduced in bfdcac6b16806416a6c0295fcfad5d820595d88c) There are also two error-handling paths that fail to free it (introduced in 4f0295fca2cfd933f4b9b539d5505cb24e4d420c) Instead of this logic, simply initialize it to NULL, and pass it to free on every exit route of the second half of the function: free(NULL) is guaranteed to be a no-op. Found by Braňo Náter using the "cppcheck" static analyzer.
* Fix bad loop condition within get_devices()David Malcolm2013-01-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | get_devices() includes this loop: char buffer[256]; ...snip... char *end = buffer; ...snip... while (end && *end != ':') end++; The condition "end" within the while guard will always be true, given that buffer is on the stack and thus will never be near the zero value. It should be *end instead, to check for the NUL terminator byte: this code will likely crash if the string does not contain a colon character. This appears to have been present in the initial commit of the code (8d6ad996f5d60d569532cdba4febb19c69bdf488) Found by Braňo Náter using the "cppcheck" static analyzer.
* Fix buffer overflow in get_module()David Malcolm2013-01-151-1/+1
| | | | | | | | | | | | | | | | | | get_module() includes this scanf call: if (sscanf(buf, "%*d\t%*s\t%100s\t%*d\t%100s\n", driver, dev) > 0) { i.e. "%100s" for each of driver and dev. i.e. a maximum field width of 100 for each. However, this field width does not include the NUL terminator. Increase the size of driver and dev from 100 to 101 to allow for the NUL byte. This appears to have been present in the initial commit of the code (8d6ad996f5d60d569532cdba4febb19c69bdf488) Found by Braňo Náter using the "cppcheck" static analyzer.
* remove redundant material from setup.pyDavid Malcolm2013-01-151-4/+0
| | | | | | | | | Commit d3fd6b84f461a4d7ffbf3f3eae37381150b69e82 introduced an ext_modules keyword argument to the setup invocation in setup.py, making the exttool = Extension(...) code at the top of setup.py redundant. Remove the redundant code.
* pifethtool: Show IPv6 address information when availableDave Malcolm2011-07-061-3/+9
| | | | Signed-off-by: David Sommerseth <davids@redhat.com>
* Make pifconfig respect interface arguments from the command lineDavid Sommerseth2011-06-212-24/+18
| | | | | | | | pifconfig did not pay attention to any arguments give on the command line, which should only list selected devices. This patch revamps the argument parsing, to behave as described in usage and man page. Signed-off-by: David Sommerseth <davids@redhat.com>
* Package man pages in the RPMDavid Sommerseth2011-04-132-3/+18
| | | | | | | The spec file slipped the man page addition commit, so the man pages was not packaged into the RPM itself. Signed-off-by: David Sommerseth <davids@redhat.com>
* Force O_CLOEXEC on the NETLINK socketv0.7David Sommerseth2011-04-121-0/+8
| | | | | | | | | | | To avoid that the NETLINK socket is available to forked children, set the FD_CLOEXEC flag on the NETLINK socket. This also avoids SELinux from complaining on Fedora 14. For more information: https://bugzilla.redhat.com/show_bug.cgi?id=689843 Signed-off-by: David Sommerseth <davids@redhat.com>
* Added man pages for pethtool and pifconfigMiroslav Suchý2011-04-112-0/+123
| | | | Signed-off-by: David Sommerseth <davids@redhat.com>
* Only open the NETLINK interface when neededDavid Sommerseth2011-04-116-75/+118
| | | | | | | | | Do not open a NETLINK connection when loading the module, but rahter open it when needed. In a case where multiple users needs the connection, it will be shared and only closed when the last active user is done. Signed-off-by: David Sommerseth <davids@redhat.com>
* Fixed several memory leaksDavid Sommerseth2011-04-113-10/+22
| | | | | | | | | | | Several places python-ethtool leaked memory, mostly due to missing Py_DECREF() calls on objects being put in to python lists (via PyList_Append() calls). This revealed an issue in addition where the IPv6 addresses pointers in some cases could freed more times. This is fixed as well. Signed-off-by: David Sommerseth <davids@redhat.com>
* Fixed typo in pethtool --help screenDavid Sommerseth2011-03-301-1/+1
| | | | Signed-off-by: David Sommerseth <davids@redhat.com>
* Improved error situations in case of NULL returnsDavid Sommerseth2011-02-251-0/+23
| | | | | | | | _ethtool_etherinfo_get_ipv6_addresses() didn't check too well several Python calls if it would return NULL. Reported-by: Dave Malcolm <dmalcolm@redhat.com> Signed-off-by: David Sommerseth <davids@redhat.com>
* RETURN_STRING() did not use Py_INCREF() when returning Py_NoneDavid Sommerseth2011-02-251-1/+1
| | | | | | | | | | | | | | | From RH BZ#680269: #define RETURN_STRING(str) (str ? PyString_FromString(str) : Py_None) This isn't incrementing the reference count on the Py_None singleton when it should be (the caller assumes that it "owns" a ref on the result of _getter, and will decref it), it could cause the python process to bail out: "Fatal Python error: deallocating None" if run repeatedly. Reported-by: Dave Malcolm <dmalcolm@redhat.com> Signed-off-by: David Sommerseth <davids@redhat.com>
* Version bump - python-ethtool v0.6v0.6David Sommerseth2011-01-191-1/+8
| | | | Signed-off-by: David Sommerseth <davids@redhat.com>
* Avoid duplicating IPv6 address informationDavid Sommerseth2011-01-191-0/+8
| | | | | | | | | In commit c52ed2cbdc5b851ebc7bc19d7c682b14a4a16ba4 a free_ipv6addresses() call was removed, which lead to duplicated IPv6 address information in some cases. Re-add this freeing, to be sure we don't add existing information to an already existing pointer chain. Signed-off-by: David Sommerseth <davids@redhat.com>
* Added ethtool.version string constantDavid Sommerseth2011-01-192-2/+6
| | | | | | This is useful to identify the python-ethtool version at runtime. Signed-off-by: David Sommerseth <davids@redhat.com>
* Remove errornous file from MANIFESTDavid Sommerseth2010-12-211-1/+0
| | | | | | | There has never really existed a file called python-ethtool/etherinfo_ipv6_obj.h Signed-off-by: David Sommerseth <davids@redhat.com>
* Don't segfault if we don't receive any address from rtnl_link_get_addr()David Sommerseth2010-12-211-1/+1
| | | | | | | The callback function for device link information was lacking a simple check to avoid a SEGV in these situations. Signed-off-by: David Sommerseth <davids@redhat.com>
* import sys moduleMiroslav Suchy2010-09-291-0/+1
| | | | | | | it is later used when calling sys.exit() Signed-off-by: Miroslav Suchy <miroslav@suchy.cz> Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
* Version bump - v0.5v0.5David Sommerseth2010-08-091-1/+4
| | | | Signed-off-by: David Sommerseth <davids@redhat.com>
* Python reference counter was not properly set for etherinfo_ipv6addr objectsDavid Sommerseth2010-08-092-5/+4
| | | | | | | | | This caused a double free situation, when Python tried to free the object if the etherinfo::get_ipv6_addresses() method was called several times. In addition the ethtool::get_interfaces_info() would also free the structures uses by etherinfo_ipv6addr objects. Signed-off-by: David Sommerseth <davids@redhat.com>
* Corrected a few spelling mistakesv0.4David Sommerseth2010-08-031-1/+1
| | | | | | Makes rpmlint happy. Signed-off-by: David Sommerseth <davids@redhat.com>
* Preparing for a python-ethtool-0.4 releaseDavid Sommerseth2010-08-031-6/+9
| | | | | | | | | - David Sommerseth is now taking over the maintenance of python-ethtool - New URLs for upstream source code - Added new API: ethtool.get_interfaces_info() - returns list of etherinfo objects - Added support retrieving for IPv6 address, using etherinfo::get_ipv6_addresses() Signed-off-by: David Sommerseth <davids@redhat.com>
* Get rid of not needed struct wrappingDavid Sommerseth2010-08-034-32/+25
| | | | | | | | | | The struct nl_handle was wrapped inside struct _nlconnection. This is really not needed if open_netlink() and close_netlink() functions uses "pointer's pointer" (struct nl_handle **) instead. Removes also the need to declare a static struct _nlconnection, as the global nlconnection variable can now be a pointer as well. Signed-off-by: David Sommerseth <davids@redhat.com>
* Don't append newline when etherinfo_ipv6addr objects are used as stringsDavid Sommerseth2010-08-031-1/+1
| | | | Signed-off-by: David Sommerseth <davids@redhat.com>
* Moved etherinfo::ipv6_addresses to etherinfo::get_ipv6_addresses()David Sommerseth2010-08-031-29/+46
| | | | | | | This is more appropriate as it is not a static list of IPv6 address objects which are returned. Signed-off-by: David Sommerseth <davids@redhat.com>
* Added missing copyright notifications and updated where neededDavid Sommerseth2010-08-037-3/+65
| | | | Signed-off-by: David Sommerseth <davids@redhat.com>
* Renamed etherinfo_ipv6_py to etherinfo_ipv6addr_pyDavid Sommerseth2010-08-022-13/+13
| | | | | | The new name reflects the contents of the data type better. Signed-off-by: David Sommerseth <davids@redhat.com>
* Improved documentation in the codeDavid Sommerseth2010-08-024-25/+94
| | | | Signed-off-by: David Sommerseth <davids@redhat.com>