Added code to check if the proc/net/if_inet6 file exists while

loading IPv6 addresses in the IPv6Addresses class.
Resolves: rhbz#2210103
jiraProject ==  RHELPLAN-158238

Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
This commit is contained in:
Anubhav Shelat 2023-06-06 11:53:18 -04:00
parent 7004ede8ac
commit 39708c6fd6
2 changed files with 65 additions and 1 deletions

View File

@ -0,0 +1,56 @@
From d25d3ccdb29be4f2573b2214db8aea3a87c356af Mon Sep 17 00:00:00 2001
From: Anubhav Shelat <ashelat@redhat.com>
Date: Thu, 1 Jun 2023 16:27:35 -0400
Subject: [PATCH] Added code to check if the proc/net/if_inet6 file exists
while loading IPv6 addresses in the IPv6Addresses class
Added code to check if the proc/net/if_inet6 file exists while loading IPv6 addresses in the IPv6Addresses class. If it doesn't, then the system has IPv6 disabled, and that chunk of code is passed.
Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
---
rteval/sysinfo/newnet.py | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/rteval/sysinfo/newnet.py b/rteval/sysinfo/newnet.py
index 63417d9e59f1..2911400ceb6c 100644
--- a/rteval/sysinfo/newnet.py
+++ b/rteval/sysinfo/newnet.py
@@ -72,19 +72,23 @@ class IPv6Addresses():
and a list of ipv6addresses
'''
MYP = '/proc/net/if_inet6'
- with open(MYP, 'r') as f:
- mystr = f.readline().strip()
- while len(mystr) > 0:
- ipv6addr , _, _, _, _, intf = mystr.split()
- ipv6addr = compress_iv6(ipv6addr)
- if intf == 'lo':
- mystr = f.readline().strip()
- continue
- if intf not in self.data:
- self.data[intf] = [ipv6addr]
- else:
- self.data[intf].append(ipv6addr)
+ try:
+ with open(MYP, 'r') as f:
mystr = f.readline().strip()
+ while len(mystr) > 0:
+ ipv6addr , _, _, _, _, intf = mystr.split()
+ ipv6addr = compress_iv6(ipv6addr)
+ if intf == 'lo':
+ mystr = f.readline().strip()
+ continue
+ if intf not in self.data:
+ self.data[intf] = [ipv6addr]
+ else:
+ self.data[intf].append(ipv6addr)
+ mystr = f.readline().strip()
+ # if IPv6 is disabled, the if_net6 files does not exist, so we can pass
+ except FileNotFoundError:
+ pass
class IPv4Addresses():
''' Obtains a list of IPv4 addresses from the proc file system '''
--
2.31.1

View File

@ -1,6 +1,6 @@
Name: rteval
Version: 3.5
Release: 7%{?dist}
Release: 8%{?dist}
Summary: Utility to evaluate system suitability for RT Linux
Group: Development/Tools
@ -36,6 +36,7 @@ Patch2: Fix-DMI-WARNING-when-not-running-as-root.patch
Patch3: rteval-Don-t-attempt-to-get-DMIinfo-if-there-are-dmi.patch
Patch4: rteval-Catch-failures-in-python-dmidecode.patch
Patch5: rteval-Change-the-default-kernel-to-compile-to-linux.patch
Patch6: Added-code-to-check-if-the-proc-net-if_inet6-file-ex.patch
%description
The rteval script is a utility for measuring various aspects of
@ -53,6 +54,7 @@ to the screen.
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%build
%{__python3} setup.py build
@ -74,6 +76,12 @@ to the screen.
%{_bindir}/rteval
%changelog
* Mon Jun 06 2023 Anubhav Shelat <ashelat@redhat.com> - 3.5-8
- Added code to check if the proc/net/if_inet6 file exists while
loading IPv6 addresses in the IPv6Addresses class.
Resolves: rhbz#2210103
jiraProject == RHELPLAN-158238
* Mon Feb 06 2023 John Kacur <jkacur@redhat.com> - 3.5-7
- Remove Requires python3-sphinx, as this is only needed for
compiling documentation, and is causing problems in testing