tuntap: fix multiqueue rx

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: Matthew Cover <matthew.cover@stackpath.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Matthew Cover and committed by David S. Miller 8ebebcba 7ddacfa5

+6 -1
+6 -1
drivers/net/tun.c
··· 1536 1537 if (!rx_batched || (!more && skb_queue_empty(queue))) { 1538 local_bh_disable(); 1539 netif_receive_skb(skb); 1540 local_bh_enable(); 1541 return; ··· 1556 struct sk_buff *nskb; 1557 1558 local_bh_disable(); 1559 - while ((nskb = __skb_dequeue(&process_queue))) 1560 netif_receive_skb(nskb); 1561 netif_receive_skb(skb); 1562 local_bh_enable(); 1563 } ··· 2455 if (!rcu_dereference(tun->steering_prog)) 2456 rxhash = __skb_get_hash_symmetric(skb); 2457 2458 netif_receive_skb(skb); 2459 2460 stats = get_cpu_ptr(tun->pcpu_stats);
··· 1536 1537 if (!rx_batched || (!more && skb_queue_empty(queue))) { 1538 local_bh_disable(); 1539 + skb_record_rx_queue(skb, tfile->queue_index); 1540 netif_receive_skb(skb); 1541 local_bh_enable(); 1542 return; ··· 1555 struct sk_buff *nskb; 1556 1557 local_bh_disable(); 1558 + while ((nskb = __skb_dequeue(&process_queue))) { 1559 + skb_record_rx_queue(nskb, tfile->queue_index); 1560 netif_receive_skb(nskb); 1561 + } 1562 + skb_record_rx_queue(skb, tfile->queue_index); 1563 netif_receive_skb(skb); 1564 local_bh_enable(); 1565 } ··· 2451 if (!rcu_dereference(tun->steering_prog)) 2452 rxhash = __skb_get_hash_symmetric(skb); 2453 2454 + skb_record_rx_queue(skb, tfile->queue_index); 2455 netif_receive_skb(skb); 2456 2457 stats = get_cpu_ptr(tun->pcpu_stats);