From patchwork Thu Apr 18 02:32:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Gu X-Patchwork-Id: 1924798 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VKhdq4ksBz1yZP for ; Thu, 18 Apr 2024 12:33:02 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id C2803608BD; Thu, 18 Apr 2024 02:32:58 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 6MwK5NxUiJdz; Thu, 18 Apr 2024 02:32:57 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A22CA605CC Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id A22CA605CC; Thu, 18 Apr 2024 02:32:57 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 24A46C0077; Thu, 18 Apr 2024 02:32:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 54BF3C0037 for ; Thu, 18 Apr 2024 02:32:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 307E14083B for ; Thu, 18 Apr 2024 02:32:55 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5KDVuUU7Q1WS for ; Thu, 18 Apr 2024 02:32:54 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=154.81.10.5; helo=mail-m105.netease.com; envelope-from=jun.gu@easystack.cn; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 8B3FC4082E Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=easystack.cn DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 8B3FC4082E Received: from mail-m105.netease.com (mail-m105.netease.com [154.81.10.5]) by smtp4.osuosl.org (Postfix) with ESMTPS id 8B3FC4082E for ; Thu, 18 Apr 2024 02:32:52 +0000 (UTC) Received: from localhost.localdomain (unknown [110.185.170.227]) by smtp.qiye.163.com (Hmail) with ESMTPA id 6AE235601A7; Thu, 18 Apr 2024 10:32:44 +0800 (CST) From: "jun.gu" To: echaudro@redhat.com Date: Thu, 18 Apr 2024 10:32:42 +0800 Message-Id: <20240418023242.259542-1-jun.gu@easystack.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <811765EC-AD27-4210-9AFC-034129F24BFA@redhat.com> References: <811765EC-AD27-4210-9AFC-034129F24BFA@redhat.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJQjdXWS1ZQUlXWQ8JGhUIEh9ZQVlDSxhCVk9MTk1DT0pNSEkdSVUZERMWGhIXJBQOD1 lXWRgSC1lBWUpKS1VKQ05VSkxLVUlJTFlXWRYaDxIVHRRZQVlPS0hVSk1PSUxOVUpLS1VKQktLWQ Y+ X-HM-Tid: 0a8eef0c9ae6023dkunm6ae235601a7 X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6OC46HQw5Sjc4QhkLLBUhOUoc HUMwCS1VSlVKTEpIT0tMTk1PQ0pNVTMWGhIXVREOFVUcDjseGggCCA8aGBBVGBVFWVdZEgtZQVlK SktVSkNOVUpMS1VJSUxZV1kIAVlBSkJKTTcG Cc: dev@openvswitch.org, jun.gu@easystack.cn, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [ovs-dev] [PATCH net-next v4] net: openvswitch: Check vport netdev name X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Ensure that the provided netdev name is not one of its aliases to prevent unnecessary creation and destruction of the vport by ovs-vswitchd. Signed-off-by: Jun Gu Acked-by: Eelco Chaudron --- net/openvswitch/vport-netdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c index 903537a5da22..7003e76b8172 100644 --- a/net/openvswitch/vport-netdev.c +++ b/net/openvswitch/vport-netdev.c @@ -78,7 +78,10 @@ struct vport *ovs_netdev_link(struct vport *vport, const char *name) int err; vport->dev = dev_get_by_name(ovs_dp_get_net(vport->dp), name); - if (!vport->dev) { + /* Ensure that the device exists and that the provided + * name is not one of its aliases. + */ + if ((!vport->dev) || strcmp(name, ovs_vport_name(vport))) { err = -ENODEV; goto error_free_vport; }