Skip to content
Snippets Groups Projects
Commit 0e00270b authored by cedi's avatar cedi
Browse files

Add GetRIBNames

parent d50f66fa
Branches
No related tags found
No related merge requests found
...@@ -121,3 +121,16 @@ func (v *VRF) RIBByName(name string) (rib *locRIB.LocRIB, found bool) { ...@@ -121,3 +121,16 @@ func (v *VRF) RIBByName(name string) (rib *locRIB.LocRIB, found bool) {
rib, found = v.ribNames[name] rib, found = v.ribNames[name]
return rib, found return rib, found
} }
// GetRIBNames returns an []string containing all rib-names
func (v *VRF) GetRIBNames() []string {
v.mu.Lock()
defer v.mu.Unlock()
ribNames := make([]string, 0)
for ribName := range v.ribNames {
ribNames = append(ribNames, ribName)
}
return ribNames
}
...@@ -81,3 +81,15 @@ func TestUnregister(t *testing.T) { ...@@ -81,3 +81,15 @@ func TestUnregister(t *testing.T) {
_, found = globalRegistry.vrfsID[vrfID] _, found = globalRegistry.vrfsID[vrfID]
assert.False(t, found, "vrf must not be in global registry") assert.False(t, found, "vrf must not be in global registry")
} }
func TestGetRIBNames(t *testing.T) {
vrfName := "namedRIBs"
vrfID := uint32(8)
v, err := New(vrfName, vrfID)
assert.Nil(t, err, "error must be nil on first invokation")
ribNames := v.GetRIBNames()
expectedRibNames := []string{"inet.8", "inet6.8"}
assert.EqualValues(t, expectedRibNames, ribNames, "rib names must match")
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment