Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1937687lqp; Tue, 16 Apr 2024 02:22:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXyfcJcdsDrfMWl5oz/4V2Ce/6IcD0f2AiHhlurX6r/+HN+V42htf4lBvclBL7JZE+obOe+jbhnzd4P0tdjIqk8+kEHNo3LtQQyiqlqLA== X-Google-Smtp-Source: AGHT+IF3M9q83ioC308u1Y526J9XgFFnY4sdggQhO+97hbhVMyKBpO64CpPySVf9eAOzSJC3DHLQ X-Received: by 2002:a17:906:407:b0:a55:3582:361d with SMTP id d7-20020a170906040700b00a553582361dmr1581504eja.27.1713259328501; Tue, 16 Apr 2024 02:22:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713259328; cv=pass; d=google.com; s=arc-20160816; b=zzKMDs5R3IC5J0ryjhzcEiZddEGLf7MnJqzrSqlR9NWQqGyB9/8LJj3DI/XYjuJmSe VcCUxbLr1JiiEDX/H9YB7rZp1SQEYRUICqO8Y4v1Olgf/QD6MYWD9kSXbsnSo+P1re20 RJSnKWjkCM0+zzgRVZpdpoT8Jt7SVJ0ygOotYgsK8iBRp1NW+T7rBXohF+83rRdupkY/ 3SOiEPqevrHw1fTwhNRHFBGXkcjY5WTTn+abc+hj0pGQB/cusMej+AyR2OXWdwYo60el 94BUkcgEnIncm3/NVSR4inm+qne1RB7oBIwqp7W730B/rYyqNGgi/crlHIqx3FnioAKt HgZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=kiwyWOGcNJkutQx3/UF61yMBlgwQSbAA6xLECT5Kq1Y=; fh=lwrJJvzjfj7lB1IkyMcoazZa5yRwRwSf1F9fyc8pJY0=; b=Iq4yv6YFQetMc+luHOEvo5MdXM7GKtxwSn8NDxHvJLvMo7PnDk8CcGl/843ivFRNi5 XA85XnULLZI3Sb6ekYdPDB9dVM/wVNYdZx46UYx5HDIDGCHKIqD/K3N2epamdgH0nvEb ozhGsaVOczOyjYPoy2A97BeAvVS/eYitxfIiNXrSk50AzqW/R0dty5OUy52DBx8rlTic 9M/v98hlYE7GE9ARqAmX4zsn0yERUzBXujB7nB3MqnvEv67wYKYV0KRn4yzgnUecNCn3 rEFxEidi209b2Ygkqy6byLbhsublHYAswyKpi8spfmOkTjZO2mWqQ9tI6ALluoZdqUpJ Z+gg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=easystack.cn dmarc=pass fromdomain=easystack.cn); spf=pass (google.com: domain of linux-kernel+bounces-146550-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146550-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=easystack.cn Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ht17-20020a170907609100b00a525910c974si2876517ejc.643.2024.04.16.02.22.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 02:22:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146550-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=easystack.cn dmarc=pass fromdomain=easystack.cn); spf=pass (google.com: domain of linux-kernel+bounces-146550-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146550-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=easystack.cn Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A19B71F2336C for ; Tue, 16 Apr 2024 09:21:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8091585299; Tue, 16 Apr 2024 09:21:24 +0000 (UTC) Received: from mail-m17218.xmail.ntesmail.com (mail-m17218.xmail.ntesmail.com [45.195.17.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3C1DEEB7; Tue, 16 Apr 2024 09:21:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.195.17.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713259284; cv=none; b=KpY2LafUJF0ZhA6apQ2nkvhnKj8t6YnLIYKdvrML7w6iZNLs81MKsvAdFX6a5nLRUOT05pIcNyDH2udiLPHmX94USlUvJJbsxQajet5dRpM7wAeH3yn6UsjoTYrjcoWX0XbEKYZKavqDleixLSzsNzKkjgwh9Pve5Z/cTEyZx5o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713259284; c=relaxed/simple; bh=ZrWqunt2M13HDfUp3oWrpInp1x6kLgr26fgi2oG168U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OU6069qgnE8sPrzIy8snYe22oqItsqzOEqn3rapXLjEXW7/g2ng6bCl2eORCX+ukr/TmXHfUl/yfccXBX6g1F2/om8eKrxEazGLc8J+yN71CICEm51nMS56jCoCLxSUUTK0NL9eIA/sL1J2gcy7BM40N/93pOP9bFJFuDafIyDU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=easystack.cn; spf=pass smtp.mailfrom=easystack.cn; arc=none smtp.client-ip=45.195.17.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=easystack.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=easystack.cn Received: from localhost.localdomain (unknown [110.185.170.227]) by smtp.qiye.163.com (Hmail) with ESMTPA id C2FB3560340; Tue, 16 Apr 2024 17:20:37 +0800 (CST) From: "jun.gu" To: echaudro@redhat.com Cc: dev@openvswitch.org, jun.gu@easystack.cn, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, pshelar@ovn.org Subject: [PATCH v2] net: openvswitch: Check vport net device name Date: Tue, 16 Apr 2024 17:20:22 +0800 Message-Id: <20240416092022.35887-1-jun.gu@easystack.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <084E7217-6290-46D2-A47A-14ACB60EBBCA@redhat.com> References: <084E7217-6290-46D2-A47A-14ACB60EBBCA@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJQjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCQhkdVkwZHhpDTkxIGBlDGlUZERMWGhIXJBQOD1 lXWRgSC1lBWUpKS1VKQ05VSkxLVUlJTFlXWRYaDxIVHRRZQVlPS0hVSk1PSUxOVUpLS1VKQktLWQ Y+ X-HM-Tid: 0a8ee6355216023dkunmc2fb3560340 X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6ORg6ERw6KDcyPyIzNjcUSS0s Q0oKFCNVSlVKTEpISU5CSUhDSUlLVTMWGhIXVREOFVUcDjseGggCCA8aGBBVGBVFWVdZEgtZQVlK SktVSkNOVUpMS1VJSUxZV1kIAVlBSU5ISjcG Check vport net device name to avoid the name that be used to query is inconsistent the retured name. Consider net device supports alias, the alias can be set to interface table in ovs userspace. Consider the following process: - set a net device alias to interface table. - ovs userspace run OVS_VPORT_CMD_NEW cmd to kernel, kernel will use net device alias to query net device by dev_get_by_name, but the net device name that return is inconsistent the name used to query. - the returned net device name is saved a hash table. - ovs userspace found that the name saved to interface table is inconsistent the name saved kernel hash table, it will run OVS_VPORT_CMD_DEL cmd to kernel and remove vport. ovs userspace will run OVS_VPORT_CMD_NEW and OVS_VPORT_CMD_DEL cmd repeatedly. So the patch will check vport net device name from dev_get_by_name to avoid the above issue. Signed-off-by: Jun Gu --- net/openvswitch/vport-netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c index 903537a5da22..de8977d7f329 100644 --- a/net/openvswitch/vport-netdev.c +++ b/net/openvswitch/vport-netdev.c @@ -78,7 +78,7 @@ 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) { + if (!vport->dev) || strcmp(name, ovs_vport_name(vport)) { err = -ENODEV; goto error_free_vport; } -- 2.25.1