Skip to content

Commit

Permalink
xsk: discard zero length descriptors in Tx path
Browse files Browse the repository at this point in the history
Descriptors with zero length are not supported by many NICs. To preserve
uniform behavior discard any zero length desc as invvalid desc.

Signed-off-by: Tirthendu Sarkar <[email protected]>
Signed-off-by: Maciej Fijalkowski <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
  • Loading branch information
tirthendu-intel authored and Alexei Starovoitov committed Jul 19, 2023
1 parent cf24f5a commit 07428da
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions net/xdp/xsk_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ static inline bool xp_aligned_validate_desc(struct xsk_buff_pool *pool,
{
u64 offset = desc->addr & (pool->chunk_size - 1);

if (!desc->len)
return false;

if (offset + desc->len > pool->chunk_size)
return false;

Expand All @@ -156,6 +159,9 @@ static inline bool xp_unaligned_validate_desc(struct xsk_buff_pool *pool,
{
u64 addr = xp_unaligned_add_offset_to_addr(desc->addr);

if (!desc->len)
return false;

if (desc->len > pool->chunk_size)
return false;

Expand Down

0 comments on commit 07428da

Please sign in to comment.