Skip to content

Commit f99f7e1

Browse files
authored
[master]fix #4716 show ipv6 interfaces neighbor_ip is N/A issue (#948)
Signed-off-by: tim-rj <[email protected]>
1 parent 5a13e0b commit f99f7e1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

show/main.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,7 @@ def interfaces():
15461546

15471547
if netifaces.AF_INET6 in ipaddresses:
15481548
ifaddresses = []
1549+
neighbor_info = []
15491550
for ipaddr in ipaddresses[netifaces.AF_INET6]:
15501551
neighbor_name = 'N/A'
15511552
neighbor_ip = 'N/A'
@@ -1557,6 +1558,7 @@ def interfaces():
15571558
neighbor_ip = bgp_peer[local_ip][1]
15581559
except Exception:
15591560
pass
1561+
neighbor_info.append([neighbor_name, neighbor_ip])
15601562

15611563
if len(ifaddresses) > 0:
15621564
admin = get_if_admin_state(iface)
@@ -1567,9 +1569,11 @@ def interfaces():
15671569
master = get_if_master(iface)
15681570
if get_interface_mode() == "alias":
15691571
iface = iface_alias_converter.name_to_alias(iface)
1570-
data.append([iface, master, ifaddresses[0][1], admin + "/" + oper, neighbor_name, neighbor_ip])
1571-
for ifaddr in ifaddresses[1:]:
1572-
data.append(["", "", ifaddr[1], ""])
1572+
data.append([iface, master, ifaddresses[0][1], admin + "/" + oper, neighbor_info[0][0], neighbor_info[0][1]])
1573+
neighbor_info.pop(0)
1574+
for ifaddr in ifaddresses[1:]:
1575+
data.append(["", "", ifaddr[1], admin + "/" + oper, neighbor_info[0][0], neighbor_info[0][1]])
1576+
neighbor_info.pop(0)
15731577

15741578
print tabulate(data, header, tablefmt="simple", stralign='left', missingval="")
15751579

0 commit comments

Comments
 (0)