public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Ido Schimmel <idosch@idosch.org>
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	pabeni@redhat.com, edumazet@google.com, bigeasy@linutronix.de,
	imagedong@tencent.com, kuniyu@amazon.com, petrm@nvidia.com
Subject: Re: [patch net-next 2/2] net: devlink: move netdev notifier block to dest namespace during reload
Date: Mon, 7 Nov 2022 18:24:29 +0100	[thread overview]
Message-ID: <Y2k/TUCa3/BXne9Q@nanopsycho> (raw)
In-Reply-To: <Y2k3uIMn2R42AH6q@shredder>

Mon, Nov 07, 2022 at 05:52:08PM CET, idosch@idosch.org wrote:
>On Mon, Nov 07, 2022 at 03:52:13PM +0100, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@nvidia.com>
>> 
>> The notifier block tracking netdev changes in devlink is registered
>> during devlink_alloc() per-net, it is then unregistered
>> in devlink_free(). When devlink moves from net namespace to another one,
>> the notifier block needs to move along.
>> 
>> Fix this by adding forgotten call to move the block.
>> 
>> Reported-by: Ido Schimmel <idosch@idosch.org>
>> Fixes: 02a68a47eade ("net: devlink: track netdev with devlink_port assigned")
>> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
>
>Does not trigger with my reproducer. Will test the fix tonight in
>regression and report tomorrow morning.

Ok!

>
>> ---
>>  net/core/devlink.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>> 
>> diff --git a/net/core/devlink.c b/net/core/devlink.c
>> index 40fcdded57e6..ea0b319385fc 100644
>> --- a/net/core/devlink.c
>> +++ b/net/core/devlink.c
>> @@ -4502,8 +4502,11 @@ static int devlink_reload(struct devlink *devlink, struct net *dest_net,
>>  	if (err)
>>  		return err;
>>  
>> -	if (dest_net && !net_eq(dest_net, curr_net))
>> +	if (dest_net && !net_eq(dest_net, curr_net)) {
>> +		move_netdevice_notifier_net(curr_net, dest_net,
>> +					    &devlink->netdevice_nb);
>>  		write_pnet(&devlink->_net, dest_net);
>> +	}
>
>I suggest adding this:
>
>diff --git a/net/core/devlink.c b/net/core/devlink.c
>index 83fd10aeddd5..3b5aedc93335 100644
>--- a/net/core/devlink.c
>+++ b/net/core/devlink.c
>@@ -9843,8 +9843,8 @@ void devlink_free(struct devlink *devlink)
> 
>        xa_destroy(&devlink->snapshot_ids);
> 
>-       unregister_netdevice_notifier_net(devlink_net(devlink),
>-                                         &devlink->netdevice_nb);
>+       WARN_ON(unregister_netdevice_notifier_net(devlink_net(devlink),
>+                                                 &devlink->netdevice_nb));
> 
>        xa_erase(&devlinks, devlink->index);
>
>This tells about the failure right away. Instead, we saw random memory
>corruptions in later tests.

Should be a separate patch then.


>
>>  
>>  	err = devlink->ops->reload_up(devlink, action, limit, actions_performed, extack);
>>  	devlink_reload_failed_set(devlink, !!err);
>> -- 
>> 2.37.3
>> 

  reply	other threads:[~2022-11-07 17:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07 14:52 [patch net-next 0/2] net: devlink: move netdev notifier block to dest namespace during reload Jiri Pirko
2022-11-07 14:52 ` [patch net-next 1/2] net: introduce a helper to move notifier block to different namespace Jiri Pirko
2022-11-08  4:29   ` Jakub Kicinski
2022-11-08  6:53     ` Jiri Pirko
2022-11-07 14:52 ` [patch net-next 2/2] net: devlink: move netdev notifier block to dest namespace during reload Jiri Pirko
2022-11-07 16:52   ` Ido Schimmel
2022-11-07 17:24     ` Jiri Pirko [this message]
2022-11-08  8:11   ` Ido Schimmel
2022-11-08 12:59     ` Jiri Pirko
2022-11-08 13:07       ` Jiri Pirko

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=Y2k/TUCa3/BXne9Q@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=bigeasy@linutronix.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=idosch@idosch.org \
    --cc=imagedong@tencent.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox