net/packet: constify packet_lookup_frame() and __tpacket_has_room()

Goal is to be able to use __tpacket_has_room() without holding a lock.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Eric Dumazet 2019-06-12 09:52:27 -07:00 committed by David S. Miller
parent 96f657e6cf
commit d4b5bd98fa
1 changed files with 7 additions and 7 deletions

View File

@ -460,10 +460,10 @@ static __u32 __packet_set_timestamp(struct packet_sock *po, void *frame,
return ts_status; return ts_status;
} }
static void *packet_lookup_frame(struct packet_sock *po, static void *packet_lookup_frame(const struct packet_sock *po,
struct packet_ring_buffer *rb, const struct packet_ring_buffer *rb,
unsigned int position, unsigned int position,
int status) int status)
{ {
unsigned int pg_vec_pos, frame_offset; unsigned int pg_vec_pos, frame_offset;
union tpacket_uhdr h; union tpacket_uhdr h;
@ -1198,12 +1198,12 @@ static void packet_free_pending(struct packet_sock *po)
#define ROOM_LOW 0x1 #define ROOM_LOW 0x1
#define ROOM_NORMAL 0x2 #define ROOM_NORMAL 0x2
static bool __tpacket_has_room(struct packet_sock *po, int pow_off) static bool __tpacket_has_room(const struct packet_sock *po, int pow_off)
{ {
int idx, len; int idx, len;
len = po->rx_ring.frame_max + 1; len = READ_ONCE(po->rx_ring.frame_max) + 1;
idx = po->rx_ring.head; idx = READ_ONCE(po->rx_ring.head);
if (pow_off) if (pow_off)
idx += len >> pow_off; idx += len >> pow_off;
if (idx >= len) if (idx >= len)