Skip to content

Commit b91d31d

Browse files
edumazetgregkh
authored andcommitted
sctp: fix busy polling
[ Upstream commit a562c0a ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9233a88 commit b91d31d

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

net/sctp/socket.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,6 +2101,10 @@ static int sctp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
21012101
if (unlikely(flags & MSG_ERRQUEUE))
21022102
return inet_recv_error(sk, msg, len, addr_len);
21032103

2104+
if (sk_can_busy_loop(sk) &&
2105+
skb_queue_empty_lockless(&sk->sk_receive_queue))
2106+
sk_busy_loop(sk, flags & MSG_DONTWAIT);
2107+
21042108
lock_sock(sk);
21052109

21062110
if (sctp_style(sk, TCP) && !sctp_sstate(sk, ESTABLISHED) &&
@@ -9041,12 +9045,6 @@ struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags, int *err)
90419045
if (sk->sk_shutdown & RCV_SHUTDOWN)
90429046
break;
90439047

9044-
if (sk_can_busy_loop(sk)) {
9045-
sk_busy_loop(sk, flags & MSG_DONTWAIT);
9046-
9047-
if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
9048-
continue;
9049-
}
90509048

90519049
/* User doesn't want to wait. */
90529050
error = -EAGAIN;

0 commit comments

Comments
 (0)