diff --git a/drivers/net/veth.c b/drivers/net/veth.c index a3046142cb8e..2ccc40e57d12 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -814,6 +814,8 @@ static struct sk_buff *veth_xdp_rcv_skb(struct veth_rq *rq, orig_data = xdp->data; orig_data_end = xdp->data_end; + xdp_update_mem_type(xdp); + act = bpf_prog_run_xdp(xdp_prog, xdp); switch (act) { diff --git a/include/net/xdp.h b/include/net/xdp.h index aa742f413c35..40829e15b05d 100644 --- a/include/net/xdp.h +++ b/include/net/xdp.h @@ -370,6 +370,13 @@ xdp_update_skb_frags_info(struct sk_buff *skb, u8 nr_frags, skb->unreadable |= !!(xdp_flags & XDP_FLAGS_FRAGS_UNREADABLE); } +static inline void +xdp_update_mem_type(struct xdp_buff *xdp) +{ + xdp->rxq->mem.type = page_pool_page_is_pp(virt_to_page(xdp->data)) ? + MEM_TYPE_PAGE_POOL : MEM_TYPE_PAGE_SHARED; +} + /* Avoids inlining WARN macro in fast-path */ void xdp_warn(const char *msg, const char *func, const int line); #define XDP_WARN(msg) xdp_warn(msg, __func__, __LINE__) diff --git a/net/core/dev.c b/net/core/dev.c index a64cef2c537e..e9e3dfc3ac41 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5357,6 +5357,8 @@ u32 bpf_prog_run_generic_xdp(struct sk_buff *skb, struct xdp_buff *xdp, orig_bcast = is_multicast_ether_addr_64bits(eth->h_dest); orig_eth_type = eth->h_proto; + xdp_update_mem_type(xdp); + act = bpf_prog_run_xdp(xdp_prog, xdp); /* check if bpf_xdp_adjust_head was used */