Commit dcf70cef authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net/packet: constify prb_lookup_block() and __tpacket_v3_has_room()

Goal is to be able to use __tpacket_v3_has_room() without holding
a lock.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d4b5bd98
...@@ -1082,8 +1082,8 @@ static void *packet_current_rx_frame(struct packet_sock *po, ...@@ -1082,8 +1082,8 @@ static void *packet_current_rx_frame(struct packet_sock *po,
} }
} }
static void *prb_lookup_block(struct packet_sock *po, static void *prb_lookup_block(const struct packet_sock *po,
struct packet_ring_buffer *rb, const struct packet_ring_buffer *rb,
unsigned int idx, unsigned int idx,
int status) int status)
{ {
...@@ -1211,12 +1211,12 @@ static bool __tpacket_has_room(const struct packet_sock *po, int pow_off) ...@@ -1211,12 +1211,12 @@ static bool __tpacket_has_room(const struct packet_sock *po, int pow_off)
return packet_lookup_frame(po, &po->rx_ring, idx, TP_STATUS_KERNEL); return packet_lookup_frame(po, &po->rx_ring, idx, TP_STATUS_KERNEL);
} }
static bool __tpacket_v3_has_room(struct packet_sock *po, int pow_off) static bool __tpacket_v3_has_room(const struct packet_sock *po, int pow_off)
{ {
int idx, len; int idx, len;
len = po->rx_ring.prb_bdqc.knum_blocks; len = READ_ONCE(po->rx_ring.prb_bdqc.knum_blocks);
idx = po->rx_ring.prb_bdqc.kactive_blk_num; idx = READ_ONCE(po->rx_ring.prb_bdqc.kactive_blk_num);
if (pow_off) if (pow_off)
idx += len >> pow_off; idx += len >> pow_off;
if (idx >= len) if (idx >= len)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment