Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3743592pxb; Mon, 1 Nov 2021 20:09:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2bBvEQAyyGsMJnBtmhhVorDlwOTJ+mQ+OL3FS9FITZs3vUWHuJ8zACPmHkkMOu868vQdi X-Received: by 2002:a5d:8619:: with SMTP id f25mr23854136iol.46.1635822562586; Mon, 01 Nov 2021 20:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635822562; cv=none; d=google.com; s=arc-20160816; b=HNyKUxYSt3VLQXNhWjJTzO6h9FYVbevt/qlvdve8/+/d4AMONe4NGfRvHw2Wj7FBAo oXBF3D6A2mw5xU5oGpF5qZWtuggWrGeuG0HhpULtVtraHegox8xhipjN9MAjA7tdYiTC 86IPHfs3fs1mQLnqtLL1xoZsSQLlIFytWyp//fStVmA4K9bbER7R+OiWL114x1aQLsKq Ueu38r21XpBKQdSg8vMrMDJtKDiv26AUqNSfasm1Ka6DCpzempXD1673D4T+JaOzMIJu K3ZS8Yca9Hbi3oFhHKrBA57EuzYXTZ9eUA2cUHmhkqIOFOH5KfNM9Godj//kd1UkrJM9 Jn+w== 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; bh=ohFXz6LKA7GQrxDs90BQYlkOW3EnDYCVyATxfEJ3c1w=; b=Orgh8Y9lWahfsFLi5ThGtkZdIUuEFXejOjTy3LCMu1z63qYYraKEvEXGe6MusotQXy R6S+ok2bA960kgBPle9kJ2wLjyTRLygt9+180WCY3LrJL6UrvIc7dE5+2coPshAs1GHy m4g2aGcCNj81/7GdEXBKG5FkyMpyrA4zo7BWTAM5b7PyyjJScPTwAB/qJ7bgy7PxqAzR rUFbmhqJyecZDzh2Aiz6/S98jgpGTcfb/v2LHf68Qpu1bMzs93/MCu3o8V0cc6IcOjKK Zs/SpvvVgR7OQbA8ynUjP1FDT/0p6hYWOy2rmH6PSjePQMMgb1AdhBPm5KWehzsnMotu NLog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=yMQvzI7i; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v4si16949566jat.45.2021.11.01.20.08.56; Mon, 01 Nov 2021 20:09:22 -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=yMQvzI7i; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229699AbhKBDL3 (ORCPT + 99 others); Mon, 1 Nov 2021 23:11:29 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:47666 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbhKBDL2 (ORCPT ); Mon, 1 Nov 2021 23:11:28 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 54D6F21957; Tue, 2 Nov 2021 03:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1635822533; 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=ohFXz6LKA7GQrxDs90BQYlkOW3EnDYCVyATxfEJ3c1w=; b=yMQvzI7iG0XUdZrZiRz4+FWQK/IxRqTJ460RJLPsXz5v0CELOWNxG/pBJ60PKXBhPZ6gaC JuXbKzOlxHgIw6G8fTjFb/YPcUK23/720USRPuv7n1lBMGKp9bPwS89Gbz3NQFcB5c6kXc lHanziIxpm4imr8BDb8ac0cyrky9to4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1635822533; 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=ohFXz6LKA7GQrxDs90BQYlkOW3EnDYCVyATxfEJ3c1w=; b=cxKDvwbCj5bSVSCJwx1SNXptBxi2X3GHk3n/VIMQ8JMbP/o594O3n5OUivOQwc8pkn0Nnm K1uqZgQ/Ir1BOgDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7D0B213B6F; Tue, 2 Nov 2021 03:08:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id HUW5DsSrgGHmBwAAMHmgww (envelope-from ); Tue, 02 Nov 2021 03:08:52 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: Steve Dickson Cc: linux-nfs@vger.kernel.org Subject: [PATCH nfs-utils] mount: don't bind a socket needlessly. Date: Tue, 02 Nov 2021 14:08:48 +1100 Message-id: <163582252847.13683.7467712657489228784@noble.neil.brown.name> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org When clnt_ping() calls get_socket(), get_socket() will create a socket, call bind() to choose an unused local port, and then connect to the given address. The "bind()" call is unnecessary and problematic. It is unnecessary as the "connect()" call will bind the socket as required. It is problematic as it requires a completely unused port number, rather than just a port number which isn't currently in use for connecting to the given remote address. If all local ports (net.ipv4.ip_local_port_range) are in use, the bind() will fail. However the connect() call will only fail if all those port are in use for connecting to the same address. So remove the unnecessary bind() call. Signed-off-by: NeilBrown --- utils/mount/network.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/utils/mount/network.c b/utils/mount/network.c index e803dbbe5a2c..35261171a615 100644 --- a/utils/mount/network.c +++ b/utils/mount/network.c @@ -429,10 +429,6 @@ static int get_socket(struct sockaddr_in *saddr, unsigne= d int p_prot, if (resvp) { if (bindresvport(so, &laddr) < 0) goto err_bindresvport; - } else { - cc =3D bind(so, SAFE_SOCKADDR(&laddr), namelen); - if (cc < 0) - goto err_bind; } if (type =3D=3D SOCK_STREAM || (conn && type =3D=3D SOCK_DGRAM)) { cc =3D connect_to(so, SAFE_SOCKADDR(saddr), namelen, --=20 2.33.1