Skip to content

[202511][show/vnet] Fix ECMP scale formatting and per-endpoint MAC/VNI wrapping#4454

Open
miatttao wants to merge 2 commits intosonic-net:202511from
miatttao:dev/mia/fix-pretty-print-202511
Open

[202511][show/vnet] Fix ECMP scale formatting and per-endpoint MAC/VNI wrapping#4454
miatttao wants to merge 2 commits intosonic-net:202511from
miatttao:dev/mia/fix-pretty-print-202511

Conversation

@miatttao
Copy link
Copy Markdown
Contributor

@miatttao miatttao commented Apr 13, 2026

What I did

  • Fixed show vnet routes output becoming unreadable at large ECMP scale (e.g. ~511 endpoints), where all endpoints were previously printed on a single line, causing column overflow and table misalignment.
  • Extended the pretty‑print logic to wrap endpoint, mac_address, and vni together so per‑endpoint fields stay aligned at any ECMP scale.
  • Updated tunnel route output to consistently include the metric field.
  • Made the CLI more robust when optional fields are missing from DB entries, preventing runtime errors

How I did it

  • Refactored the pretty‑print helper to:
    • Accept metric and handle per‑endpoint mac_address / vni lists.
    • Split all per‑endpoint fields by comma and wrap them in identical chunks so each row remains aligned.
  • Computed row_width based on the longest element across endpoint, mac_address, and vni, ensuring wide MAC addresses don’t overflow the terminal.
  • Removed the tunnel‑route special case (if len(epval) < 40) so all routes go through the same pretty‑print path for consistent behavior.
  • Added and updated unit tests to validate:
    • Pretty‑print behavior directly.
    • Large‑scale MAC/VNI list scenarios.
    • CLI output for local, tunnel, and filtered route variants.

Tests added/updated:

  • test_pretty_print_basic
  • test_show_vnet_routes_all_basic
  • test_show_vnet_routes_all_vnetname
  • test_show_vnet_routes_tunnel_basic
  • test_show_vnet_routes_tunnel_vnetname
  • test_show_vnet_routes_local_basic
  • test_show_vnet_routes_local_vnetname
  • test_show_vnet_routes_tunnel_mac_vni_list (scale case)

How to verify it

image

Previous command output (if the output of a command-line utility has changed)

show vnet routes all

vnet name        prefix                    endpoint                                     mac address    vni    metric    status
----------------  ------------------------  -------------------------------------------  -------------  -----  --------  --------
Vnet_v6_in_v6-0  fddd:a156:a251::a6:1/128  fddd:a100:a251::a10:1,fddd:a101:a251::a10:1                                  active
                                           fddd:a102:a251::a10:1,fddd:a103:a251::a10:1
test_v4_in_v4-0  160.162.191.1/32          100.251.7.1                                                                  active
test_v4_in_v4-0  160.163.191.1/32          100.251.7.1                                                        0         active
test_v4_in_v4-0  160.164.191.1/32          100.251.7.1

show vnet routes tunnel

vnet name        prefix                    endpoint                                     mac address    vni    metric    status
----------------  ------------------------  -------------------------------------------  -------------  -----  --------  --------
Vnet_v6_in_v6-0  fddd:a156:a251::a6:1/128  fddd:a100:a251::a10:1,fddd:a101:a251::a10:1                                  active
                                           fddd:a102:a251::a10:1,fddd:a103:a251::a10:1
test_v4_in_v4-0  160.162.191.1/32          100.251.7.1                                                                  active
test_v4_in_v4-0  160.163.191.1/32          100.251.7.1                                                        0         active
test_v4_in_v4-0  160.164.191.1/32          100.251.7.1

show vnet routes tunnel <vnet_name> (previous example: test_v4_in_v4-0)

vnet name        prefix            endpoint     mac address    vni      metric  status
---------------  ----------------  -----------  -------------  -----  --------  --------
test_v4_in_v4-0  160.162.191.1/32  100.251.7.1                                  active
test_v4_in_v4-0  160.163.191.1/32  100.251.7.1                               0  active
test_v4_in_v4-0  160.164.191.1/32  100.251.7.1

New command output (if the output of a command-line utility has changed)

show vnet routes all

vnet name           prefix                    endpoint                                     mac address                          vni      metric    status
------------------  ------------------------  -------------------------------------------  -----------------------------------  -------  --------  --------
Vnet_mac_vni_scale  10.0.0.0/24               10.0.0.1,10.0.0.2                            aa:bb:cc:00:00:01,aa:bb:cc:00:00:02  100,200            active
                                              10.0.0.3,10.0.0.4                            aa:bb:cc:00:00:03,aa:bb:cc:00:00:04  300,400
                                              10.0.0.5,10.0.0.6                            aa:bb:cc:00:00:05,aa:bb:cc:00:00:06  500,600
Vnet_v6_in_v6-0     fddd:a156:a251::a6:1/128  fddd:a100:a251::a10:1,fddd:a101:a251::a10:1                                                          active
                                              fddd:a102:a251::a10:1,fddd:a103:a251::a10:1
test_v4_in_v4-0     160.162.191.1/32          100.251.7.1                                                                                          active
test_v4_in_v4-0     160.163.191.1/32          100.251.7.1                                                                                0         active
test_v4_in_v4-0     160.164.191.1/32          100.251.7.1

show vnet routes tunnel

vnet name           prefix                    endpoint                                     mac address                          vni      metric    status
------------------  ------------------------  -------------------------------------------  -----------------------------------  -------  --------  --------
Vnet_mac_vni_scale  10.0.0.0/24               10.0.0.1,10.0.0.2                            aa:bb:cc:00:00:01,aa:bb:cc:00:00:02  100,200            active
                                              10.0.0.3,10.0.0.4                            aa:bb:cc:00:00:03,aa:bb:cc:00:00:04  300,400
                                              10.0.0.5,10.0.0.6                            aa:bb:cc:00:00:05,aa:bb:cc:00:00:06  500,600
Vnet_v6_in_v6-0     fddd:a156:a251::a6:1/128  fddd:a100:a251::a10:1,fddd:a101:a251::a10:1                                                          active
                                              fddd:a102:a251::a10:1,fddd:a103:a251::a10:1
test_v4_in_v4-0     160.162.191.1/32          100.251.7.1                                                                                          active
test_v4_in_v4-0     160.163.191.1/32          100.251.7.1                                                                                0         active
test_v4_in_v4-0     160.164.191.1/32          100.251.7.1

show vnet routes tunnel <vnet_name> new example: test_v4_in_v4-0

vnet name        prefix            endpoint     mac address    vni    metric    status
---------------  ----------------  -----------  -------------  -----  --------  --------
test_v4_in_v4-0  160.162.191.1/32  100.251.7.1                                  active
test_v4_in_v4-0  160.163.191.1/32  100.251.7.1                        0         active
test_v4_in_v4-0  160.164.191.1/32  100.251.7.1

show vnet routes tunnel Vnet_mac_vni_scale (new scale case)

vnet name           prefix       endpoint           mac address                          vni      metric    status
------------------  -----------  -----------------  -----------------------------------  -------  --------  --------
Vnet_mac_vni_scale  10.0.0.0/24  10.0.0.1,10.0.0.2  aa:bb:cc:00:00:01,aa:bb:cc:00:00:02  100,200            active
                                 10.0.0.3,10.0.0.4  aa:bb:cc:00:00:03,aa:bb:cc:00:00:04  300,400
                                 10.0.0.5,10.0.0.6  aa:bb:cc:00:00:05,aa:bb:cc:00:00:06  500,600

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@miatttao miatttao force-pushed the dev/mia/fix-pretty-print-202511 branch from 1bd4f6a to 1ebdac1 Compare April 15, 2026 23:20
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@miatttao miatttao force-pushed the dev/mia/fix-pretty-print-202511 branch from 1ebdac1 to 43ef5e8 Compare April 16, 2026 00:14
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@miatttao miatttao force-pushed the dev/mia/fix-pretty-print-202511 branch from 43ef5e8 to 9ba5d51 Compare April 16, 2026 00:16
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@anish-n
Copy link
Copy Markdown

anish-n commented Apr 16, 2026

Would you please add a PR description, and CLI output to the description?

@miatttao miatttao force-pushed the dev/mia/fix-pretty-print-202511 branch from 9ba5d51 to 2241d7b Compare April 16, 2026 00:19
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@miatttao miatttao force-pushed the dev/mia/fix-pretty-print-202511 branch from 2241d7b to 82307ff Compare April 16, 2026 18:32
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@miatttao miatttao changed the title [show/vnet]: Fix ECMP scale formatting and per-endpoint MAC/VNI wrapping [202511][show/vnet]: Fix ECMP scale formatting and per-endpoint MAC/VNI wrapping Apr 16, 2026
@miatttao miatttao changed the title [202511][show/vnet]: Fix ECMP scale formatting and per-endpoint MAC/VNI wrapping [202511][show/vnet] Fix ECMP scale formatting and per-endpoint MAC/VNI wrapping Apr 16, 2026
@miatttao
Copy link
Copy Markdown
Contributor Author

Would you please add a PR description, and CLI output to the description?

Hi Anish, yes—thank you for the reminder! I’ve added the PR description and the CLI output to the description. Please take a look when you have a chance.

@alawing
Copy link
Copy Markdown
Contributor

alawing commented Apr 20, 2026

Please make reference document changes in doc/Command-Reference.md

@miatttao miatttao force-pushed the dev/mia/fix-pretty-print-202511 branch from 82307ff to e9df0a3 Compare April 21, 2026 18:43
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@miatttao miatttao force-pushed the dev/mia/fix-pretty-print-202511 branch from e9df0a3 to 1b76134 Compare April 21, 2026 20:23
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@miatttao miatttao force-pushed the dev/mia/fix-pretty-print-202511 branch from 1b76134 to 33570d2 Compare April 21, 2026 20:40
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: miatao <miatao@microsoft.com>
@miatttao miatttao force-pushed the dev/mia/fix-pretty-print-202511 branch from 33570d2 to b9f6904 Compare April 21, 2026 22:10
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

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.

4 participants