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

What needs to be done to make vlan tags visible to netmap in emulated mode? #904

Open
koverskeid opened this issue Jan 12, 2023 · 9 comments

Comments

@koverskeid
Copy link

koverskeid commented Jan 12, 2023

My plan is to use netmap in a system that will be deployed at multiple locations also many years ahead in time. This makes it handy to use netmap in emulated mode to avoid clutter when the computers suddenly has a new nic.

On FreeBSD, this is not a problem, but on Linux (Ubuntu) I cannot see vlan tags, which is a huge drawback. I think I understand the explanation in #259, but I don't understand why it has to be this way.

Do I just have to accept this or is there a way to sneak around this issue somehow?

@jhk098
Copy link
Contributor

jhk098 commented Jan 14, 2023

It can be done, but it has to be implemented.

This code
https://github.com/luigirizzo/netmap/blob/master/sys/dev/netmap/netmap_generic.c#L985-L1002
must be extended to check if the mbuf m has a VLAN tag within its metadata. If present, the VLAN header must be inserted while copying data. Alternatively, the VLAN tag can be pushed back from the metadata into the packet data here
https://github.com/luigirizzo/netmap/blob/master/sys/dev/netmap/netmap_generic.c#L845

@cygnus2048
Copy link

It can be done, but it has to be implemented.

This code https://github.com/luigirizzo/netmap/blob/master/sys/dev/netmap/netmap_generic.c#L985-L1002 must be extended to check if the mbuf m has a VLAN tag within its metadata. If present, the VLAN header must be inserted while copying data. Alternatively, the VLAN tag can be pushed back from the metadata into the packet data here https://github.com/luigirizzo/netmap/blob/master/sys/dev/netmap/netmap_generic.c#L845

Do those fixes also apply to the ixgbe driver? I've been fighting this issue for quite some time with Netmap in trying to access the interface as a trunk port, i.e. multiple VLANs at once on the same interface.

@jhk098
Copy link
Contributor

jhk098 commented Jan 26, 2023

The ixgbe driver has native netmap support, so that's a different story. With native support you should be able to see the VLAN tag if you disable the VLAN hw offloads, as described in the README.md.
If you are using ixgbe with emulated netmap mode (why?) then yes, the fix will apply also in this case.

@cygnus2048
Copy link

Thanks. Yes, I am using native and not emulated mode. I also have all VLAN offloads disabled, however, I still do not receive the VLAN tags in the received packets. For performance reasons I am using a 4.4.86 kernel, (newer had much worse performance) and running inside a VM with the interface connected in PCI passthrough mode, where the complete interface is disconnected from the host and connected to the VM. In other words, I am not using VFs I was not able to get VLAN packets out/in using VFs in SR-IOV mode.

@jhk098
Copy link
Contributor

jhk098 commented Jan 27, 2023

There must be something wrong with your offload configuration...
Netmap does not modify the packet contents in any way, so if you don't see the VLAN tag it means that the NIC is stripping it for some reason. There are many VLAN-related offloads, maybe someone is still active and causing the stripping.

@jhk098
Copy link
Contributor

jhk098 commented Jan 27, 2023

Also make sure you are not using emulated mode, by checking in the dmesg.
If something like this

[ 2865.316685] 256.410317 [1136] generic_netmap_attach     Emulated adapter for enp3s2 created (prev was NULL)
[ 2865.340627] 256.434258 [ 320] generic_netmap_register   Emulated adapter for enp3s2 activated
[ 2865.340651] 256.434283 [ 864] tc_configure              ifp enp3s2 qdisc netmapemu parent 4294967295 handle 0

is present, then you are using emulated mode.

@drearms
Copy link

drearms commented Jan 27, 2023 via email

@drearms
Copy link

drearms commented Jan 28, 2023

My plan is to use netmap in a system that will be deployed at multiple locations also many years ahead in time. This makes it handy to use netmap in emulated mode to avoid clutter when the computers suddenly has a new nic.

On FreeBSD, this is not a problem, but on Linux (Ubuntu) I cannot see vlan tags, which is a huge drawback. I think I understand the explanation in #259, but I don't understand why it has to be this way.

Do I just have to accept this or is there a way to sneak around this issue somehow?

It sounds like you need a solution that allows you to use netmap in emulated mode with Linux (Ubuntu) while still allowing you to see the VLAN tags. Have you tried using a virtual switch such as Open vSwitch or OpenFlow? This would allow you to configure your network to handle VLAN tags and have the flexibility you need for your system deployment. Let me know if you need any help setting this up!

@koverskeid
Copy link
Author

My plan is to use netmap in a system that will be deployed at multiple locations also many years ahead in time. This makes it handy to use netmap in emulated mode to avoid clutter when the computers suddenly has a new nic.
On FreeBSD, this is not a problem, but on Linux (Ubuntu) I cannot see vlan tags, which is a huge drawback. I think I understand the explanation in #259, but I don't understand why it has to be this way.
Do I just have to accept this or is there a way to sneak around this issue somehow?

It sounds like you need a solution that allows you to use netmap in emulated mode with Linux (Ubuntu) while still allowing you to see the VLAN tags. Have you tried using a virtual switch such as Open vSwitch or OpenFlow? This would allow you to configure your network to handle VLAN tags and have the flexibility you need for your system deployment. Let me know if you need any help setting this up!

My intesion is to implement a prp solution, so I need to receive frames on two interfaces with or withouth vlan tags, analyze them in a user space program, drop them or modify and forward them to a tap interface. Is this possible to achieve with Open vSwitch or OpenFlow?

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

No branches or pull requests

4 participants