All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: Xin Long <lucien.xin@gmail.com>
Cc: network dev <netdev@vger.kernel.org>,
	David Miller <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Steffen Klassert <steffen.klassert@secunet.com>
Subject: Re: [PATCH ipsec] xfrm: set dst dev to blackhole_netdev instead of loopback_dev in ifdown
Date: Fri, 13 May 2022 09:22:02 -0700	[thread overview]
Message-ID: <CANn89iJxkikxKmN7JM_-1dohhb7TvH0Ok7CWxAajz_Lqi3y3Dw@mail.gmail.com> (raw)
In-Reply-To: <01a8af8654b87058ecd421e471d760a43784ab96.1652456873.git.lucien.xin@gmail.com>

On Fri, May 13, 2022 at 8:47 AM Xin Long <lucien.xin@gmail.com> wrote:
>
> The global blackhole_netdev has replaced pernet loopback_dev to become the
> one given to the object that holds an netdev when ifdown in many places of
> ipv4 and ipv6 since commit 8d7017fd621d ("blackhole_netdev: use
> blackhole_netdev to invalidate dst entries").
>
> Especially after commit faab39f63c1f ("net: allow out-of-order netdev
> unregistration"), it's no longer safe to use loopback_dev that may be
> freed before other netdev.

Maybe add it formally in Fixes: tag.

>
> This patch is to set dst dev to blackhole_netdev instead of loopback_dev
> in ifdown.
>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
>  net/xfrm/xfrm_policy.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> index 00bd0ecff5a1..f1876ea61fdc 100644
> --- a/net/xfrm/xfrm_policy.c
> +++ b/net/xfrm/xfrm_policy.c
> @@ -3744,7 +3744,7 @@ static int stale_bundle(struct dst_entry *dst)
>  void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev)
>  {
>         while ((dst = xfrm_dst_child(dst)) && dst->xfrm && dst->dev == dev) {
> -               dst->dev = dev_net(dev)->loopback_dev;
> +               dst->dev = blackhole_netdev;

I assume the XFRM layer is ready to deal with dst->dev set to blackhole ?

No initial setup needed ?

Thanks

>                 dev_hold(dst->dev);
>                 dev_put(dev);
>         }
> --
> 2.31.1
>

  reply	other threads:[~2022-05-13 16:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-13 15:47 [PATCH ipsec] xfrm: set dst dev to blackhole_netdev instead of loopback_dev in ifdown Xin Long
2022-05-13 16:22 ` Eric Dumazet [this message]
2022-05-13 18:56   ` Xin Long

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=CANn89iJxkikxKmN7JM_-1dohhb7TvH0Ok7CWxAajz_Lqi3y3Dw@mail.gmail.com \
    --to=edumazet@google.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.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.