Skip to content

Commit 068f37f

Browse files
tim-rjshaoshouping
andauthored
[master]Fix show ip interface neighbor info not correct when add second ip (sonic-net#1134)
**- What I did** Fix sonic-net#5423 **- How I did it** store neighbor info into array for later showing. **- How to verify it** config interface ip add Ethernet49 xxx secondary many times show ip interface **- Previous command output (if the output of a command-line utility has changed)** ``` root@sonic:/home/admin# show ip interfaces Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP --------------- -------- ------------------- ------------ -------------- ------------- Ethernet49 10.0.0.96/31 up/up N/A N/A 10.10.49.1/24 ``` **- New command output (if the output of a command-line utility has changed)** ``` root@sonic:/usr/lib/python2.7/dist-packages/show# show ip interfaces Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP ----------- --------------- ------------------- ------------ -------------- ------------- Ethernet49 10.0.0.96/31 up/up ARISTA21T0 10.0.0.97 10.10.49.1/24 up/up N/A N/A ``` Co-authored-by: shaoshouping <[email protected]>
1 parent 6e58dff commit 068f37f

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
@@ -721,6 +721,7 @@ def interfaces():
721721

722722
if netifaces.AF_INET in ipaddresses:
723723
ifaddresses = []
724+
neighbor_info = []
724725
for ipaddr in ipaddresses[netifaces.AF_INET]:
725726
neighbor_name = 'N/A'
726727
neighbor_ip = 'N/A'
@@ -732,6 +733,7 @@ def interfaces():
732733
neighbor_ip = bgp_peer[local_ip][1]
733734
except Exception:
734735
pass
736+
neighbor_info.append([neighbor_name, neighbor_ip])
735737

736738
if len(ifaddresses) > 0:
737739
admin = get_if_admin_state(iface)
@@ -743,10 +745,12 @@ def interfaces():
743745
if clicommon.get_interface_naming_mode() == "alias":
744746
iface = iface_alias_converter.name_to_alias(iface)
745747

746-
data.append([iface, master, ifaddresses[0][1], admin + "/" + oper, neighbor_name, neighbor_ip])
748+
data.append([iface, master, ifaddresses[0][1], admin + "/" + oper, neighbor_info[0][0], neighbor_info[0][1]])
749+
neighbor_info.pop(0)
747750

748-
for ifaddr in ifaddresses[1:]:
749-
data.append(["", "", ifaddr[1], ""])
751+
for ifaddr in ifaddresses[1:]:
752+
data.append(["", "", ifaddr[1], admin + "/" + oper, neighbor_info[0][0], neighbor_info[0][1]])
753+
neighbor_info.pop(0)
750754

751755
print(tabulate(data, header, tablefmt="simple", stralign='left', missingval=""))
752756

0 commit comments

Comments
 (0)