Skip to content

Commit 493bbce

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 c5e183b commit 493bbce

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
@@ -1734,17 +1734,8 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
17341734
rcvbuf = READ_ONCE(sk->sk_rcvbuf);
17351735
size = skb->truesize;
17361736

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

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

0 commit comments

Comments
 (0)