Bug 241737 - cannot use the tap interface name to build a VM
Summary: cannot use the tap interface name to build a VM
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bhyve (show other bugs)
Version: 12.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-virtualization (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2019-11-05 16:43 UTC by Fabien Costard
Modified: 2021-08-20 07:18 UTC (History)
1 user (show)

See Also:


Attachments
modification on pci_virtio_net.c (3.35 KB, patch)
2019-11-05 16:43 UTC, Fabien Costard
no flags Details | Diff
update_code on pci_virtio_net.c (3.04 KB, patch)
2019-11-27 15:33 UTC, Fabien Costard
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fabien Costard 2019-11-05 16:43:31 UTC
Created attachment 208881 [details]
modification on pci_virtio_net.c

Hi,
If a tap interface is created with a name, it is not possible to start a VM with bhyve using this name. We must use the device name.

For example, I create this interface (sysctl is correctly configured to use tap):
ifconfig tap create name port1

when I launch the VM (after loaded it for sure)
bhyve -c 1 -m 256 -A -H -P -s 0:0,hostbridge -s 1,virtio-net,port1 -s 2:0 virtio-blk,/root/rFreeBSD.img -s 31,lpc -l com1,/dev/nmdm0A rFreeBSD

The network will not work because the command is only develop to check device in /dev/.

I add some code to check if the name matches with a interface and replace it to create the virtual interface

I hope I was enough clear and my code not too ugly
Comment 1 Kyle Evans freebsd_committer freebsd_triage 2019-11-07 13:54:15 UTC
(In reply to Fabien Costard from comment #0)

Hmm... unfortunately, this should work fine in -CURRENT and stable/12, but the patch will not go to stable/11 and did not make it into 12.1. The merged tuntap(4) will create a dev alias for the different name:

root@viper:/usr/src# ifconfig tap create name port1
port1
root@viper:/usr/src# ls -l /dev | grep tap
lrwxr-xr-x  1 root  wheel        4 Nov  7 07:52 port1 -> tap0
crw-------  1 uucp  dialer    0x60 Nov  7 07:52 tap0

I do not have any insight into how -virtualization would prefer to proceed, but this is news from the tun/tap side. =-)
Comment 2 Fabien Costard 2019-11-11 21:35:48 UTC
(In reply to Kyle Evans from comment #1)
Hi,

That is a good with the link. As advice me a friend, I am also trying to find another way (to myself, this is a good way to learn) to find the source device file instead of checking the /dev folder. I hope it will be more generic
Comment 3 Fabien Costard 2019-11-27 15:33:26 UTC
Created attachment 209488 [details]
update_code on pci_virtio_net.c

Hello,

My code was very ugly and bad.. It does not work well. I find I have an issue when I used more that 8 tap interfaces.

After I worked on memory allocation & co... I send you for memories an upgrade of the code.

I know about the previous comments, but I do not want to let a wrong code :-)

Regards,
Fabien
Comment 4 Fabien Costard 2021-08-20 07:18:48 UTC
Ok with the link :-)

Thanks !