{{ message }}
Repository navigation
libct: fix netDevices rename with %d template - #5554
Open
samridh10exe wants to merge 2 commits into
Open
samridh10exe wants to merge 2 commits into
samridh10exe wants to merge 2 commits into
Conversation
The runtime-spec allows a netDevices name such as "eth%d", in which case the kernel replaces %d with the lowest number not yet used in the target network namespace. runc passed the template to the kernel as is, but then looked up the moved interface by the template itself, so creating the container failed with "link not found for interface eth%d". When the new name has %d, record the interface names in the target namespace before the move, and afterwards pick the new interface whose name matches the template. Add integration tests for both a new and a precreated network namespace (with the first name already taken). Fixes: opencontainers#5548 Signed-off-by: Samridh <109811970+samridh10exe@users.noreply.github.com>
The previous commit found the moved interface by diffing the names in the target network namespace before and after the move. When two containers move devices into the same network namespace at the same time, both can see the other's new interface as new, and both pick the same one. Instead, move the device under a unique temporary name, look it up by that name, and then rename it with the template inside the target namespace, where the kernel resolves %d. The link is then read back by its ifindex, which does not change while it stays in that namespace. Signed-off-by: Samridh <109811970+samridh10exe@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The runtime-spec allows a netDevices name such as
eth%d, in which case the kernel replaces%dwith the lowest number not yet used in the target network namespace. runc passed the template to the kernel as is, but then looked up the moved interface by the template itself, so creating the container failed withlink not found for interface eth%d.When the new name has
%d, record the interface names in the target namespace before the move, and afterwards pick the new interface whose name matches the template. Add integration tests for both a new and a precreated network namespace (with the first name already taken).Tested with
make localintegration TESTPATH=/netdev.bats: the two new tests fail on main and all 11 pass with this change.Fixes #5548