Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5071539rwb; Sun, 22 Jan 2023 02:44:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXsbp9WR1cUWdiHzo3h2UVnQ2vzb0ZXZTok/iv/ANYKo5vmhJI1i6IMWgAWYjLXpm2sZwgZl X-Received: by 2002:a17:907:6d21:b0:805:1e6e:6777 with SMTP id sa33-20020a1709076d2100b008051e6e6777mr45501767ejc.23.1674384244817; Sun, 22 Jan 2023 02:44:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674384244; cv=none; d=google.com; s=arc-20160816; b=lLGhiAKDD1M4c7mUddVYNWGbqClW5USMfD+z9MimXkt1iuS2/28tl8YFtBQ5H+i9ic W620pcwP0sd2XLPC2NCTbUYGE0mLDW3DLskmr3/7Tpv9YummQx91vSHBY0Bw/2mAdPlb o8IIIetT/O09o4IbQr634ArSVA0FDC+cyfxNvki3szQw8sPntnaXIyqW2IKg2ZZYU6Cy bsBbF2nPAjJKGaO4MDoxHM+sry8k0ihZu1uW/y9D11Nc0uvCqfKWI9rUOqIrgYxBSiln gYun2qLc07EOixdZqP8QD5tVBbGKDk5vucFR4zZzXXHOni/bl7HhiwK2kFN3UtYI7W7P c46A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=bhTnAV0EW3t0DWruN1WdsKZihyfmAFVj7kgRbYzn3PQ=; b=EIjkqmjW4z3spIa5lHtcfTwCRwT+7Ei1LvlMSXB0PEYbG7CKev8UEg2NNWFxEAj3k0 OVkEbJkOmouqYCniK5zz2PPP5KNWu17LoPHSDOXMkgw8l74gi/TMPHcSexMl19vH3zur UndQnclpwBZjZGzTRfRS8ZwH0YlS52P3U8Cxs2NMHn/NSa/7u6ZKUGGYkdLxbQXws1kE AoFikYODVBGzokEWkjPnnPh12UC6aKR2xCaT+97+Wi8LQqgUVA+I+AMWvt7Mt0HxRxjV TbfjXDSiHGIa909cPq23f1cZt4QVJDZFJZGWu7I16stAKIKehbrrTGuokDIcR+MjtUz4 N4GA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d14-20020aa7c1ce000000b0049793b1fa7csi35718405edp.318.2023.01.22.02.43.49; Sun, 22 Jan 2023 02:44:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229902AbjAVKLq convert rfc822-to-8bit (ORCPT + 51 others); Sun, 22 Jan 2023 05:11:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbjAVKLp (ORCPT ); Sun, 22 Jan 2023 05:11:45 -0500 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 302021D90E; Sun, 22 Jan 2023 02:11:01 -0800 (PST) Received: from lenovo-t14s.redhat.com ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mtxxk-1oPdmn1xOO-00uJdX; Sun, 22 Jan 2023 11:05:29 +0100 From: Laurent Vivier To: linux-kernel@vger.kernel.org Cc: "Michael S. Tsirkin" , Parav Pandit , virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Eli Cohen , Jason Wang , Gautam Dawar , Cindy Lu , "David S. Miller" , =?UTF-8?q?Eugenio=20P=C3=A9rez?= Subject: [PATCH 0/4] virtio_net: vdpa: update MAC address when it is generated by virtio-net Date: Sun, 22 Jan 2023 11:05:22 +0100 Message-Id: <20230122100526.2302556-1-lvivier@redhat.com> X-Mailer: git-send-email 2.39.0 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT X-Provags-ID: V03:K1:yq7SLpOrrrwYVuK/Tdk6ssgdcQ6R8SuLVoPPYJezo5ADX4BjNKy jPDNlUIGwIUmFhylv5V6HcgBQNaEyIiXaqQowDqi8e4rgKiPvAEhdshNHaqBw48ZIrSEx04 mGDb2jrNB0YFnhYouLuagZLWB45N6Id3Kx/yqqZbmuDSupW+masgienmCgt/r20QktmRkO4 MSOX1Ugsi04mspkV6F8KA== UI-OutboundReport: notjunk:1;M01:P0:8zp5s8d3byQ=;VxTDJnXgSWcqoj9jK6Z0jrgUKRV xdIXae7LSGr11uz887/DmX+feK/EuW2DkElSDBcPwoMbBS0EKDziZmY8n3lhk0VlIeoOtHSms 0mdDqhAEgVNanjszFxz62e13szM8r8LHBbTD/ToCB1fRPwLttuQp0kghoy/hYcbehmyQVFHOe KKbok64aSuwX7Lnyng57IQ5IHRvmLwatggE2O79/BDsMn99YrVrNFmk1AONbeLrsPm+WWvTZb FfWojLxucdiWbpaLcQgl5k8H1qcXE7sLze9Ye2xoM/WmAL5ZQDbMM1QLJo+wuNseA6RGNtvOS F+EWCzzrPalH1hqUroL6DfQyjfpAINgqTOxRFDvrfKSadWzGz/aBN+g/Lnl3DwtX4RkJFcrnq iLSDWAb4+mDRPXSW/aTWRlET2gcVsnTZnGtWkZUMvDL4ghWvB6xrTgoT08LzdfB4tvB/AUV7U VCIv8jO/Zn285MXjBpBODkmTHnr75YJd8T0txWkFb7WDtWLSOLNJ4+RRdRF4p5GYtJhbH7tkf NM+O9rtYdXzUFdd7L8P6fx7F5Qo5c8Kc97k7l5nBOXvv6EESCiAgNMdlb7uaH3bHjSERXlKdd YRtZPUBJ23dBznF4RhF5yYpbyviDStqJOFx65aVrEASqGAWqOzNA5pWVWHe5l1F/b/epjkN9i 29YMG/gPjx2ZyDMv2Wvn/p02BVQ8esMyvRdw9v77Qw== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the MAC address is not provided by the vdpa device virtio_net driver assigns a random one without notifying the device. The consequence, in the case of mlx5_vdpa, is the internal routing tables of the device are not updated and this can block the communication between two namespaces. To fix this problem, use virtnet_send_command(VIRTIO_NET_CTRL_MAC) to set the address from virtnet_probe() when the MAC address is randomly assigned from virtio_net. While I was testing this change I found 3 other bugs in vdpa_sim_net: - vdpa_sim_net sets the VIRTIO_NET_F_MAC even if no MAC address is provided. So virtio_net doesn't generate a random MAC address and the MAC address appears to be 00:00:00:00:00:00 - vdpa_sim_net never processes the command and virtnet_send_command() hangs in an infinite loop. To avoid a kernel crash add a timeout in the loop. - To allow vdpa_sim_net to process the command, replace the cpu_relax() in the loop by a schedule(). vdpa_sim_net uses a workqueue to process the queue, and if we don't allow the kernel to schedule, the queue is not processed and the loop is infinite. Laurent Vivier (4): virtio_net: notify MAC address change on device initialization virtio_net: add a timeout in virtnet_send_command() vdpa_sim_net: don't always set VIRTIO_NET_F_MAC virtio_net: fix virtnet_send_command() with vdpa_sim_net drivers/net/virtio_net.c | 21 +++++++++++++++++++-- drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 6 ++++++ 2 files changed, 25 insertions(+), 2 deletions(-) -- 2.39.0