Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1190081iob; Wed, 4 May 2022 17:02:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBnWen1XYUro5nIecmwkG8hv/FLdbTZH7ffC/VIfNrym6S37pPLC9ylrsb6fX2P4dPGCMq X-Received: by 2002:a17:902:b906:b0:14f:76a0:ad48 with SMTP id bf6-20020a170902b90600b0014f76a0ad48mr24639913plb.79.1651708939813; Wed, 04 May 2022 17:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651708939; cv=none; d=google.com; s=arc-20160816; b=QkZ6K1obu9uNP41HkmMR2ehQoL5zjsQWlpr1jCP0OWo1z2ZoxRxbOyaWyYdQBSxAUB a7afEtH2m0Nq3hjSVTv0sTaUsSgk0LmNi/um4TayQIhYuGY/bcaLLXobbGQrXBsAGuOV kkXgzWkBSu2Amkz3wjS+XGyr/hRsCVH37HbxPKHXRiceUaqvHhr7eTnta0g4BI9rppRr OY1PE6kKLQ6YXLuixbbCyje1rf7AVJQgZ+0eo6puV7GsoCEThqYU9BoAkEtrhmWUG4J6 /H1Whw3CmUDRD5UPMQfJb5c4J8xHaCyDkSaiAZNqf/UxHqPdXbTmY3yVDtaLMuAL9QvN j9NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=t3AseDwiAdzbSTjiqVdJwbSkKY3FVk6KBeh7c27Cu6o=; b=W/TglLDraYh7vcUD7/qFUUQdWqpFgONlEO3iI2luo4z/8+UPdESC2BVZuvBnyNjcDA bUoDq/GPjO9b7V0/5yWBGr4ws7hY+1i5qgFVP/4I2jZOvSChHeCOlzBrBsnQ7+ZJX4rp ngBMjwbfnsaKgyEAKlAss2xA+aZf3riotONz2jip6Oag+NCzz2DrnNP1E/Ba5sYkXyTc EENwpretZSle8JzrDcVzCVEQs7ncp9fkzIJfvk+I5cOfpOVJEltC/bkJ+zJLKvLDWyhl 27eI3bLnwUDCjawF9i3UmRt+bat1HFaoymFg3uA7leTnps8ecmmqOeGDfdbOD6pKpud6 Q+MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yQOTU3yi; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a17090311cf00b00153b2d16541si173125plh.329.2022.05.04.17.02.01; Wed, 04 May 2022 17:02:19 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yQOTU3yi; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356768AbiEDRTA (ORCPT + 99 others); Wed, 4 May 2022 13:19:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356301AbiEDRFI (ORCPT ); Wed, 4 May 2022 13:05:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D42450B38; Wed, 4 May 2022 09:54:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BC9A6B82792; Wed, 4 May 2022 16:54:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B48DC385B1; Wed, 4 May 2022 16:54:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683240; bh=SNx83Pbjpg0ZcHfND6i5kAbdpaRsicsaY11CcJYsxrw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yQOTU3yiqAwjDfSOOJGBpZIe/0dNWRqGS+gqrdXzcKSB7F5DCqvJYEFjbtLZRmz13 DoV+NptLRA+rWfInli9Rj9YZOjV10rHJ+2rctrXhhYGxPgMmew2YNUn8Sw5NJPWly+ LrLLNNVQl+irVwnonR/PhcdOG3CsJkB2ou31/6c8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, liuyacan , Tony Lu , Karsten Graul , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 097/177] net/smc: sync err code when tcp connection was refused Date: Wed, 4 May 2022 18:44:50 +0200 Message-Id: <20220504153101.812740917@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: liuyacan [ Upstream commit 4e2e65e2e56c6ceb4ea1719360080c0af083229e ] In the current implementation, when TCP initiates a connection to an unavailable [ip,port], ECONNREFUSED will be stored in the TCP socket, but SMC will not. However, some apps (like curl) use getsockopt(,,SO_ERROR,,) to get the error information, which makes them miss the error message and behave strangely. Fixes: 50717a37db03 ("net/smc: nonblocking connect rework") Signed-off-by: liuyacan Reviewed-by: Tony Lu Acked-by: Karsten Graul Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/smc/af_smc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 499058248bdb..fb801c249d92 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1223,6 +1223,8 @@ static void smc_connect_work(struct work_struct *work) smc->sk.sk_state = SMC_CLOSED; if (rc == -EPIPE || rc == -EAGAIN) smc->sk.sk_err = EPIPE; + else if (rc == -ECONNREFUSED) + smc->sk.sk_err = ECONNREFUSED; else if (signal_pending(current)) smc->sk.sk_err = -sock_intr_errno(timeo); sock_put(&smc->sk); /* passive closing */ -- 2.35.1