Compare commits

...

No commits in common. 'c9' and 'c8' have entirely different histories.
c9 ... c8

2
.gitignore vendored

@ -1 +1 @@
SOURCES/ethtool-0.15.tar.gz SOURCES/ethtool-0.14.tar.gz

@ -1 +1 @@
546d16dc5d5de83b8c2944df49b7906645c1a35c SOURCES/ethtool-0.15.tar.gz 6e811ede779f2eac9d30950b6dc7abba61372262 SOURCES/ethtool-0.14.tar.gz

@ -0,0 +1,49 @@
From d51756af3dafa2d09ed8f351a48431333318ba31 Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Wed, 7 Nov 2018 11:54:43 +0100
Subject: [PATCH] Fix issue when interface has no IPv4 address assigned.
---
scripts/pifconfig | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
mode change 100755 => 100644 scripts/pifconfig
diff --git a/scripts/pifconfig b/scripts/pifconfig
old mode 100755
new mode 100644
index d1bcdb4..f2b0707
--- a/scripts/pifconfig
+++ b/scripts/pifconfig
@@ -60,16 +60,23 @@ def flags2str(flags):
def show_config(device):
- ipaddr = ethtool.get_ipaddr(device)
- netmask = ethtool.get_netmask(device)
+ try:
+ ipaddr = ethtool.get_ipaddr(device)
+ netmask = ethtool.get_netmask(device)
+ broadcast = ethtool.get_broadcast(device)
+ except (IOError, OSError):
+ ipaddr, netmask, broadcast = None, None, None
flags = ethtool.get_flags(device)
print('%s' % device)
if not (flags & ethtool.IFF_LOOPBACK):
print('\tHWaddr %s' % ethtool.get_hwaddr(device))
- print('\tinet addr:%s' % ipaddr)
- if not (flags & (ethtool.IFF_LOOPBACK | ethtool.IFF_POINTOPOINT)):
- print('\tBcast:%s' % ethtool.get_broadcast(device))
- print('\tMask:%s' % netmask)
+ if ipaddr is not None:
+ print('\tinet addr:%s' % ipaddr)
+ if broadcast is not None and \
+ not (flags & (ethtool.IFF_LOOPBACK | ethtool.IFF_POINTOPOINT)):
+ print('\tBcast:%s' % broadcast)
+ if netmask is not None:
+ print('\tMask:%s' % netmask)
for info in ethtool.get_interfaces_info(device):
for addr in info.get_ipv6_addresses():
print('\tinet6 addr: %s/%s Scope: %s'
--
2.19.1

@ -0,0 +1,105 @@
From 7279bdb8a281de67be61f745f24344d0574e32cf Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Tue, 4 Dec 2018 11:58:48 +0100
Subject: [PATCH 1/2] Allow pifconfig script to show multiple IPv4 addresses
---
scripts/pifconfig | 34 ++++++++++++++++++----------------
tests/test_ethtool.py | 15 +++++++++------
2 files changed, 27 insertions(+), 22 deletions(-)
mode change 100644 => 100755 scripts/pifconfig
diff --git a/scripts/pifconfig b/scripts/pifconfig
old mode 100644
new mode 100755
index f2b0707..c4e726d
--- a/scripts/pifconfig
+++ b/scripts/pifconfig
@@ -17,10 +17,17 @@
from __future__ import unicode_literals, print_function
import ethtool
+import socket
+import struct
import sys
from optparse import OptionParser
+def bits2netmask(bits):
+ mask = (1 << 32) - (1 << 32 >> bits)
+ return socket.inet_ntoa(struct.pack(">L", mask))
+
+
def flags2str(flags):
string = ''
if flags & ethtool.IFF_UP:
@@ -60,24 +67,19 @@ def flags2str(flags):
def show_config(device):
- try:
- ipaddr = ethtool.get_ipaddr(device)
- netmask = ethtool.get_netmask(device)
- broadcast = ethtool.get_broadcast(device)
- except (IOError, OSError):
- ipaddr, netmask, broadcast = None, None, None
flags = ethtool.get_flags(device)
- print('%s' % device)
- if not (flags & ethtool.IFF_LOOPBACK):
- print('\tHWaddr %s' % ethtool.get_hwaddr(device))
- if ipaddr is not None:
- print('\tinet addr:%s' % ipaddr)
- if broadcast is not None and \
- not (flags & (ethtool.IFF_LOOPBACK | ethtool.IFF_POINTOPOINT)):
- print('\tBcast:%s' % broadcast)
- if netmask is not None:
- print('\tMask:%s' % netmask)
+
for info in ethtool.get_interfaces_info(device):
+ print(device)
+ if not (flags & ethtool.IFF_LOOPBACK):
+ print('\tHWaddr %s' % ethtool.get_hwaddr(device))
+
+ for addr in info.get_ipv4_addresses():
+ print('\tinet addr:%s' % addr.address, end=" ")
+ if not (flags & (ethtool.IFF_LOOPBACK | ethtool.IFF_POINTOPOINT)):
+ print('Bcast:%s' % addr.broadcast, end=" ")
+ print('Mask:%s' % bits2netmask(addr.netmask))
+
for addr in info.get_ipv6_addresses():
print('\tinet6 addr: %s/%s Scope: %s'
% (addr.address,
diff --git a/tests/test_ethtool.py b/tests/test_ethtool.py
index 2d8bc0e..6162cd3 100755
--- a/tests/test_ethtool.py
+++ b/tests/test_ethtool.py
@@ -175,17 +175,20 @@ class EthtoolTests(unittest.TestCase):
scraped = None
self.assertIsStringOrNone(ei.ipv4_address)
- if scraped:
- self.assertEqual(ei.ipv4_address, scraped.inet)
+ if scraped and scraped.inet:
+ addresses = [ip.address for ip in ei.get_ipv4_addresses()]
+ self.assertTrue(scraped.inet in addresses)
self.assertIsStringOrNone(ei.ipv4_broadcast)
- if scraped and scraped.broadcast:
+ if scraped and scraped.broadcast not in (None, '0.0.0.0'):
# Broadcast is optional
- self.assertEqual(ei.ipv4_broadcast, scraped.broadcast)
+ broadcasts = [ip.broadcast for ip in ei.get_ipv4_addresses()]
+ self.assertTrue(scraped.broadcast in broadcasts)
self.assertIsInt(ei.ipv4_netmask)
- if scraped:
- self.assertEqual(ei.ipv4_netmask, scraped.get_netmask_bits())
+ if scraped and scraped.netmask:
+ netmasks = [ip.netmask for ip in ei.get_ipv4_addresses()]
+ self.assertTrue(scraped.get_netmask_bits(), netmasks)
self.assertIsStringOrNone(ei.mac_address)
if scraped and scraped.hwaddr and scraped.hwtitle.lower() != 'unspec':
--
2.19.2

@ -5,15 +5,15 @@
%global pypi_name ethtool %global pypi_name ethtool
Name: python-%{pypi_name} Name: python-%{pypi_name}
Version: 0.15 Version: 0.14
Release: 2%{?dist} Release: 5%{?dist}
Summary: Python module to interface with %{pypi_name} Summary: Python module to interface with %{pypi_name}
License: GPLv2 License: GPLv2
URL: https://github.com/fedora-python/%{name} URL: https://github.com/fedora-python/%{name}
Source0: %{pypi_source} Source0: https://files.pythonhosted.org/packages/source/e/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
Patch0: 0001-Fix-issue-when-interface-has-no-IPv4-address-assigne.patch
BuildRequires: gcc Patch1: 0002-Allow-pifconfig-script-to-show-multiple-IPv4-address.patch
BuildRequires: python3-devel BuildRequires: python3-devel
BuildRequires: python3-setuptools BuildRequires: python3-setuptools
@ -37,7 +37,7 @@ PCI locations.
%prep %prep
%autosetup -n %{pypi_name}-%{version} %autosetup -p1 -n %{pypi_name}-%{version}
# Remove bundled egg-info # Remove bundled egg-info
rm -rf %{pypi_name}.egg-info rm -rf %{pypi_name}.egg-info
@ -55,7 +55,8 @@ mv %{buildroot}{%{_bindir},%{_sbindir}}/pifconfig
mv %{buildroot}{%{_bindir},%{_sbindir}}/pethtool mv %{buildroot}{%{_bindir},%{_sbindir}}/pethtool
mkdir -p %{buildroot}%{_mandir}/man8/ mkdir -p %{buildroot}%{_mandir}/man8/
cp -p man/*.8 %{buildroot}%{_mandir}/man8/ %{__gzip} -c man/pethtool.8 > %{buildroot}%{_mandir}/man8/pethtool.8.gz
%{__gzip} -c man/pifconfig.8 > %{buildroot}%{_mandir}/man8/pifconfig.8.gz
%if %{with tests} %if %{with tests}
@ -73,56 +74,34 @@ export PYTHONPATH=%{buildroot}%{python3_sitearch}
%{_sbindir}/pethtool %{_sbindir}/pethtool
%doc %{_mandir}/man8/* %doc %{_mandir}/man8/*
%{python3_sitearch}/%{pypi_name}.cpython-%{python3_version_nodots}*.so %{python3_sitearch}/%{pypi_name}.cpython-%{python3_version_nodots}*.so
%{python3_sitearch}/%{pypi_name}-%{version}-py%{python3_version}.egg-info/ %{python3_sitearch}/%{pypi_name}-%{version}-py?.?.egg-info
%changelog %changelog
* Thu Jan 13 2022 John Kacur <jkacur@redhat.com> - 0.15-2 * Mon Feb 07 2022 John Kacur <jkacur@redhat.com> - 0.15-5
- Rebuild for rhel-9.0 - Add functional test to python-ethtool
Resolves:rhbz#2040095 - Resolves: rhbz#2051609
* Tue Aug 17 2021 Lumír Balhar <lbalhar@redhat.com> - 0.15-1 * Thu Jan 20 2022 John Kacur <jkacur@redhat.com> - 0.14-4
- Update to 0.15 - Rebuild for rhel-8.6, no functional change
Resolves: rhbz#1976102 and rhbz#1977904 - Resolves: rhbz#2042222
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 0.14-11 * Sat Dec 08 2018 Lumír Balhar <lbalhar@redhat.com> - 0.14-3
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags - Backport patch from upstream/rhel7 which allows pifconfig to show
Related: rhbz#1991688 multiple IPv4 addresses for each interface
- Move patches to dist-git
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 0.14-10 - Resolves: rhbz#1652174
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Thu Nov 08 2018 Lumír Balhar <lbalhar@redhat.com> - 0.14-2
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.14-9 - Backport upstream bugfix patch
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - Resolves: rhbz#1637918
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.14-8 * Mon Sep 17 2018 Lumír Balhar <lbalhar@redhat.com> - 0.14-1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild - New upstream version
- Resolves: rhbz#1606952
* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 0.14-7
- Rebuilt for Python 3.9 * Tue Jun 05 2018 Petr Viktorin <pviktori@redhat.com> - 0.13-5
- Remove the Python 2 version
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.14-6 https://bugzilla.redhat.com/show_bug.cgi?id=1567419
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Tue Sep 17 2019 Miro Hrončok <mhroncok@redhat.com> - 0.14-5
- Drop python2-ethtool
* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 0.14-4
- Rebuilt for Python 3.8
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.14-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.14-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Thu Sep 13 2018 Miro Hrončok <mhroncok@redhat.com> - 0.14-1
- Update to 0.14
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.13-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 0.13-5
- Rebuilt for Python 3.7
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.13-4 * Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.13-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

Loading…
Cancel
Save