All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] xsk: Fix error return code in __xp_assign_dev()
@ 2020-12-04  8:50 Zhang Changzhong
  2020-12-04  9:01 ` Magnus Karlsson
  0 siblings, 1 reply; 3+ messages in thread
From: Zhang Changzhong @ 2020-12-04  8:50 UTC (permalink / raw)
  To: Björn Töpel, Magnus Karlsson, Jonathan Lemon,
	David S. Miller, Jakub Kicinski, Alexei Starovoitov,
	Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend
  Cc: Zhang Changzhong, netdev, bpf, linux-kernel

Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: 921b68692abb ("xsk: Enable sharing of dma mappings")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
---
 net/xdp/xsk_buff_pool.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index 9287edd..d5adeee 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -175,6 +175,7 @@ static int __xp_assign_dev(struct xsk_buff_pool *pool,
 
 	if (!pool->dma_pages) {
 		WARN(1, "Driver did not DMA map zero-copy buffers");
+		err = -EINVAL;
 		goto err_unreg_xsk;
 	}
 	pool->umem->zc = true;
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] xsk: Fix error return code in __xp_assign_dev()
  2020-12-04  8:50 [PATCH net] xsk: Fix error return code in __xp_assign_dev() Zhang Changzhong
@ 2020-12-04  9:01 ` Magnus Karlsson
  2020-12-04 10:18   ` Zhang Changzhong
  0 siblings, 1 reply; 3+ messages in thread
From: Magnus Karlsson @ 2020-12-04  9:01 UTC (permalink / raw)
  To: Zhang Changzhong
  Cc: Björn Töpel, Magnus Karlsson, Jonathan Lemon,
	David S. Miller, Jakub Kicinski, Alexei Starovoitov,
	Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
	Network Development, bpf, open list

On Fri, Dec 4, 2020 at 9:49 AM Zhang Changzhong
<zhangchangzhong@huawei.com> wrote:
>
> Fix to return a negative error code from the error handling
> case instead of 0, as done elsewhere in this function.
>
> Fixes: 921b68692abb ("xsk: Enable sharing of dma mappings")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
> ---
>  net/xdp/xsk_buff_pool.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
> index 9287edd..d5adeee 100644
> --- a/net/xdp/xsk_buff_pool.c
> +++ b/net/xdp/xsk_buff_pool.c
> @@ -175,6 +175,7 @@ static int __xp_assign_dev(struct xsk_buff_pool *pool,
>
>         if (!pool->dma_pages) {
>                 WARN(1, "Driver did not DMA map zero-copy buffers");
> +               err = -EINVAL;

Good catch! My intention here by not setting err is that it should
fall back to copy mode, which it does. The problem is that the
force_zc flag is disregarded when err is not set (see exit code below)
and your patch fixes that. If force_zc is set, we should exit out with
an error, not fall back. Could you please write about this in your
cover letter and send a v2?

BTW, what is the "Hulk Robot" that is in your Reported-by tag?

Thank you: Magnus

err_unreg_xsk:
        xp_disable_drv_zc(pool);
err_unreg_pool:
        if (!force_zc)
                err = 0; /* fallback to copy mode */
        if (err)
                xsk_clear_pool_at_qid(netdev, queue_id);
        return err;

>                 goto err_unreg_xsk;
>         }
>         pool->umem->zc = true;
> --
> 2.9.5
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] xsk: Fix error return code in __xp_assign_dev()
  2020-12-04  9:01 ` Magnus Karlsson
@ 2020-12-04 10:18   ` Zhang Changzhong
  0 siblings, 0 replies; 3+ messages in thread
From: Zhang Changzhong @ 2020-12-04 10:18 UTC (permalink / raw)
  To: Magnus Karlsson
  Cc: Björn Töpel, Magnus Karlsson, Jonathan Lemon,
	David S. Miller, Jakub Kicinski, Alexei Starovoitov,
	Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
	Network Development, bpf, open list

> 
> Good catch! My intention here by not setting err is that it should
> fall back to copy mode, which it does. The problem is that the
> force_zc flag is disregarded when err is not set (see exit code below)
> and your patch fixes that. If force_zc is set, we should exit out with
> an error, not fall back. Could you please write about this in your
> cover letter and send a v2?
> 

Thanks for the suggestion, I have sent the v2 patch, please take another look.

> BTW, what is the "Hulk Robot" that is in your Reported-by tag?

It's an auto tester, here is some information: https://lwn.net/Articles/804119/

> 
> Thank you: Magnus
> 
> err_unreg_xsk:
>         xp_disable_drv_zc(pool);
> err_unreg_pool:
>         if (!force_zc)
>                 err = 0; /* fallback to copy mode */
>         if (err)
>                 xsk_clear_pool_at_qid(netdev, queue_id);
>         return err;
> 
>>                 goto err_unreg_xsk;
>>         }
>>         pool->umem->zc = true;
>> --
>> 2.9.5
>>
> .
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-04 10:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04  8:50 [PATCH net] xsk: Fix error return code in __xp_assign_dev() Zhang Changzhong
2020-12-04  9:01 ` Magnus Karlsson
2020-12-04 10:18   ` Zhang Changzhong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.