Skip to content

Commit 71795da

Browse files
almostivanNipaLocal
authored andcommitted
udp: use __sock_rcvbuf_has_space() helper
Make use of __sock_rcvbuf_has_space() in __udp_enqueue_schedule_skb(). Signed-off-by: Jason Baron <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 67c9627 commit 71795da

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

net/ipv4/udp.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,17 +1733,8 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
17331733
rcvbuf = READ_ONCE(sk->sk_rcvbuf);
17341734
size = skb->truesize;
17351735

1736-
/* Immediately drop when the receive queue is full.
1737-
* Cast to unsigned int performs the boundary check for INT_MAX.
1738-
*/
1739-
if (rmem + size > rcvbuf) {
1740-
if (rcvbuf > INT_MAX >> 1)
1741-
goto drop;
1742-
1743-
/* Always allow at least one packet for small buffer. */
1744-
if (rmem > rcvbuf)
1745-
goto drop;
1746-
}
1736+
if (!__sock_rcvbuf_has_space(rmem, rcvbuf, size))
1737+
goto drop;
17471738

17481739
/* Under mem pressure, it might be helpful to help udp_recvmsg()
17491740
* having linear skbs :

0 commit comments

Comments
 (0)