Skip to content

Enhance FGNHG CLI to filter by and show vnet + prefix#4510

Merged
qiluo-msft merged 6 commits into
sonic-net:masterfrom
NavdhaJindal:vnetFgEcmp
Jun 24, 2026
Merged

Enhance FGNHG CLI to filter by and show vnet + prefix#4510
qiluo-msft merged 6 commits into
sonic-net:masterfrom
NavdhaJindal:vnetFgEcmp

Conversation

@NavdhaJindal

@NavdhaJindal NavdhaJindal commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

What I did

CLI enhancement for fine grained ecmp routes, to show fg routes by specifying vnet and prefix.

New CLI added:

show fgnhg hash-view <vnet/vrf name> <prefix name>
show fgnhg active-hops <vnet/vrf name> <prefix name>

How I did it

Accept 2 positional args instead of 1. Depending on number of args, filter for:

  • 1 arg: nhg
  • 2 args: vnet and prefix

How to verify it

Usage:

$show fgnhg active-hops Vnet200 30.0.1.2/32
VNET/VRF    FG NHG Prefix    Active Next Hops
----------  ---------------  ------------------
Vnet200     30.0.1.2/32      10.10.10.20
                             10.10.2.1
                             10.10.2.2
                             10.10.2.3
                             10.10.2.4
                             10.10.2.5
                             10.10.2.6
                             10.10.2.7

$ show fgnhg active-hops
VNET/VRF    FG NHG Prefix    Active Next Hops
----------  ---------------  ------------------
default     100.1.1.0/24     10.0.0.57
	                             10.0.0.59
	                             10.0.0.61
	                             10.0.0.63
Vnet1       180.0.3.1/32     100.0.1.0
	                             100.0.1.1
                                     100.0.1.2                            
$show fgnhg hash-view Vnet200 30.0.1.2/32
VNET/VRF    FG NHG Prefix    Next Hop     Hash buckets
----------  ---------------  -----------  --------------
Vnet200     30.0.1.2/32      10.10.10.20  7   15
Vnet200     30.0.1.2/32      10.10.2.1    0   8
Vnet200     30.0.1.2/32      10.10.2.2    1   9
Vnet200     30.0.1.2/32      10.10.2.3    2   10
Vnet200     30.0.1.2/32      10.10.2.4    3   11
Vnet200     30.0.1.2/32      10.10.2.5    4   12
Vnet200     30.0.1.2/32      10.10.2.6    5   13
Vnet200     30.0.1.2/32      10.10.2.7    6   14

$ show fgnhg hash-view
VNET/VRF    FG NHG Prefix    Next Hop    Hash buckets
----------  ---------------  ----------  --------------------------
default     100.1.1.0/24     10.0.0.57   0   4   8   12  16
default     100.1.1.0/24     10.0.0.59   1   5   9   13  17
default     100.1.1.0/24     10.0.0.61   2   6   10  14  18
default     100.1.1.0/24     10.0.0.63   3   7   11  15  19
Vnet1       180.0.3.1/32     100.0.1.0   0   3   6   9   12  15  18
Vnet1       180.0.3.1/32     100.0.1.1   1   4   7   10  13  16  19
Vnet1       180.0.3.1/32     100.0.1.2   2   5   8   11  14  17

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)

Copilot AI review requested due to automatic review settings April 30, 2026 20:33
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enhances the show fgnhg CLI to surface VRF/VNET context (by adding a VNET/VRF column) and introduces a new 2-argument filter mode intended to query FGNHG data by (vrf, prefix).

Changes:

  • Added FG_ROUTE_TABLE key parsing and reused hash-bucket formatting logic to support VRF-aware output.
  • Updated show fgnhg {hash-view,active-hops} output to include VNET/VRF and added (vrf, prefix) filtering via positional args.
  • Extended unit-test mock STATE_DB data and updated/added pytest expectations for the new output and filter behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
show/fgnhg.py Adds VRF-aware key parsing/formatting and new positional-argument filtering modes for hash-view and active-hops.
tests/fgnhg_test.py Updates expected CLI output to include VNET/VRF and adds tests for (vrf, prefix) filtering and invalid VRF handling.
tests/mock_tables/state_db.json Adds a VRF/VNET-scoped `FG_ROUTE_TABLE

Comment thread show/fgnhg.py Outdated
Comment thread tests/fgnhg_test.py
Comment thread show/fgnhg.py Outdated
Comment thread show/fgnhg.py Outdated
Comment thread show/fgnhg.py
Comment thread show/fgnhg.py
Comment thread tests/fgnhg_test.py
Comment thread show/fgnhg.py Outdated
Comment thread show/fgnhg.py Outdated
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@linux-foundation-easycla

linux-foundation-easycla Bot commented May 12, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@radha-danda

Copy link
Copy Markdown

@NavdhaJindal, Please fix PR checks

@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: Navdha Jindal <navdhajindal@microsoft.com>
Signed-off-by: Navdha Jindal <navdhajindal@microsoft.com>
@prsunny

prsunny commented May 22, 2026

Copy link
Copy Markdown
Contributor

Changes lgtm, Please fix PR checker failures

Signed-off-by: Navdha Jindal <navdhajindal@microsoft.com>
@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: Navdha Jindal <navdhajindal@microsoft.com>
@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: Navdha Jindal <navdhajindal@microsoft.com>
@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: Navdha Jindal <navdhajindal@microsoft.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@prsunny

prsunny commented May 28, 2026

Copy link
Copy Markdown
Contributor

@qiluo-msft , would you help with merge?

Comment thread show/fgnhg.py
@qiluo-msft
qiluo-msft merged commit d68cdd6 into sonic-net:master Jun 24, 2026
9 checks passed
Yogapriya-cisco pushed a commit to vrajeshe/sonic-utilities that referenced this pull request Jul 10, 2026
What I did
CLI enhancement for fine grained ecmp routes, to show fg routes by specifying vnet and prefix.

New CLI added:

show fgnhg hash-view <vnet/vrf name> <prefix name>
show fgnhg active-hops <vnet/vrf name> <prefix name>
How I did it
Accept 2 positional args instead of 1. Depending on number of args, filter for:

1 arg: nhg
2 args: vnet and prefix

Signed-off-by: Yogapriya Mohankumar <ymohanku@cisco.com>
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.

7 participants