From patchwork Wed Apr 17 04:20:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Gu X-Patchwork-Id: 1924489 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 4VK7520GP5z1yZ2 for ; Wed, 17 Apr 2024 14:21:09 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id DE4E6608A6; Wed, 17 Apr 2024 04:21:02 +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 nU7gsfNFAn-q; Wed, 17 Apr 2024 04:21:01 +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 534D560844 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 534D560844; Wed, 17 Apr 2024 04:21:01 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E28A3C007C; Wed, 17 Apr 2024 04:21:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 16CBFC0037 for ; Wed, 17 Apr 2024 04:21:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E5A8281336 for ; Wed, 17 Apr 2024 04:20:59 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 31gHS5xgcssH for ; Wed, 17 Apr 2024 04:20:59 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=45.195.24.4; helo=mail-m244.xmail.ntesmail.com; envelope-from=jun.gu@easystack.cn; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 542658130D Authentication-Results: smtp1.osuosl.org; dmarc=fail (p=none dis=none) header.from=easystack.cn DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 542658130D Received: from mail-m244.xmail.ntesmail.com (mail-m244.xmail.ntesmail.com [45.195.24.4]) by smtp1.osuosl.org (Postfix) with ESMTPS id 542658130D for ; Wed, 17 Apr 2024 04:20:57 +0000 (UTC) Received: from localhost.localdomain (unknown [110.185.170.227]) by smtp.qiye.163.com (Hmail) with ESMTPA id 79C865601D6; Wed, 17 Apr 2024 12:20:48 +0800 (CST) From: "jun.gu" To: echaudro@redhat.com Date: Wed, 17 Apr 2024 12:20:31 +0800 Message-Id: <20240417042031.157008-1-jun.gu@easystack.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <27644212-924C-4AB2-88F6-D209E2586E82@redhat.com> References: <27644212-924C-4AB2-88F6-D209E2586E82@redhat.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJQjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCH0IZVk0aSkNPQk8dTxlJTlUZERMWGhIXJBQOD1 lXWRgSC1lBWUpKS1VKQ05VSkxLVUlJTFlXWRYaDxIVHRRZQVlPS0hVSk1PSUxOVUpLS1VKQktLWQ Y+ X-HM-Tid: 0a8eea493018023dkunm79c865601d6 X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PyI6Iyo5FTcrQiEWDxcqDwIV FFYKCQFVSlVKTEpISElMTU9CSkpPVTMWGhIXVREOFVUcDjseGggCCA8aGBBVGBVFWVdZEgtZQVlK SktVSkNOVUpMS1VJSUxZV1kIAVlBSkNDQjcG Cc: dev@openvswitch.org, jun.gu@easystack.cn, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [ovs-dev] [PATCH net-next v3] net: openvswitch: Check vport net device 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" Check vport net device name to ensure the provided name is not one of its aliases. This can avoid that ovs userspace create and destroy vport repeatedly. 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; }