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

Add the tun mounting with vhost is requested #394

Merged
merged 1 commit into from
Nov 16, 2021

Conversation

SchSeba
Copy link
Collaborator

@SchSeba SchSeba commented Oct 28, 2021

This commit add also the tun device into the container.
This is needed to create tap devices inside the container network namespace

Vhost-net is used to accelerate the dpdk connected to kernel networking using tap devices.

Signed-off-by: Sebastian Sch sebassch@gmail.com

@SchSeba
Copy link
Collaborator Author

SchSeba commented Oct 28, 2021

@adrianchiris @martinkennelly can you please have a look on this PR please, I will like to get your comments about it.

@SchSeba
Copy link
Collaborator Author

SchSeba commented Oct 28, 2021

/cc @zshi-redhat

@zshi-redhat
Copy link
Collaborator

/cc @NicolasDichtel

return GetVhostNetDeviceSpec()
deviceSpec[0] = GetVhostNetDeviceSpec()[0]

if !TunDeviceExist() {
Copy link
Contributor

@adrianchiris adrianchiris Nov 2, 2021

Choose a reason for hiding this comment

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

This means we now require /dev/net/tun to exist when needVhostNet is set to true in resource config.

is there no use-case for vhost-net without tun device ? (there must be because that how it was working before :))

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the comment!

That was my question I am not aware from our side of any use case that we use vhost until now.
Now we have a use-case (dpdk slow path/ vpp) there is a need to create a tap device and for that, the tun device should be available inside the pod.

The other solution is to have a new flag for the tun device but I will like to know if there is a use-case for only vhost-net mount if not I don't see a reason to create another flag to will be always equal to the vhost one

Copy link
Contributor

Choose a reason for hiding this comment

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

With our use case, we also need /dev/net/tun, it is exported to via:
volumes:
- hostPath:
path: /dev/net/tun
type: ""
name: net

Copy link
Contributor

Choose a reason for hiding this comment

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

@amorenoz I see you also participated in discussions on the original vhostNet support PR #228
any thoughts on this ? do you see a case where we need vhost but not /dev/net/tun ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not with upstream DPDK. The vhost-net (virtio-user) PMD creates a tap device and configures it as the backend of the vhost-net device.

Copy link
Contributor

Choose a reason for hiding this comment

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

ack, thanks for the input. if all use-cases sift down to needing tun as well, to me it makes sense to provide it as a mount when needVhostNet is specified.

lets see if we get additional inputs, maybe raise this in one of the NPWG network resource mgmt meeting ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will do it at the next meeting thanks everyone for the inputs!

Copy link
Contributor

@adrianchiris adrianchiris left a comment

Choose a reason for hiding this comment

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

Could you also update documentation as well to mention this new mount ?

if !VhostNetDeviceExist() {
glog.Errorf("GetDeviceSpecs(): /dev/vhost-net doesn't exist")
return nil
}
return GetVhostNetDeviceSpec()
deviceSpec[0] = GetVhostNetDeviceSpec()[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just

deviceSpec := GetVhostNetDeviceSpec()

...
...

deviceSpec := append(deviceSpec, GetTunDeviceSpec()...)
return deviceSpec

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just didn't want to append as in the underling it will create a new slice and copy everything but again here is only a small slice so if you want I can change the code :)

Copy link
Contributor

Choose a reason for hiding this comment

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

also, if later on, if either GetVhostNetDeviceSpec() or GetTunDeviceSpec() end up returning more than one element, you will not need to change here :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

works for me :)

@SchSeba SchSeba force-pushed the add_tun_mount branch 2 times, most recently from 8c009a6 to f83cd6c Compare November 15, 2021 12:33
@SchSeba
Copy link
Collaborator Author

SchSeba commented Nov 15, 2021

document updated.

@adrianchiris can you have another round of review please

This commit add also the tun device into the container.
This is needed to create tap devices inside the container network namespace

Vhost-net is used to accelerate the dpdk connected to kernel networking using tap devices.

Signed-off-by: Sebastian Sch <sebassch@gmail.com>
@@ -72,11 +72,20 @@ func NewVhostNetInfoProvider() types.DeviceInfoProvider {
/* DeviceInfoProvider Interface */

func (rip *vhostNetInfoProvider) GetDeviceSpecs() []*pluginapi.DeviceSpec {

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove newline, un-needed change

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done thanks, the linter was complaining about it :)

@zshi-redhat
Copy link
Collaborator

merge with two approvals.

@zshi-redhat zshi-redhat merged commit d9891af into k8snetworkplumbingwg:master Nov 16, 2021
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.

5 participants