* [PATCH 1/1] xen/netfront: stop tx queues during live migration
@ 2021-10-22 23:31 Dongli Zhang
2021-10-25 15:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Dongli Zhang @ 2021-10-22 23:31 UTC (permalink / raw)
To: xen-devel, netdev
Cc: linux-kernel, boris.ostrovsky, jgross, sstabellini, davem, kuba,
joe.jin
The tx queues are not stopped during the live migration. As a result, the
ndo_start_xmit() may access netfront_info->queues which is freed by
talk_to_netback()->xennet_destroy_queues().
This patch is to netif_device_detach() at the beginning of xen-netfront
resuming, and netif_device_attach() at the end of resuming.
CPU A CPU B
talk_to_netback()
-> if (info->queues)
xennet_destroy_queues(info);
to free netfront_info->queues
xennet_start_xmit()
to access netfront_info->queues
-> err = xennet_create_queues(info, &num_queues);
The idea is borrowed from virtio-net.
Cc: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
Since I am not able to reproduce the corner case on purpose, I create a
patch to reproduce.
https://raw.githubusercontent.com/finallyjustice/patchset/master/xen-netfront-send-GARP-during-live-migration.patch
drivers/net/xen-netfront.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index e31b98403f31..fc41ba95f81d 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1730,6 +1730,10 @@ static int netfront_resume(struct xenbus_device *dev)
dev_dbg(&dev->dev, "%s\n", dev->nodename);
+ netif_tx_lock_bh(info->netdev);
+ netif_device_detach(info->netdev);
+ netif_tx_unlock_bh(info->netdev);
+
xennet_disconnect_backend(info);
return 0;
}
@@ -2349,6 +2353,10 @@ static int xennet_connect(struct net_device *dev)
* domain a kick because we've probably just requeued some
* packets.
*/
+ netif_tx_lock_bh(np->netdev);
+ netif_device_attach(np->netdev);
+ netif_tx_unlock_bh(np->netdev);
+
netif_carrier_on(np->netdev);
for (j = 0; j < num_queues; ++j) {
queue = &np->queues[j];
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] xen/netfront: stop tx queues during live migration
2021-10-22 23:31 [PATCH 1/1] xen/netfront: stop tx queues during live migration Dongli Zhang
@ 2021-10-25 15:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-10-25 15:20 UTC (permalink / raw)
To: Dongli Zhang
Cc: xen-devel, netdev, linux-kernel, boris.ostrovsky, jgross,
sstabellini, davem, kuba, joe.jin
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Fri, 22 Oct 2021 16:31:39 -0700 you wrote:
> The tx queues are not stopped during the live migration. As a result, the
> ndo_start_xmit() may access netfront_info->queues which is freed by
> talk_to_netback()->xennet_destroy_queues().
>
> This patch is to netif_device_detach() at the beginning of xen-netfront
> resuming, and netif_device_attach() at the end of resuming.
>
> [...]
Here is the summary with links:
- [1/1] xen/netfront: stop tx queues during live migration
https://git.kernel.org/netdev/net/c/042b2046d0f0
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-25 15:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-22 23:31 [PATCH 1/1] xen/netfront: stop tx queues during live migration Dongli Zhang
2021-10-25 15:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).