Skip to content

Commit

Permalink
net/packet: constify prb_lookup_block() and __tpacket_v3_has_room()
Browse files Browse the repository at this point in the history
Goal is to be able to use __tpacket_v3_has_room() without holding
a lock.

Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed Jun 15, 2019
1 parent d4b5bd9 commit dcf70ce
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,10 +1082,10 @@ static void *packet_current_rx_frame(struct packet_sock *po,
}
}

static void *prb_lookup_block(struct packet_sock *po,
struct packet_ring_buffer *rb,
unsigned int idx,
int status)
static void *prb_lookup_block(const struct packet_sock *po,
const struct packet_ring_buffer *rb,
unsigned int idx,
int status)
{
struct tpacket_kbdq_core *pkc = GET_PBDQC_FROM_RB(rb);
struct tpacket_block_desc *pbd = GET_PBLOCK_DESC(pkc, idx);
Expand Down Expand Up @@ -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);
}

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;

len = po->rx_ring.prb_bdqc.knum_blocks;
idx = po->rx_ring.prb_bdqc.kactive_blk_num;
len = READ_ONCE(po->rx_ring.prb_bdqc.knum_blocks);
idx = READ_ONCE(po->rx_ring.prb_bdqc.kactive_blk_num);
if (pow_off)
idx += len >> pow_off;
if (idx >= len)
Expand Down

0 comments on commit dcf70ce

Please sign in to comment.