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
This commit is contained in:
parent
ee5059a64d
commit
0c5f48599b
net/xdp
|
@ -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,
|
static inline bool xp_aligned_validate_desc(struct xsk_buff_pool *pool,
|
||||||
struct xdp_desc *desc)
|
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 (offset + desc->len > pool->chunk_size)
|
||||||
if (likely(desc->len)) {
|
return false;
|
||||||
chunk_end = xp_aligned_extract_addr(pool, desc->addr + desc->len - 1);
|
|
||||||
if (chunk != chunk_end)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chunk >= pool->addrs_cnt)
|
if (desc->addr >= pool->addrs_cnt)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (desc->options)
|
if (desc->options)
|
||||||
|
|
Loading…
Reference in New Issue