Skip to content

[202506] Fix ECMP scale formatting and per-endpoint MAC/VNI wrapping#322

Merged
prsunny merged 2 commits intoAzure:202506from
miatttao:dev/mia/fix-pretty-print-formatting
Apr 30, 2026
Merged

[202506] Fix ECMP scale formatting and per-endpoint MAC/VNI wrapping#322
prsunny merged 2 commits intoAzure:202506from
miatttao:dev/mia/fix-pretty-print-formatting

Conversation

@miatttao
Copy link
Copy Markdown

@miatttao miatttao commented Apr 28, 2026

This is a manual cherry-pick of master PR sonic-net/sonic-utilities#4452 due to merge conflicts.

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

@anish-n
Copy link
Copy Markdown

anish-n commented Apr 30, 2026

@miatttao please link the master PR in description

@prsunny prsunny merged commit d971a6e into Azure:202506 Apr 30, 2026
3 checks passed
@miatttao
Copy link
Copy Markdown
Author

@miatttao please link the master PR in description

Yes, linked!

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.

3 participants