Skip to content
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

merge inject and rename chain elements #306

Merged
merged 6 commits into from
Aug 17, 2021

Conversation

pperiyasamy
Copy link
Member

Fixes #102

Signed-off-by: Periyasamy Palanisamy periyasamy.palanisamy@est.tech

Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@est.tech>
Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@est.tech>
@pperiyasamy pperiyasamy force-pushed the merge-inject-rename branch from 5fd6eed to 42910ff Compare August 5, 2021 12:12
Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@est.tech>
if vfConfig != nil && vfConfig.VFInterfaceName != ifName {
err = moveInterfaceToAnotherNamespace(vfConfig.VFInterfaceName, curNetNS, curNetNS, targetNetNS)
if err == nil {
err = renameInterface(vfConfig.VFInterfaceName, ifName, curNetNS, targetNetNS)

Choose a reason for hiding this comment

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

Looks like we need to move interface back in such case.

Choose a reason for hiding this comment

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

I am afraid that this operation is not idempotent, because after the rename we still have different vfconfig.VFInterfaceName and ifName, but interface is no more accessible by vfconfig.VFInterfaceName because it was renamed.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, that's why there is a check at line 100-103 to see ifName is already present in contNetNS and if interface is already present, it's returned immediately without an error.

return nil
}

func moveToContNetNS(vfConfig *vfconfig.VFConfig, ifName string, curNetNS, targetNetNS netns.NsHandle) (err error) {

Choose a reason for hiding this comment

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

Please rename here curNetNS to hostNetNS and targetNetNS to conNetNS if you make such renaming.

Copy link
Member Author

Choose a reason for hiding this comment

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

done


func moveToHostNetNS(vfConfig *vfconfig.VFConfig, ifName string, curNetNS, targetNetNS netns.NsHandle) (err error) {
if vfConfig != nil && vfConfig.VFInterfaceName != ifName {
link, _ := kernellink.FindHostDevice("", vfConfig.VFInterfaceName, curNetNS)

Choose a reason for hiding this comment

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

If interface was renamed, we need to find it by ifName and so if we are moving it back, we probably need to find it in targetNetNS.

Copy link
Member Author

Choose a reason for hiding this comment

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

This method gets executed only for sriov device move back scenario and renaming would happen only at line 123.
This check is done to make things to be idempotent and also to find out if sriov device is accidentally moved out to hostNetNS without renaming the interface (in case of container kill), its not appropriate to rely on ifName here as multiple NSCs use same interface name. so we must also search using kernellink.FindHostDevice using VFs pci address to restore interface original name. will revisit here once this PR is merged.

err = move(logger, request.GetConnection(), true)
if err != nil {
logger.Warnf("server request failed, failed to move back the interface: %v", err)
moveRenameErr := move(ctx, request.GetConnection(), true)

Choose a reason for hiding this comment

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

Please use here isEstablished check as we discussed offline.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@est.tech>
Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@est.tech>
Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@est.tech>
@edwarnicke edwarnicke merged commit 5bdd8f7 into networkservicemesh:main Aug 17, 2021
nsmbot pushed a commit to networkservicemesh/sdk-vpp that referenced this pull request Aug 17, 2021
…k-kernel@main

PR link: networkservicemesh/sdk-kernel#306

Commit: 5bdd8f7
Author: Ed Warnicke
Date: 2021-08-17 09:17:32 -0500
Message:
  - Merge pull request #306 from Nordix/merge-inject-rename
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
@pperiyasamy pperiyasamy deleted the merge-inject-rename branch August 17, 2021 14:28
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.

Reorder inject, rename chain elements
3 participants