Skip to content

Commit 005ec97

Browse files
Shawn Bohrerdavem330
authored andcommitted
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>
1 parent 2c8c8e6 commit 005ec97

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

net/ipv4/udp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,8 +1405,10 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
14051405
{
14061406
int rc;
14071407

1408-
if (inet_sk(sk)->inet_daddr)
1408+
if (inet_sk(sk)->inet_daddr) {
14091409
sock_rps_save_rxhash(sk, skb);
1410+
sk_mark_napi_id(sk, skb);
1411+
}
14101412

14111413
rc = sock_queue_rcv_skb(sk, skb);
14121414
if (rc < 0) {
@@ -1716,7 +1718,6 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
17161718
if (sk != NULL) {
17171719
int ret;
17181720

1719-
sk_mark_napi_id(sk, skb);
17201721
ret = udp_queue_rcv_skb(sk, skb);
17211722
sock_put(sk);
17221723

net/ipv6/udp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,10 @@ static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
549549
{
550550
int rc;
551551

552-
if (!ipv6_addr_any(&inet6_sk(sk)->daddr))
552+
if (!ipv6_addr_any(&inet6_sk(sk)->daddr)) {
553553
sock_rps_save_rxhash(sk, skb);
554+
sk_mark_napi_id(sk, skb);
555+
}
554556

555557
rc = sock_queue_rcv_skb(sk, skb);
556558
if (rc < 0) {
@@ -844,7 +846,6 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
844846
if (sk != NULL) {
845847
int ret;
846848

847-
sk_mark_napi_id(sk, skb);
848849
ret = udpv6_queue_rcv_skb(sk, skb);
849850
sock_put(sk);
850851

0 commit comments

Comments
 (0)