-
Notifications
You must be signed in to change notification settings - Fork 36
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
Make the kernel generateInterfaceName function public #1607
Make the kernel generateInterfaceName function public #1607
Conversation
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1607 +/- ##
=======================================
Coverage ? 67.42%
=======================================
Files ? 264
Lines ? 12493
Branches ? 0
=======================================
Hits ? 8424
Misses ? 3545
Partials ? 524 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
pkg/tools/nanoid/utils.go
Outdated
|
||
// GenerateLinuxInterfaceName - returns a random interface name with "nsm" prefix | ||
// to achieve a 1% chance of name collision, you need to generate approximately 68 billon names | ||
func GenerateLinuxInterfaceName(generator func(int) (string, error)) (string, error) { |
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.
func GenerateLinuxInterfaceName(generator func(int) (string, error)) (string, error) { | |
func GenerateLinuxInterfaceName() (string, error) { |
pkg/tools/nanoid/utils.go
Outdated
// to achieve a 1% chance of name collision, you need to generate approximately 68 billon names | ||
func GenerateLinuxInterfaceName(generator func(int) (string, error)) (string, error) { | ||
ifIDLen := kernelmech.LinuxIfMaxLength - len(ifPrefix) | ||
id, err := generator(ifIDLen) |
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.
id, err := generator(ifIDLen) | |
id, err := RandomString(ifIDLen, WithAlphabet(...)) |
@@ -58,7 +58,7 @@ func (m *kernelMechanismServer) Request(ctx context.Context, request *networkser | |||
if m.interfaceName != "" { | |||
mechanism.SetInterfaceName(m.interfaceName) | |||
} else { | |||
ifname, err := generateInterfaceName(m.interfaceNameGenerator) | |||
ifname, err := nanoid.GenerateLinuxInterfaceName(m.interfaceNameGenerator) |
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.
ifname, err := nanoid.GenerateLinuxInterfaceName(m.interfaceNameGenerator) | |
ifname, err := nanoid.GenerateLinuxInterfaceName() |
Description
Issue link
networkservicemesh/integration-k8s-gke#435
How Has This Been Tested?
Types of changes