-----Original Message----- From: Jakub Kicinski kuba@kernel.org Sent: Monday, July 14, 2025 9:29 PM To: Haiyang Zhang haiyangz@linux.microsoft.com Cc: linux-hyperv@vger.kernel.org; netdev@vger.kernel.org; Haiyang Zhang haiyangz@microsoft.com; KY Srinivasan kys@microsoft.com; wei.liu@kernel.org; Dexuan Cui decui@microsoft.com; edumazet@google.com; pabeni@redhat.com; stephen@networkplumber.org; davem@davemloft.net; linux- kernel@vger.kernel.org; stable@vger.kernel.org Subject: [EXTERNAL] Re: [PATCH net] hv_netvsc: Switch VF namespace in netvsc_open instead
On Fri, 11 Jul 2025 13:57:10 -0700 Haiyang Zhang wrote:
The existing code move the VF NIC to new namespace when NETDEV_REGISTER
is
received on netvsc NIC. During deletion of the namespace, default_device_exit_batch() >> default_device_exit_net() is called. When netvsc NIC is moved back and registered to the default namespace, it automatically brings VF NIC back to the default namespace. This will
cause
the default_device_exit_net() >> for_each_netdev_safe loop unable to
detect
the list end, and hit NULL ptr:
Are you saying that when netns is dismantled both devices are listed for moving back to default, but the netvsc_event_set_vf_ns() logic tries to undo the move / move the VF before the netns dismantle loop got to it?
netvsc_event_set_vf_ns() moves the VF to default ns before the netns dismantle loop got to it, and causes the Null prt error.
This needs a better fix, moving on open is way too hacky. Perhaps we should start with reverting 4c262801ea60 and then trying to implement it in a more robust way?
This patch reverts the 4c262801ea60, and moves the logic to netvsc_open().
I was thinking some other ways too... But seems I couldn't find a way to know it's in the for_each_netdev_safe loop, and to skip moving the VF in netvsc_event_set_vf_ns() this case.
Thanks, - Haiyang