Skip to contentSkip to conversation

xsk: fix poll/POLLIN premature returns

PATCH In review Björn Töpel 2 participants 2 messages Jul 23, 2018 – Jul 25, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xsk: fix poll/POLLIN premature returns

From: Björn Töpel <[email protected]>

Polling for the ingress queues relies on reading the producer/consumer pointers of the Rx queue.

Prior this commit, a cached consumer pointer could be used, instead of the actual consumer pointer and therefore report POLLIN prematurely.

This patch makes sure that the non-cached consumer pointer is used instead.

Fixes c497176cb2e4 ("xsk: add Rx receive functions and poll support")
---
 net/xdp/xsk_queue.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/xdp/xsk_queue.h +1 -1
index 52ecaf770642..8a64b150be54 100644
@@ -250,7 +250,7 @@ static inline bool xskq_full_desc(struct xsk_queue *q)
 
 static inline bool xskq_empty_desc(struct xsk_queue *q)
 {
-	return xskq_nb_free(q, q->prod_tail, 1) == q->nentries;
+	return xskq_nb_free(q, q->prod_tail, q->nentries) == q->nentries;
 }
 
 void xskq_set_umem(struct xsk_queue *q, struct xdp_umem_props *umem_props);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 8 lines · Björn Töpel

From: Björn Töpel <[email protected]>

Polling for the ingress queues relies on reading the producer/consumer pointers of the Rx queue.

Prior this commit, a cached consumer pointer could be used, instead of the actual consumer pointer and therefore report POLLIN prematurely.

Quoted 7 lines

This patch makes sure that the non-cached consumer pointer is used instead.

Fixes c497176cb2e4 ("xsk: add Rx receive functions and poll support")

Applied thanks, Björn!