python-ifcfg
python-ifcfg copied to clipboard
SLES 12 interface inet6 returns an element 'add'
OS:
server:~ # more /etc/os-release
NAME="SLES"
VERSION="12-SP5"
VERSION_ID="12.5"
PRETTY_NAME="SUSE Linux Enterprise Server 12 SP5"
ID="sles"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:12:sp5"
ifconfig
server:~ # ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
p3p1 Link encap:Ethernet HWaddr 90:E2:BA:48:77:28
inet addr:10.10.0.2 Bcast:10.10.0.255 Mask:255.255.255.0
inet6 addr: fe80::92e2:baff:fe48:7728/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:353636 errors:0 dropped:272 overruns:0 frame:0
TX packets:23246 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:40679739 (38.7 Mb) TX bytes:3620715 (3.4 Mb)
python. you can see in the inet6 there is an element named add. Where does it come from?
server:~ # python
Python 3.6.8 (default, Apr 30 2019, 13:27:23) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import ifcfg
>>> import json
>>> for name, interface in ifcfg.interfaces().items():
... print(interface)
...
{'inet': '127.0.0.1', 'inet4': ['127.0.0.1'], 'ether': None, 'inet6': ['add', '::1'], 'netmask': '255.0.0.0', 'device': 'lo', 'mtu': '65536', 'rxbytes': '0', 'txbytes': '0'}
{'inet': '10.10.0.2', 'inet4': ['10.10.0.2'], 'ether': '90:F2:BA:48:77:28', 'inet6': ['add', 'fe80::92e2:baff:fe48:7728'], 'netmask': '255.255.255.0', 'device': 'p3p1', 'broadcast': '10.10.0.255', 'mtu': '1500', 'rxbytes': '40370493', 'txbytes': '3396222'}
Thanks for filing this issue! Must be that the regex picks up "add", thinking that it's some kind of hex value of an ipv6 address... because the regex is bad.
If you can contribute a fix for this, it will be most welcomed! There are also test cases that could be expanded to include this.
Yes, it's the regex issue. And I found several regex issue on different platforms. I will fix them and test on my side then create PR to fix here.
@Rocking80 sounds great! You are welcome to contribute with new test input data as well, that can solidify the changes for the future :+1: