diff options
-rw-r--r-- | net/packet/af_packet.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 6a2bb37506c5..b5dc1168f98a 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -308,11 +308,27 @@ static bool packet_use_direct_xmit(const struct packet_sock *po) | |||
308 | return po->xmit == packet_direct_xmit; | 308 | return po->xmit == packet_direct_xmit; |
309 | } | 309 | } |
310 | 310 | ||
311 | static u16 packet_pick_tx_queue(struct net_device *dev) | 311 | static u16 __packet_pick_tx_queue(struct net_device *dev, struct sk_buff *skb) |
312 | { | 312 | { |
313 | return (u16) raw_smp_processor_id() % dev->real_num_tx_queues; | 313 | return (u16) raw_smp_processor_id() % dev->real_num_tx_queues; |
314 | } | 314 | } |
315 | 315 | ||
316 | static void packet_pick_tx_queue(struct net_device *dev, struct sk_buff *skb) | ||
317 | { | ||
318 | const struct net_device_ops *ops = dev->netdev_ops; | ||
319 | u16 queue_index; | ||
320 | |||
321 | if (ops->ndo_select_queue) { | ||
322 | queue_index = ops->ndo_select_queue(dev, skb, NULL, | ||
323 | __packet_pick_tx_queue); | ||
324 | queue_index = netdev_cap_txqueue(dev, queue_index); | ||
325 | } else { | ||
326 | queue_index = __packet_pick_tx_queue(dev, skb); | ||
327 | } | ||
328 | |||
329 | skb_set_queue_mapping(skb, queue_index); | ||
330 | } | ||
331 | |||
316 | /* register_prot_hook must be invoked with the po->bind_lock held, | 332 | /* register_prot_hook must be invoked with the po->bind_lock held, |
317 | * or from a context in which asynchronous accesses to the packet | 333 | * or from a context in which asynchronous accesses to the packet |
318 | * socket is not possible (packet_create()). | 334 | * socket is not possible (packet_create()). |
@@ -2285,7 +2301,8 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg) | |||
2285 | } | 2301 | } |
2286 | } | 2302 | } |
2287 | 2303 | ||
2288 | skb_set_queue_mapping(skb, packet_pick_tx_queue(dev)); | 2304 | packet_pick_tx_queue(dev, skb); |
2305 | |||
2289 | skb->destructor = tpacket_destruct_skb; | 2306 | skb->destructor = tpacket_destruct_skb; |
2290 | __packet_set_status(po, ph, TP_STATUS_SENDING); | 2307 | __packet_set_status(po, ph, TP_STATUS_SENDING); |
2291 | packet_inc_pending(&po->tx_ring); | 2308 | packet_inc_pending(&po->tx_ring); |
@@ -2499,7 +2516,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) | |||
2499 | skb->dev = dev; | 2516 | skb->dev = dev; |
2500 | skb->priority = sk->sk_priority; | 2517 | skb->priority = sk->sk_priority; |
2501 | skb->mark = sk->sk_mark; | 2518 | skb->mark = sk->sk_mark; |
2502 | skb_set_queue_mapping(skb, packet_pick_tx_queue(dev)); | 2519 | |
2520 | packet_pick_tx_queue(dev, skb); | ||
2503 | 2521 | ||
2504 | if (po->has_vnet_hdr) { | 2522 | if (po->has_vnet_hdr) { |
2505 | if (vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { | 2523 | if (vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { |