Commit 453fcc4b authored by Matthew Cover's avatar Matthew Cover Committed by Greg Kroah-Hartman

tuntap: fix multiqueue rx

[ Upstream commit 8ebebcba ]

When writing packets to a descriptor associated with a combined queue, the
packets should end up on that queue.

Before this change all packets written to any descriptor associated with a
tap interface end up on rx-0, even when the descriptor is associated with a
different queue.

The rx traffic can be generated by either of the following.
  1. a simple tap program which spins up multiple queues and writes packets
     to each of the file descriptors
  2. tx from a qemu vm with a tap multiqueue netdev

The queue for rx traffic can be observed by either of the following (done
on the hypervisor in the qemu case).
  1. a simple netmap program which opens and reads from per-queue
     descriptors
  2. configuring RPS and doing per-cpu captures with rxtxcpu

Alternatively, if you printk() the return value of skb_get_rx_queue() just
before each instance of netif_receive_skb() in tun.c, you will get 65535
for every skb.

Calling skb_record_rx_queue() to set the rx queue to the queue_index fixes
the association between descriptor and rx queue.
Signed-off-by: default avatarMatthew Cover <matthew.cover@stackpath.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8e201ff7
...@@ -1214,6 +1214,7 @@ static void tun_rx_batched(struct tun_struct *tun, struct tun_file *tfile, ...@@ -1214,6 +1214,7 @@ static void tun_rx_batched(struct tun_struct *tun, struct tun_file *tfile,
if (!rx_batched || (!more && skb_queue_empty(queue))) { if (!rx_batched || (!more && skb_queue_empty(queue))) {
local_bh_disable(); local_bh_disable();
skb_record_rx_queue(skb, tfile->queue_index);
netif_receive_skb(skb); netif_receive_skb(skb);
local_bh_enable(); local_bh_enable();
return; return;
...@@ -1233,8 +1234,11 @@ static void tun_rx_batched(struct tun_struct *tun, struct tun_file *tfile, ...@@ -1233,8 +1234,11 @@ static void tun_rx_batched(struct tun_struct *tun, struct tun_file *tfile,
struct sk_buff *nskb; struct sk_buff *nskb;
local_bh_disable(); local_bh_disable();
while ((nskb = __skb_dequeue(&process_queue))) while ((nskb = __skb_dequeue(&process_queue))) {
skb_record_rx_queue(nskb, tfile->queue_index);
netif_receive_skb(nskb); netif_receive_skb(nskb);
}
skb_record_rx_queue(skb, tfile->queue_index);
netif_receive_skb(skb); netif_receive_skb(skb);
local_bh_enable(); local_bh_enable();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment