Commit 005ec9743394010cd37d86c3fd2e81978231cdbf

Authored by Shawn Bohrer
Committed by David S. Miller
1 parent 2c8c8e6f9d

udp: Only allow busy read/poll on connected sockets

UDP sockets can receive packets from multiple endpoints and thus may be
received on multiple receive queues.  Since packets packets can arrive
on multiple receive queues we should not mark the napi_id for all
packets.  This makes busy read/poll only work for connected UDP sockets.

This additionally enables busy read/poll for UDP multicast packets as
long as the socket is connected by moving the check into
__udp_queue_rcv_skb().

Signed-off-by: Shawn Bohrer <sbohrer@rgmadvisors.com>
Suggested-by: Eric Dumazet <edumazet@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 2 changed files with 6 additions and 4 deletions Side-by-side Diff

... ... @@ -1405,8 +1405,10 @@
1405 1405 {
1406 1406 int rc;
1407 1407  
1408   - if (inet_sk(sk)->inet_daddr)
  1408 + if (inet_sk(sk)->inet_daddr) {
1409 1409 sock_rps_save_rxhash(sk, skb);
  1410 + sk_mark_napi_id(sk, skb);
  1411 + }
1410 1412  
1411 1413 rc = sock_queue_rcv_skb(sk, skb);
1412 1414 if (rc < 0) {
... ... @@ -1716,7 +1718,6 @@
1716 1718 if (sk != NULL) {
1717 1719 int ret;
1718 1720  
1719   - sk_mark_napi_id(sk, skb);
1720 1721 ret = udp_queue_rcv_skb(sk, skb);
1721 1722 sock_put(sk);
1722 1723  
... ... @@ -549,8 +549,10 @@
549 549 {
550 550 int rc;
551 551  
552   - if (!ipv6_addr_any(&inet6_sk(sk)->daddr))
  552 + if (!ipv6_addr_any(&inet6_sk(sk)->daddr)) {
553 553 sock_rps_save_rxhash(sk, skb);
  554 + sk_mark_napi_id(sk, skb);
  555 + }
554 556  
555 557 rc = sock_queue_rcv_skb(sk, skb);
556 558 if (rc < 0) {
... ... @@ -844,7 +846,6 @@
844 846 if (sk != NULL) {
845 847 int ret;
846 848  
847   - sk_mark_napi_id(sk, skb);
848 849 ret = udpv6_queue_rcv_skb(sk, skb);
849 850 sock_put(sk);
850 851