Skip to content

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

Open
NavdhaJindal wants to merge 6 commits into
sonic-net:masterfrom
NavdhaJindal:vnetFgEcmp
Open

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

Conversation

@NavdhaJindal
Copy link
Copy Markdown
Contributor

@NavdhaJindal NavdhaJindal commented Apr 30, 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

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).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 12, 2026

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
Copy link
Copy Markdown
Contributor

prsunny commented May 22, 2026

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
Copy link
Copy Markdown
Contributor

prsunny commented May 28, 2026

@qiluo-msft , would you help with merge?

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.

6 participants