All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heng Qi <hengqi@linux.alibaba.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
	bpf@vger.kernel.org
Subject: Re: [PATCH net-next 2/2] veth: fix double napi enable
Date: Fri, 18 Nov 2022 22:24:51 +0800	[thread overview]
Message-ID: <20221118142451.66472-1-hengqi@linux.alibaba.com> (raw)
In-Reply-To: <b90034c61b939d18cd7a201c547fb7ddffc91231.1668727939.git.pabeni@redhat.com>

> While investigating a related issue I stumbled upon another
> oops, reproducible as the follow:
>
> ip link add type veth
> ip link set dev veth0 xdp object <obj>
> ip link set dev veth0 up
> ip link set dev veth1 up
>
> The first link up command will enable the napi instances on
> veth1 and the second link up common will try again the same
> operation, causing the oops.
>
> This change addresses the issue explicitly checking the peer
> is up before enabling its napi instances.
>
> Fixes: 2e0de6366ac1 ("veth: Avoid drop packets when xdp_redirect performs")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
>  drivers/net/veth.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> index 1384134f7100..d541183e0c66 100644
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c
> @@ -1343,7 +1343,8 @@ static int veth_open(struct net_device *dev)
> 		if (err)
>  			return err;
>  		/* refer to the logic in veth_xdp_set() */
> -		if (!rtnl_dereference(peer_rq->napi)) {
> +		if (!rtnl_dereference(peer_rq->napi) &&
> +		    (peer->flags & IFF_UP)) {
>  			err = veth_napi_enable(peer);
>  			if (err)
>  				return err;

I have checked the conditions related to enabling and disabling napi for
veth pair. In general, we should check whether napi is disabled before
enabling it, and check whether napi is enabled before disabling it. I am
sorry that my previous test cases didn't do better, and we can work
completely with your patchset. As the your patch in link below does
https://lore.kernel.org/all/c59f4adcdd1296ee37cc6bca4d927b8c79158909.1668727939.git.pabeni@redhat.com/

Is this patch more uniform like the following:

--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -1348,7 +1348,8 @@ static int veth_open(struct net_device *dev)
                        if (err)
                                return err;
                }
-       } else if (veth_gro_requested(dev) || peer_priv->_xdp_prog) {
+       } else if ((veth_gro_requested(dev) || peer_priv->_xdp_prog) &&
+                   !rtnl_dereference(priv->rq[0].napi)) {
                err = veth_napi_enable(dev);
                if (err)
                        return err;

Thanks.

  reply	other threads:[~2022-11-18 14:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17 23:33 [PATCH net-next 0/2] veth: a couple of fixes Paolo Abeni
2022-11-17 23:33 ` [PATCH net-next 1/2] veth: fix uninitialized napi disable Paolo Abeni
2022-11-17 23:33 ` [PATCH net-next 2/2] veth: fix double napi enable Paolo Abeni
2022-11-18 14:24   ` Heng Qi [this message]
2022-11-18  8:41 ` [PATCH net-next 0/2] veth: a couple of fixes Paolo Abeni
2022-11-18 11:05   ` Toke Høiland-Jørgensen
2022-11-19  1:06     ` Jakub Kicinski
2022-11-21  6:15       ` John Fastabend
2022-11-21  3:33   ` Xuan Zhuo
2022-11-21  3:55     ` Heng Qi
2022-11-21 10:11       ` Paolo Abeni
2022-11-21 11:28         ` [PATCH 0/2] Revert "veth: Avoid drop packets when xdp_redirect performs" and its fix Heng Qi
2022-11-21 11:28           ` [PATCH 1/2] Revert "bpf: veth driver panics when xdp prog attached before veth_open" Heng Qi
2022-11-21 11:28           ` [PATCH 2/2] Revert "veth: Avoid drop packets when xdp_redirect performs" Heng Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221118142451.66472-1-hengqi@linux.alibaba.com \
    --to=hengqi@linux.alibaba.com \
    --cc=bpf@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.