summaryrefslogtreecommitdiffstats
path: root/net/xdp/xsk_queue.h
diff options
context:
space:
mode:
authorKal Conley <kal.conley@dectris.com>2023-04-10 14:18:41 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2023-04-13 14:51:02 +0200
commit0c5f48599bed55c13d6f979ea824554bdebdf2ad (patch)
treef0b8893de4e74e6439147e67bd9072aa75fe4a20 /net/xdp/xsk_queue.h
parentselftests/bpf: Remove stand-along test_verifier_log test binary (diff)
downloadlinux-0c5f48599bed55c13d6f979ea824554bdebdf2ad.tar.xz
linux-0c5f48599bed55c13d6f979ea824554bdebdf2ad.zip
xsk: Simplify xp_aligned_validate_desc implementation
Perform the chunk boundary check like the page boundary check in xp_desc_crosses_non_contig_pg(). This simplifies the implementation and reduces the number of branches. Signed-off-by: Kal Conley <kal.conley@dectris.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Magnus Karlsson <magnus.karlsson@intel.com> Link: https://lore.kernel.org/bpf/20230410121841.643254-1-kal.conley@dectris.com
Diffstat (limited to 'net/xdp/xsk_queue.h')
-rw-r--r--net/xdp/xsk_queue.h12
1 files changed, 4 insertions, 8 deletions
diff --git a/net/xdp/xsk_queue.h b/net/xdp/xsk_queue.h
index 66c6f57c9c44..76b574bffd4a 100644
--- a/net/xdp/xsk_queue.h
+++ b/net/xdp/xsk_queue.h
@@ -133,16 +133,12 @@ static inline bool xskq_cons_read_addr_unchecked(struct xsk_queue *q, u64 *addr)
static inline bool xp_aligned_validate_desc(struct xsk_buff_pool *pool,
struct xdp_desc *desc)
{
- u64 chunk, chunk_end;
+ u64 offset = desc->addr & (pool->chunk_size - 1);
- chunk = xp_aligned_extract_addr(pool, desc->addr);
- if (likely(desc->len)) {
- chunk_end = xp_aligned_extract_addr(pool, desc->addr + desc->len - 1);
- if (chunk != chunk_end)
- return false;
- }
+ if (offset + desc->len > pool->chunk_size)
+ return false;
- if (chunk >= pool->addrs_cnt)
+ if (desc->addr >= pool->addrs_cnt)
return false;
if (desc->options)