On Thu, 1 Jun 2023, Anubhav Shelat wrote: > 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@xxxxxxxxxx> > --- > 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 ''' > -- Signed-off-by: John Kacur <jkacur@xxxxxxxxxx>