-
Notifications
You must be signed in to change notification settings - Fork 225
fix(libnetwork): interface name length validation #2372
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
fix(libnetwork): interface name length validation #2372
Conversation
libnetwork/internal/util/validate.go
Outdated
| if ifName == "." || ifName == ".." { | ||
| return fmt.Errorf("interface name is . or ..: %w", types.ErrInvalidArg) | ||
| } | ||
| for _, r := range ifName { |
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.
Use strings.ContainsAny here instead
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.
|
Code LGTM. @Luap99 PTAL. Can we test this in c/common or do we need a Podman test once this vendors? |
Luap99
left a comment
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 squash the commits and add tests for each error case in libnetwork/netavark/config_test.go
1587d76 to
a9b4f91
Compare
Implements interface name length validation during network creation to prevent netlink errors when names exceed the kernel's 15-character limit. This prevents creation of networks with interface names that would cause failures when running containers. Signed-off-by: Lucas Pablo Calisi <lucas.calisi@mercadolibre.com>
a9b4f91 to
c83bc2b
Compare
|
LGTM |
Luap99
left a comment
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.
/lgtm
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lpcalisi, Luap99 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
8077163
into
containers:main
Description
The Linux kernel imposes a 15-character limit on network interface names. Currently,
Podman allows creating networks with interface names longer than this limit, which
leads to runtime failures when attempting to use these networks.
How to reproduce error
For example:
Fix
This change adds validation during network creation by adopting the same approach
used in the CNI project, which already handles this kernel limitation.