diff --git a/afthelper/afthelper.go b/afthelper/afthelper.go index 4f819673..1d72e907 100644 --- a/afthelper/afthelper.go +++ b/afthelper/afthelper.go @@ -31,6 +31,8 @@ type NextHopSummary struct { Address string `json:"address"` // NetworkInstance is the network instance within which the address was resolved. NetworkInstance string `json:"network-instance"` + // Index is the gRIBI index of the next hop. + Index uint64 `json:"index"` } // NextHopAddrsForPrefix unrolls the prefix specified within the network-instance netInst from the @@ -96,6 +98,7 @@ func NextHopAddrsForPrefix(rib map[string]*aft.RIB, netinst, prefix string) (map Address: nh, Weight: weights[nhID], NetworkInstance: nhNI, + Index: nhID, } } diff --git a/afthelper/afthelper_test.go b/afthelper/afthelper_test.go index 261637d0..49ddf086 100644 --- a/afthelper/afthelper_test.go +++ b/afthelper/afthelper_test.go @@ -52,6 +52,7 @@ func TestNextHopAddrsForPrefix(t *testing.T) { Weight: 1, Address: "1.1.1.1", NetworkInstance: defName, + Index: 1, }, }, }, { @@ -74,11 +75,13 @@ func TestNextHopAddrsForPrefix(t *testing.T) { Address: "1.1.1.1", Weight: 1, NetworkInstance: defName, + Index: 1, }, "2.2.2.2": { Address: "2.2.2.2", Weight: 1, NetworkInstance: defName, + Index: 2, }, }, }, { @@ -101,11 +104,13 @@ func TestNextHopAddrsForPrefix(t *testing.T) { Address: "1000:10:10::10", Weight: 1, NetworkInstance: defName, + Index: 1, }, "2.2.2.2": { Address: "2.2.2.2", Weight: 1, NetworkInstance: defName, + Index: 2, }, }, }, { @@ -144,6 +149,7 @@ func TestNextHopAddrsForPrefix(t *testing.T) { Weight: 2, Address: "2.2.2.2", NetworkInstance: "VRF-1", + Index: 2, }, }, }, { @@ -172,11 +178,13 @@ func TestNextHopAddrsForPrefix(t *testing.T) { Address: "1000:10:10::10", Weight: 1, NetworkInstance: "VRF-1", + Index: 1, }, "2.2.2.2": { Address: "2.2.2.2", Weight: 1, NetworkInstance: "VRF-1", + Index: 2, }, }, }} diff --git a/rib/rib_test.go b/rib/rib_test.go index cf26144b..3b3d53cf 100644 --- a/rib/rib_test.go +++ b/rib/rib_test.go @@ -4382,6 +4382,7 @@ func TestResolvedEntryHook(t *testing.T) { Weight: 32, Address: "1.1.1.1", NetworkInstance: "DEFAULT", + Index: 1, }, } if diff := cmp.Diff(got, want); diff != "" { @@ -4429,6 +4430,7 @@ func TestResolvedEntryHook(t *testing.T) { Weight: 32, Address: "1000:10:10::10", NetworkInstance: "DEFAULT", + Index: 10, }, } if diff := cmp.Diff(got, want); diff != "" {