Skip to content

Commit

Permalink
sctp: fix busy polling
Browse files Browse the repository at this point in the history
Busy polling while holding the socket lock makes litle sense,
because incoming packets wont reach our receive queue.

Fixes: 8465a5f ("sctp: add support for busy polling to sctp protocol")
Reported-by: Jacob Moroni <jmoroni@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Cc: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Jan 4, 2024
1 parent b15a4cf commit a562c0a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions net/sctp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -2102,6 +2102,10 @@ static int sctp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
if (unlikely(flags & MSG_ERRQUEUE))
return inet_recv_error(sk, msg, len, addr_len);

if (sk_can_busy_loop(sk) &&
skb_queue_empty_lockless(&sk->sk_receive_queue))
sk_busy_loop(sk, flags & MSG_DONTWAIT);

lock_sock(sk);

if (sctp_style(sk, TCP) && !sctp_sstate(sk, ESTABLISHED) &&
Expand Down Expand Up @@ -9046,12 +9050,6 @@ struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags, int *err)
if (sk->sk_shutdown & RCV_SHUTDOWN)
break;

if (sk_can_busy_loop(sk)) {
sk_busy_loop(sk, flags & MSG_DONTWAIT);

if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
continue;
}

/* User doesn't want to wait. */
error = -EAGAIN;
Expand Down

0 comments on commit a562c0a

Please sign in to comment.