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

removed subshelling for link creation #209

Merged
merged 6 commits into from
Jan 5, 2021
Merged

removed subshelling for link creation #209

merged 6 commits into from
Jan 5, 2021

Conversation

hellt
Copy link
Member

@hellt hellt commented Dec 29, 2020

Hi @karimra @steiler

I'd had a festive morning where I wanted to look into the #68 more closely. @steiler I decided to create a new PR, since I had to use different approach than you proposed in #123, I will explain why.

1 Link MTU

First, I decided to add an MTU config parameter to the Link object to allow for MTU configuration on veth links https://github.com/srl-wim/container-lab/compare/native-veth?expand=1#diff-24901324638614d6ed95797828a77247d9dad583c83606ec43cce4f7ed2e8269R129

The Link MTU defaults to 1500 if not set - https://github.com/srl-wim/container-lab/compare/native-veth?expand=1#diff-24901324638614d6ed95797828a77247d9dad583c83606ec43cce4f7ed2e8269R475-R478

2 NSPath is part of Node

I added NSPath field to Node struct. This string field contains a path to the netns file descriptor of the namespace this node(container) is in. https://github.com/srl-wim/container-lab/compare/native-veth?expand=1#diff-24901324638614d6ed95797828a77247d9dad583c83606ec43cce4f7ed2e8269R122

The NSPath is used in the veth creation code, that takes this path to put a veth endpoint into the relevant netns

3 Removed InitVirtualWiring entirely

I removed the InitVirtualWiring func, because all it was doing is cleaning up the interfaces in the host NS which might be left hanging after the previous deployments. It is not needed anymore, since the code that creates the veth interfaces now will clean them up if something goes wrong during the creation.

4 veth creation

The root of this change is in the CreateVirtualWiring func https://github.com/srl-wim/container-lab/compare/native-veth?expand=1#diff-1a8d111c070c6cf01d39d5f2935d710f1e09fe35101cd75796f8cec113133b32R24

It now has a single private function that will handle both vethToNS and vethToBridge creation methods.

It uses a new struct vEthEndpoint which defines the veth endpoint https://github.com/srl-wim/container-lab/compare/native-veth?expand=1#diff-1a8d111c070c6cf01d39d5f2935d710f1e09fe35101cd75796f8cec113133b32R24

@steiler the reason I needed to create a new PR, is because I read how CNI creates veth interfaces, and they use ns package (github.com/containernetworking/plugins/pkg/ns) that has a Do() function that wraps all the thread locking techniques. That enables us to not tackle that ourselves and rely on a proven techniques.

I did test the new code on a large scale deployment (20,4,2 scenario) and it worked faster than original subshelling method. But it would be good if you try it yourselves.

close #68, #123

clab/netlink.go Outdated Show resolved Hide resolved
clab/netlink.go Outdated Show resolved Hide resolved
clab/netlink.go Outdated Show resolved Hide resolved
clab/netlink.go Outdated Show resolved Hide resolved
clab/netlink.go Outdated Show resolved Hide resolved
clab/netlink.go Outdated Show resolved Hide resolved
clab/netlink.go Outdated Show resolved Hide resolved
clab/config.go Outdated Show resolved Hide resolved
clab/netlink.go Outdated Show resolved Hide resolved
clab/netlink.go Outdated Show resolved Hide resolved
@hellt
Copy link
Member Author

hellt commented Dec 30, 2020

Thank you for your thorough review @karimra!

clab/netlink.go Outdated Show resolved Hide resolved
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.

container attachement without subshelling
2 participants