sonic-utilities
sonic-utilities copied to clipboard
[show][multiasic]Fixed SONIC_CLI_IFACE_MODE=alias show ip|ipv6 route output in default mode issue
What I did
There are many issues with the "SONIC_CLI_IFACE_MODE=aliasshow ip/ipv6 route [json]" commands on both single asic platform and multiasic platform
- Doesn't show the interface alias on single asic platform
- Display the route info twice either in Json format or default format on the single asic platform
- Doesn't show the interface alias on multiasic platform
- Display the route info in the Json format even if Json is not specified in the CLI command
Resolves# https://github.com/sonic-net/sonic-buildimage/issues/8498
This PR is required by 202205 branch
How I did it
- In the current show_routes() function, the internal command to get the route for single asic platform is formatted to "vtysh show ip/ipv6 route" while it is formatted to "vtysh show ip/ipv6 route json". This commit changes to use the same command "vtysh show ip/ipv6 route json" for both single asic platform and multiasic platform.
- With the same format (in Json) output, add logic to run_bgp_show_command() to convert the Interface name to alias if SONIC_CLI_IFACE_MODE=alias for both show ip/ipv4 route command
- Add code to skip the function run_command_in_alias_mode() for "show ip/ipv6 route" command since it is not applicable to show the route table info.
- Modify and clean up the show_routes() function to use the same code path to display route info for both none-multasic and multiasic platform.
- Add unit test cases: test_show_ipv6_route_alias() and test show_multi_asic_ipv6_route_all_namespace_alias()
How to verify it
- execute show command "SONIC_CLI_IFACE_MODE=alias show ip route", it will display the route info in the default format with the interface name
- verify the port interface name is displayed the alias instead of the port name
admin@sonic:~$ SONIC_CLI_IFACE_MODE=alias show ip route 0.0.0.0/0
Routing entry for 0.0.0.0/0
Known via "bgp", distance 20, metric 0, best
Last update 01:24:03 ago
* 10.0.0.11, via Ethernet-IB0 onlink
* 10.0.0.11 (recursive)
* 10.0.0.7, via Ethernet-IB0 onlink
* 10.0.0.7 (recursive)
* 10.0.0.5, via Ethernet1/18
* 10.0.0.1, via PortChannel102
* 10.0.0.1 (recursive)
* 10.0.0.1, via Ethernet-IB1 onlink
* 10.0.0.5 (recursive)
* 10.0.0.5, via Ethernet-IB1 onlink
* 10.0.0.7, via PortChannel106
* 10.0.0.11, via Ethernet1/36
- Also exec the "show ipv6 command" to verify the ipv6 route info is displayed in the correct format with the alias name.
admin@sonic:~$ SONIC_CLI_IFACE_MODE=alias show ipv6 route ::0/0
Routing entry for ::/0
Known via "kernel", distance 210, metric 0
Last update 21:31:04 ago
* fd00::1, via eth0
Routing entry for ::/0
Known via "bgp", distance 20, metric 0, best
Last update 01:27:15 ago
* fc00::16, via Ethernet-IB0 onlink
* fc00::16 (recursive)
* fc00::e, via Ethernet-IB0 onlink
* fc00::e (recursive)
* fc00::a, via Ethernet1/18
* fc00::2, via PortChannel102
* fc00::2 (recursive)
* fc00::2, via Ethernet-IB1 onlink
* fc00::a (recursive)
* fc00::a, via Ethernet-IB1 onlink
* fc00::e, via PortChannel106
* fc00::16, via Ethernet1/36
The following command have been run to against these changes. They all work as expected:
------------------- Multiasic ip/ipv6 route ---------------------
show ip route
SONIC_CLI_IFACE_MODE=alias show ip route
show ip route json
SONIC_CLI_IFACE_MODE=alias show ip route json
show ip route -n asic0
SONIC_CLI_IFACE_MODE=alias show ip route -n asic0
show ip route json -n asic0
SONIC_CLI_IFACE_MODE=alias show ip route json -n asic0
show ip route -d all
SONIC_CLI_IFACE_MODE=alias show ip route -d all
show ip route json -d all
SONIC_CLI_IFACE_MODE=alias show ip route json -d all
show ip route -d frontend
SONIC_CLI_IFACE_MODE=alias show ip route -d frontend
show ip route json -d frontend
SONIC_CLI_IFACE_MODE=alias show ip route json -d frontend
show ip route 192.217.192.128
SONIC_CLI_IFACE_MODE=alias show ip route 192.217.192.128
show ip route 192.217.192.128 json
SONIC_CLI_IFACE_MODE=alias show ip route 192.217.192.128 json
show ip route 192.217.192.128 -d all
SONIC_CLI_IFACE_MODE=alias show ip route 192.217.192.128 -d all
show ip route 192.217.192.128 json -d all
SONIC_CLI_IFACE_MODE=alias show ip route 192.217.192.128 json -d all
show ip route 192.217.192.128 -d frontend
SONIC_CLI_IFACE_MODE=alias show ip route 192.217.192.128 -d frontend
show ip route 192.217.192.128 json -d frontend
SONIC_CLI_IFACE_MODE=alias show ip route 192.217.192.128 json -d frontend
show ipv6 route
SONIC_CLI_IFACE_MODE=alias show ipv6 route
show ipv6 route json
SONIC_CLI_IFACE_MODE=alias show ipv6 route json
show ipv6 route -d all
SONIC_CLI_IFACE_MODE=alias show ipv6 route -d all
show ipv6 route json -d all
SONIC_CLI_IFACE_MODE=alias show ip route json -d all
show ipv6 route -d frontend
SONIC_CLI_IFACE_MODE=alias show ipv6 route -d frontend
show ipv6 route json -d frontend
SONIC_CLI_IFACE_MODE=alias show ipv6 route json -d frontend
show ipv6 route fe80::
SONIC_CLI_IFACE_MODE=alias show ipv6 route fe80::/64
show ipv6 route fe80::/64 json
SONIC_CLI_IFACE_MODE=alias show ipv6 route fe80::/64 json
show ipv6 route fe80::/64 -d all
SONIC_CLI_IFACE_MODE=alias show ipv6 route fe80::/64 -d all
show ipv6 route fe80::/64 json -d all
SONIC_CLI_IFACE_MODE=alias show ipv6 route fe80::/64 json -d all
show ipv6 route fe80::/64 -d frontend
SONIC_CLI_IFACE_MODE=alias show ipv6 route fe80::/64 -d frontend
show ipv6 route fe80::/64 json -d frontend
SONIC_CLI_IFACE_MODE=alias show ipv6 route fe80::/64 json -d frontend
================ Non-multiasic ip/ route =======================
show ip route
SONIC_CLI_IFACE_MODE=alias show ip route
show ip route json
SONIC_CLI_IFACE_MODE=alias show ip route json
show ip route -d all
SONIC_CLI_IFACE_MODE=alias show ip route -d all
show ip route json -d all
SONIC_CLI_IFACE_MODE=alias show ip route json -d all
show ip route 10.1.0.32
SONIC_CLI_IFACE_MODE=alias show ip route 10.1.0.32
show ip route 192.217.192.128 json
SONIC_CLI_IFACE_MODE=alias show ip route 10.1.0.32 json
show ip route 10.1.0.32 -d all
SONIC_CLI_IFACE_MODE=alias show ip route 10.1.0.32 -d all
show ip route 10.1.0.32 json -d all
SONIC_CLI_IFACE_MODE=alias show ip route 10.1.0.32 json -d all
show ip route 10.1.0.32 -d frontend
SONIC_CLI_IFACE_MODE=alias show ip route 10.1.0.32 -d frontend
show ip route 10.1.0.32 json -d frontend
SONIC_CLI_IFACE_MODE=alias show ip route 10.1.0.32 json -d frontend
show ipv6 route
SONIC_CLI_IFACE_MODE=alias show ipv6 route
show ipv6 route json
SONIC_CLI_IFACE_MODE=alias show ipv6 route json
show ipv6 route -d all
SONIC_CLI_IFACE_MODE=alias show ipv6 route -d all
show ipv6 route json -d all
SONIC_CLI_IFACE_MODE=alias show ip route json -d all
show ipv6 route -d frontend
SONIC_CLI_IFACE_MODE=alias show ipv6 route -d frontend
show ipv6 route json -d frontend
SONIC_CLI_IFACE_MODE=alias show ipv6 route json -d frontend
show ipv6 route fe80::
SONIC_CLI_IFACE_MODE=alias show ipv6 route fe80::/64
show ipv6 route fe80::/64 json
SONIC_CLI_IFACE_MODE=alias show ipv6 route fe80::/64 json
show ipv6 route fe80::/64 -d all
SONIC_CLI_IFACE_MODE=alias show ipv6 route fe80::/64 -d all
show ipv6 route fe80::/64 json -d all
SONIC_CLI_IFACE_MODE=alias show ipv6 route fe80::/64 json -d all
show ipv6 route fe80::/64 -d frontend
SONIC_CLI_IFACE_MODE=alias show ipv6 route fe80::/64 -d frontend
show ipv6 route fe80::/64 json -d frontend
SONIC_CLI_IFACE_MODE=alias show ipv6 route fe80::/64 json -d frontend
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)
@judyjoseph @abdosi Please help or inivite the right people to review this PR. Thanks
@judyjoseph & @abdosi Please help to review this PR. Thanks.
@abdosi Since this PR is approved, could you please merge it. Thanks