Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3276722pxj; Mon, 14 Jun 2021 19:43:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzOkT2etgI94ehrtv173pcxhaI+olS/IWiM+IQ/7OvMWMQBU/UMIArX87YcTbRN3U+stT6 X-Received: by 2002:a17:907:10d7:: with SMTP id rv23mr7259552ejb.163.1623725016359; Mon, 14 Jun 2021 19:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623725016; cv=none; d=google.com; s=arc-20160816; b=E0mhnCmZPw8c0X4lQvlvShU5YpTTqZTi8XuXyBvwej4OCWOj8kfKzSPq44qPMmFDYT QQ5eOmbwEqFQnrPZDMxOcfEacI70pcaKa3N6CHe2rUzdYIUoi4D5yIBiaADuzESifI4o rxRfCu7157B6WitNwRY5tvVbn1NlN2RCTMSn0qJIx3xusx+PMBJCkynnA6dSeePIc0UG if36/R4WA4Fqhm2TwgCCq1fru9R+7X8w5ffAfGfHzlv0Z3jryFnfl1TUnAaydG2uLkTt MMCUJXx+z+O07E+fAaz2DSC5SbnMtiyLqa9fOZuUOSmN0VX9p1JjngGEv5qIo8puwkpN djhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:mime-version :content-transfer-encoding:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=F06ZyStN8f99M7irca5GaI5PmNrxFECMaTmP5VtAe+k=; b=Fwe1ZNkJxm/0QKY7eWB/EIvUr8s9LjghQIHAgcvCCe9bDWKQOlZLXu0Li37YXDICxu eoCYZRHWS7a9JNbSv+sZIlm+bY2TykJZhkL9+yZeXJpThnUf+lYGdNUJ3PifVEMbBpLz /5dd8i7FqRAttDvCs4z6qbe/k+MkyUO684rtOcSi6eA4v6qdyTteaPkUgoeQD3F0QUPS 9Jz+beoXvEaRF6okneRXs2ysyPUN0g/ZK9OFGGKf11TMbL3UeIg759RfVcTC6+NDpp1t rwa8HfYrdcYwRifZgAEQ7D6a36FgWgUxPb5s+kvq7KtLeOSh/1Ma9mplzicPHvVYULfp GcgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=hEVwMeJ4; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=hEVwMeJ4; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dz10si12552722edb.266.2021.06.14.19.43.04; Mon, 14 Jun 2021 19:43:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=hEVwMeJ4; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=hEVwMeJ4; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbhFOCid (ORCPT + 99 others); Mon, 14 Jun 2021 22:38:33 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:33872 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbhFOCid (ORCPT ); Mon, 14 Jun 2021 22:38:33 -0400 Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2B0AD1FD2A; Tue, 15 Jun 2021 01:19:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623719942; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F06ZyStN8f99M7irca5GaI5PmNrxFECMaTmP5VtAe+k=; b=hEVwMeJ4E7VGal5sH8m4WRuDQvDgi3JClqZWDfAXNp49BfYAC+wdyZMMzc0HqPVICRn2NK bQWNe8ndbH1O+bgXInQ9XJRFxn+qMHineWB+lo8WnjjuMI5pcS1Lb+l2KVL51XMcDckdWd uVaCsIi2y+tf2IMl9uyChV4GCaQDB+A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623719942; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F06ZyStN8f99M7irca5GaI5PmNrxFECMaTmP5VtAe+k=; b=HgsyNqHcvrsWrfMDPUIW6GRjuR9mFdyAogvo2Ji/floO0G9R5OJdwmvcGCw8VoUnOBwi/i +4BtwQeTsdPjx0BA== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id C620D118DD; Tue, 15 Jun 2021 01:19:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623719942; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F06ZyStN8f99M7irca5GaI5PmNrxFECMaTmP5VtAe+k=; b=hEVwMeJ4E7VGal5sH8m4WRuDQvDgi3JClqZWDfAXNp49BfYAC+wdyZMMzc0HqPVICRn2NK bQWNe8ndbH1O+bgXInQ9XJRFxn+qMHineWB+lo8WnjjuMI5pcS1Lb+l2KVL51XMcDckdWd uVaCsIi2y+tf2IMl9uyChV4GCaQDB+A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623719942; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F06ZyStN8f99M7irca5GaI5PmNrxFECMaTmP5VtAe+k=; b=HgsyNqHcvrsWrfMDPUIW6GRjuR9mFdyAogvo2Ji/floO0G9R5OJdwmvcGCw8VoUnOBwi/i +4BtwQeTsdPjx0BA== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id B15gHQQAyGB7JQAALh3uQQ (envelope-from ); Tue, 15 Jun 2021 01:19:00 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH] SUNRPC: prevent port reuse on transports which don't request it. Date: Tue, 15 Jun 2021 11:18:38 +1000 Message-id: <162371991856.23575.16102887900102220450@noble.neil.brown.name> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If an RPC client is created without RPC_CLNT_CREATE_REUSEPORT, it should not reuse the source port when a TCP connection is re-established. This is currently implemented by preventing the source port being recorded after a successful connection (the call to xs_set_srcport()). However the source port is also recorded after a successful bind in xs_bind(). This may not be needed at all and certainly is not wanted when RPC_CLNT_CREATE_REUSEPORT wasn't requested. So avoid that assignment when xprt.reuseport is not set. With this change, NFSv4.1 and later mounts use a different port number on each connection. This is helpful with some firewalls which don't cope well with port reuse. Signed-off-by: NeilBrown --- net/sunrpc/xprtsock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 316d04945587..3228b7a1836a 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -1689,7 +1689,8 @@ static int xs_bind(struct sock_xprt *transport, struct = socket *sock) err =3D kernel_bind(sock, (struct sockaddr *)&myaddr, transport->xprt.addrlen); if (err =3D=3D 0) { - transport->srcport =3D port; + if (transport->xprt.reuseport) + transport->srcport =3D port; break; } last =3D port; --=20 2.31.1