[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/1] xen/netfront: stop tx queues during live migration


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx
  • From: Dongli Zhang <dongli.zhang@xxxxxxxxxx>
  • Date: Fri, 22 Oct 2021 16:31:39 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=j35yrGam9kFx0sdQF8/EFufTO4tusW7M53d8jmIisWA=; b=SWX9Haufz8o42/kM9W4PGjnYNufnak0BD56hRM1D0WxnhzxuvHtF5DjZyaatNxHFotiwjtLlfIJy4n0N/DbZoGDeKZXdV14WMse0YvJKy61dK+ZAtcW6+KlbS+DDzaIBiD0XxRZWEdpTaeQxVGqdkUNifvwzCMymQPu3pwZ9ruJl981Wi38pB66GVKVqnxeKbt0g66/bUjx732tSLlXpOjZq4bK9XisAVJnwTHzL48qIWPNwJPBWnTJnkG/zrTM+zfpVtSIwgvN9iFFsYK8gjrzXSlRChZhaU9UPR9b2hpHNBRrc9yj9xvZTpZAprFadooFKUuAKNcb1yu2FEpyqnw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J2NWfRL0USTVixHYA/fEQOZY78iCFuiQixcOOmyVJh0ww4RnLv9xRnxDPNfqE7OsqyecHm+fWIYLCaNmFFdBazaCVjVm3BffNK8ErXBLPH6jNziHY2RzRJ7jzHkLBIu8OXi2xaJKuWPS6NoEFQvqwqmf6JhVKocAjlGQOv8m5s9b0WEU0rbkOq2m2CNr7fNCVQGi6j3LuLKzHFtGW6IaTWLS+cIydJRjuJhC+4oG2beMy0zgQjjX/gVGBwmN3hwwKmDL0TgrI7vTXjeM8Tf/rVlqnkOA1LT3kDL5G48As+6rhNkVrrSoNh0WYSOtvDC/HGVjTlb5yx1gUj+/9m8SbA==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=oracle.com;
  • Cc: linux-kernel@xxxxxxxxxxxxxxx, boris.ostrovsky@xxxxxxxxxx, jgross@xxxxxxxx, sstabellini@xxxxxxxxxx, davem@xxxxxxxxxxxxx, kuba@xxxxxxxxxx, joe.jin@xxxxxxxxxx
  • Delivery-date: Fri, 22 Oct 2021 23:33:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxxxx>
Signed-off-by: Dongli Zhang <dongli.zhang@xxxxxxxxxx>
---
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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.