-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(idpool): idpool feature for generating id's #400
base: main
Are you sure you want to change the base?
Conversation
pkg/LinuxGeneralModule/lgm.go
Outdated
func GenerateRouteTable() uint32 { | ||
return uint32(rand.Intn(RoutingTableMax-RoutingTableMin+1) + RoutingTableMin) //nolint:gosec | ||
// RoutingTableRange ModPointer structure of mod ptr definitions | ||
var RoutingTableRange = struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not used in other modules, then the type and members can be lowercased
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/LinuxGeneralModule/lgm.go
Outdated
@@ -363,7 +363,8 @@ func Initialize() { | |||
brTenant = "br-tenant" | |||
ipMtu = config.GlobalConfig.LinuxFrr.IPMtu | |||
ctx = context.Background() | |||
nlink = utils.NewNetlinkWrapperWithArgs(config.GlobalConfig.Tracer) | |||
RouteTableGen = utils.IDPoolInit("RTtable", RoutingTableRange.RoutingTableMin, RoutingTableRange.RoutingTableMax) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if RoutingTableRange is used only to put values here, then why not just use 2 constants routingTableMin
and routingTableMax
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -454,6 +455,7 @@ func setUpBridge(lb *infradb.LogicalBridge) bool { | |||
//nolint:funlen,gocognit | |||
func setUpVrf(vrf *infradb.Vrf) (string, bool) { | |||
IPMtu := fmt.Sprintf("%+v", ipMtu) | |||
var addKey int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need to declare the variable here, if you zero it on 471?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified
pkg/LinuxGeneralModule/lgm.go
Outdated
@@ -465,8 +467,12 @@ func setUpVrf(vrf *infradb.Vrf) (string, bool) { | |||
vrf.Metadata.RoutingTable = make([]*uint32, 1) | |||
vrf.Metadata.RoutingTable[0] = new(uint32) | |||
var routingTable uint32 | |||
Name := vrf.Name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please align with Go style guide:
https://google.github.io/styleguide/go/decisions.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/LinuxGeneralModule/lgm.go
Outdated
for { | ||
routingTable = GenerateRouteTable() | ||
// var key interface{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if code is not sued, it can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/utils/Idpool.go
Outdated
} | ||
|
||
// ReleaseID get the reference id | ||
func (ip *IDPool) ReleaseID(key interface{}, ref interface{}) (uint32, uint32) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see that ReleaseID is used anywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its used in vendor plugin code dcgw.go for releasing the ecmp and trie id's
pkg/utils/Idpool.go
Outdated
|
||
// IDPool structure | ||
/* Helper class for uniquely assigning IDs from a specified integer set (e.g. a | ||
# range) to keys. IDs are assigned (or read) with get_id(key) and returned back |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no get_id(key) function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/utils/Idpool.go
Outdated
// IDPool structure | ||
/* Helper class for uniquely assigning IDs from a specified integer set (e.g. a | ||
# range) to keys. IDs are assigned (or read) with get_id(key) and returned back | ||
# into the pool with release_id(key). The IDPool remembers a once-assigned ID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no release_id(key)
function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/utils/Idpool.go
Outdated
_unusedIDs []uint32 // Yet unused IDs in pool Available ids | ||
_idsInUse map[interface{}]uint32 // Mapping key: id for currently assigned ids | ||
_idsForReuse map[interface{}]uint32 // Mapping key: id for previously assigned ids | ||
_refs map[uint32][]interface{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refs sounds like a counter tracking how many times we requested the same id, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, its reference to the same id
790e754
to
eb45583
Compare
Signed-off-by: Venkatesh, Vemula <[email protected]> Signed-off-by: Atul Patel <[email protected]> Signed-off-by: Vemula Venkatesh <[email protected]>
eb45583
to
45ace4d
Compare
idpool feature for generating id's for mod pointer, routing table id , trie pointer.