3

I am trying to understand how Multiqueue tuntap interface works. Following the instructions provided at: https://www.kernel.org/doc/Documentation/networking/tuntap.txt I was able to create multiple queues. However, I don't know how to check the queus status and where they are created. I tried:

$ tc -s class show dev tap0

(where tap0 is my tap interface), I see around 255 queues, even for a single ioctl call with IFF_MULTI_QUEUE flag. So probably I am looking at the wrong place. Here is the snippet of the output of the above command:

class mq :1 root
 Sent 4741 bytes 37 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
class mq :2 root
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
.
.
.
class mq :ff root
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
class mq :100 root
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0

Secondly, I am not sure how to steer packets to these queues based on some filter or classifier using TC or any other tool. I'll really appreciate if someone can shed some light on it.

PS: I'm not sure which is the best forum to ask such questions and will appreciate if someone can point me to the right one. I have tried: https://unix.stackexchange.com/questions/496043/multiqueue-tun-tap-interface but haven't got any convincing answer yet. Thanks!

Deys Nima
  • 51
  • 5

1 Answers1

2

Okay for the second question, with several trials and errors, I am able to steer packets to particular classes. It was more of an exploratory effort so not sure if it is the "best" way. Here is a brief background that what I wanted to achieve: Suppose, if we have a multi-queue tap interface with two queues and corresponding fds, fd1 and fd2 then I wanted to receive special flows on fd1, and rest of them to fd2. I was able to create two queues at the application layer, again using this link. But the packets were getting assigned randomly to these queues, probably based on their hashes.

To steer packets to a particular flow and eventually to their corresponding fds, I used tc-multiq. If you create classes using tc multiq on a multi-queue tap interface, you'd get as many classes as supported by tap interface; for the above example, I got two. Then you can leverage tc filters and action (skbedit) for queue mapping.

Steps to follow:

Create tap interfaces first (using my own program and script here).

$ ./createTap.sh tap0

Check the number of queues. I am still not sure why we see 255 classes here (question 1 of my original post).

$ tc -s class show dev tap0 class mq :1 root Sent 4741 bytes 37 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 class mq :2 root Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 . . . class mq :ff root Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 class mq :100 root Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0

Let's create multiq on tap0:

$ tc qdisc add dev tap0 root handle 1: multiq

Check how many classes we have now. Note that we have only 2 classes now instead of 255:

$ tc -s class show dev class multiq 1:1 parent 1: Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 class multiq 1:2 parent 1: Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 `

Finally, use tc filters to steer packets as you want.

Hope this is helpful for others!

Deys Nima
  • 51
  • 5