Subject: Re: [PATCH net-next v8 03/17] net: page_pool: create hooks for custom page providers

From: Jakub Kicinski <[email-masked]>
Date: Mon, 9 Dec 2024 19:02:30 -0800

On Wed,  4 Dec 2024 09:21:42 -0800 David Wei wrote:
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index f89cf93f6eb4..36f61a1e4ffe 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -284,10 +284,11 @@ static int page_pool_init(struct page_pool *pool,
>  		rxq = __netif_get_rx_queue(pool->slow.netdev,
>  					   pool->slow.queue_idx);
>  		pool->mp_priv = rxq->mp_params.mp_priv;
> +		pool->mp_ops = rxq->mp_params.mp_ops;
>  	}
>  
> -	if (pool->mp_priv) {
> -		err = mp_dmabuf_devmem_init(pool);
> +	if (pool->mp_ops) {

Can we throw in a:

		if (WARN_ON(!is_kernel_rodata((unsigned long)pool->mp_ops)))
			goto free_ptr_ring;

here, to avoid any abuse?

> +		err = pool->mp_ops->init(pool);
>  		if (err) {
>  			pr_warn("%s() mem-provider init failed %d\n", __func__,
>  				err);