Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0338a145 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

net/packet: constify __packet_rcv_has_room()



Goal is use the helper without lock being held.

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dcf70cef
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -1224,15 +1224,18 @@ static bool __tpacket_v3_has_room(const struct packet_sock *po, int pow_off)
	return prb_lookup_block(po, &po->rx_ring, idx, TP_STATUS_KERNEL);
}

static int __packet_rcv_has_room(struct packet_sock *po, struct sk_buff *skb)
static int __packet_rcv_has_room(const struct packet_sock *po,
				 const struct sk_buff *skb)
{
	struct sock *sk = &po->sk;
	const struct sock *sk = &po->sk;
	int ret = ROOM_NONE;

	if (po->prot_hook.func != tpacket_rcv) {
		int avail = sk->sk_rcvbuf - atomic_read(&sk->sk_rmem_alloc)
		int rcvbuf = READ_ONCE(sk->sk_rcvbuf);
		int avail = rcvbuf - atomic_read(&sk->sk_rmem_alloc)
				   - (skb ? skb->truesize : 0);
		if (avail > (sk->sk_rcvbuf >> ROOM_POW_OFF))

		if (avail > (rcvbuf >> ROOM_POW_OFF))
			return ROOM_NORMAL;
		else if (avail > 0)
			return ROOM_LOW;