Skip to content

Use temporary name for netdevice when moving in/out of NS#1002

Merged
s1061123 merged 1 commit intocontainernetworking:mainfrom
adrianchiris:use-temp-name
Mar 12, 2024
Merged

Use temporary name for netdevice when moving in/out of NS#1002
s1061123 merged 1 commit intocontainernetworking:mainfrom
adrianchiris:use-temp-name

Conversation

@adrianchiris
Copy link
Copy Markdown
Contributor

@adrianchiris adrianchiris commented Jan 23, 2024

Today, it is not possible to use host-device CNI to move a
host device to container namespace if a device with the same
netdev name already exists in that namespace.

e.g when a delegate plugin (such as multus) is used to provide
multiple networks to a container, CNI Add call will fail if
the targeted host device name already exists in container network
namespace.

to overcome this, we use a temporary name for the interface before
moving it in/out of container network namespace.

@adrianchiris adrianchiris force-pushed the use-temp-name branch 3 times, most recently from 8dd7158 to 90db66c Compare January 23, 2024 13:04
@adrianchiris
Copy link
Copy Markdown
Contributor Author

@squeed @dcbw could you take a look a this one :)

Copy link
Copy Markdown
Contributor

@s1061123 s1061123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrianchiris sorry to review this. It looks good to me almost code. Regarding error handling, I added one comment. could you please take a look into it? Thanks!


tempDev, err := setTempName(hostDev)
if err != nil {
return nil, fmt.Errorf("failed to rename device %q to temporary name: %v", hostDevName, err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If moveLinkIn() is called with interface Up and failed at here (or later), then the interface goes down and not up. I suppose to add the code to revert (i.e. LinkSetUp()) at error-return case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added logic to restore netdev:

  • bring back to host namespace
  • retore netdev name
  • restore link status

Today, it is not possible to use host-device CNI to move a
host device to container namespace if a device already exists
in that namespace.

e.g when a delegate plugin (such as multus) is used to provide
multiple networks to a container, CNI Add call will fail if
the targeted host device name already exists in container network
namespace.

to overcome this, we use a temporary name for the interface before
moving it in/out of container network namespace.

Signed-off-by: adrianc <[email protected]>
@adrianchiris
Copy link
Copy Markdown
Contributor Author

@s1061123 thx for reviewing. comment addressed.

Copy link
Copy Markdown
Contributor

@s1061123 s1061123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM'ed!

@s1061123 s1061123 merged commit 7567d28 into containernetworking:main Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants