Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[201911] Fix Multi-ASIC show specific recursive route by using common parsing function #1563

Merged
merged 1 commit into from
Apr 15, 2021

Conversation

gechiang
Copy link
Contributor

@gechiang gechiang commented Apr 15, 2021

What I did

This is to port the same fix from master branch to 201911 (#1560)

On Multi-ASIC DUT when the route contains recursive routes in the nexthop information the show ip route handling parsing logic was missing the parsing logic for this case due to it was using its own parsing logic instead of sharing the previous parsing function that already handle the recursive next hop case. This resulted to hitting an error during show handling similar to following:

admin@str2-n3164-acs-1:~$ show ip route -nasic4 -d all 193.11.208.0/25
Routing entry for 193.11.208.0/25
  Known via "bgp", distance 200, metric 0, best
  Last update 13:34:33 ago
Traceback (most recent call last):
  File "/usr/bin/show", line 12, in <module>
    sys.exit(cli())
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/show/main.py", line 1226, in route
    bgp_common.show_routes(args, namespace, display, verbose, "ip")
  File "/usr/lib/python2.7/dist-packages/show/bgp_common.py", line 423, in show_routes
    print_ip_routes(ns_route, filter_by_ip)
  File "/usr/lib/python2.7/dist-packages/show/bgp_common.py", line 159, in print_ip_routes
    str_2_print += ", via {}".format(info[i]['nexthops'][j]['interfaceName'])
KeyError: 'interfaceName'

How I did it

Changed the code to use the existing parsing function "get_nexthop_info_str()" that already handles recursive nexthop case.
This also improves code reuse.

How to verify it

After the fix in place perform similar show command and no longer see the error:

admin@str2-n3164-acs-1:~$ show ip route -nasic4 -d all 193.11.208.0/25
Routing entry for 193.11.208.0/25
  Known via "bgp", distance 200, metric 0, best
  Last update 13:34:33 ago
  * 10.0.0.1 (recursive)
  * 10.1.0.1, via PortChannel4004
  * 10.0.0.9 (recursive)
  * 10.1.0.5, via PortChannel4014

 admin@str2-n3164-acs-1:~$

Here is the build log that shows all test passed including my new changes in
sonic-utilities-tests/ip_show_routes_multi_asic_test.py:

...
============================= test session starts ==============================
platform linux2 -- Python 2.7.13, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: /sonic/src/sonic-utilities, inifile: pytest.ini
plugins: cov-2.4.0
collected 285 items

sonic-utilities-tests/acl_config_test.py ............
sonic-utilities-tests/acl_loader_test.py .....................
sonic-utilities-tests/aclshow_test.py ..........
sonic-utilities-tests/counterpoll_test.py ...
sonic-utilities-tests/crm_test.py ..................................................
sonic-utilities-tests/db_migrator_test.py ..............................
sonic-utilities-tests/drops_group_test.py .......
sonic-utilities-tests/feature_test.py ...............
sonic-utilities-tests/filter_fdb_entries_test.py ..........
sonic-utilities-tests/intfstat_test.py ........
sonic-utilities-tests/intfutil_test.py .........
sonic-utilities-tests/ip_show_routes_multi_asic_test.py ...............
sonic-utilities-tests/ip_show_routes_test.py ......
sonic-utilities-tests/multi_asic_intfutil_test.py ..........
sonic-utilities-tests/pfcstat_test.py .......
sonic-utilities-tests/pfcwd_test.py ............
sonic-utilities-tests/port2alias_test.py ....
sonic-utilities-tests/portstat_test.py ..................
sonic-utilities-tests/psu_test.py ...
sonic-utilities-tests/sfp_test.py .........
sonic-utilities-tests/show_ip_bgp_commands_test.py ...........
sonic-utilities-tests/show_ip_int_test.py ..........
sonic-utilities-tests/sku_create_test.py .....

========================= 285 passed in 66.24 seconds ==========================
make[1]: Leaving directory '/sonic/src/sonic-utilities/deb_dist/sonic-utilities-1.2'
 fakeroot debian/rules binary
make[1]: Entering directory '/sonic/src/sonic-utilities/deb_dist/sonic-utilities-1.2'
dh binary --with python2 --buildsystem=pybuild
   dh_testroot -O--buildsystem=pybuild
   dh_prep -O--buildsystem=pybuild
   dh_auto_install -O--buildsystem=pybuild
I: pybuild base:184: /usr/bin/python setup.py install --root /sonic/src/sonic-utilities/deb_dist/sonic-utilities-1.2/debian/python-sonic-utilities
running install
...

Note:

This change only effects DUT that are Multi-ASIC based. no impact to non-Multi-ASIC platforms.

@gechiang gechiang merged commit 391e524 into sonic-net:201911 Apr 15, 2021
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 28, 2022
a364614 2021-04-22 | [201911][acl] Use a list instead of a comma-separated string for ACL port list (sonic-net#1576) [Danny Allen]
391e524 2021-04-15 | [201911] Fix Multi-ASIC show specific resursive route (sonic-net#1563) [gechiang]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants