Added code to check if the /proc/net/if_net6 file exists.

Resolves: rhbz#2210106
jiraProject == RHELPLAN-158239

Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
This commit is contained in:
Anubhav Shelat 2023-06-07 11:03:41 -04:00
parent 0535a1a5eb
commit 85b7a8e9ca
2 changed files with 65 additions and 1 deletions

View File

@ -0,0 +1,57 @@
From 0ba98b12775b5394aab2205df29d93439d625cc3 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>
Signed-off-by: John Kacur <jkacur@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: 4%{?dist}
Release: 5%{?dist}
Summary: Utility to evaluate system suitability for RT Linux
Group: Development/Tools
@ -37,6 +37,7 @@ Patch1: rteval-Replace-python-ethtool-with-inline-code.patch
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: 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.
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%build
%{__python3} setup.py build
@ -86,6 +88,11 @@ to the screen.
%{python3_sitelib}/rteval/__pycache__/*
%changelog
* Wed Jun 07 2023 John Kacur <jkacur@redhat.com> - 3.5-5
- Added code to check if the /proc/net/if_net6 file exists.
Resolves: rhbz#2210106
jiraProject == RHELPLAN-158239
* Wed Feb 08 2023 John Kacur <jkacur@redhat.com> - 3.5-4
- Add check to catch python-dmidecode if it fails
Resolves: rhbz#2168373