From: Trond Myklebust Subject: Re: Random UDP port assignment for rpc.statd Date: Sun, 20 Feb 2005 11:43:13 -0500 Message-ID: <1108917793.27120.43.camel@lade.trondhjem.org> References: <20050220111312.GA3974@s> <1108908221.27120.26.camel@lade.trondhjem.org> <20050220141037.GA7686@s> <1108913435.27120.40.camel@lade.trondhjem.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-Ym46F5bDriW11WPMG08f" Cc: Neil Brown , nfs@lists.sourceforge.net Received: from sc8-sf-mx2-b.sourceforge.net ([10.3.1.12] helo=sc8-sf-mx2.sourceforge.net) by sc8-sf-list2.sourceforge.net with esmtp (Exim 4.30) id 1D2uB9-0007Ss-Ev for nfs@lists.sourceforge.net; Sun, 20 Feb 2005 08:43:31 -0800 Received: from pat.uio.no ([129.240.130.16] ident=7411) by sc8-sf-mx2.sourceforge.net with esmtp (TLSv1:AES256-SHA:256) (Exim 4.41) id 1D2uB6-0007aM-NA for nfs@lists.sourceforge.net; Sun, 20 Feb 2005 08:43:31 -0800 To: Haakon Riiser In-Reply-To: <1108913435.27120.40.camel@lade.trondhjem.org> Sender: nfs-admin@lists.sourceforge.net Errors-To: nfs-admin@lists.sourceforge.net List-Unsubscribe: , List-Id: Discussion of NFS under Linux development, interoperability, and testing. List-Post: List-Help: List-Subscribe: , List-Archive: --=-Ym46F5bDriW11WPMG08f Content-Type: text/plain Content-Transfer-Encoding: 7bit su den 20.02.2005 Klokka 10:30 (-0500) skreiv Trond Myklebust: > See if the attached patch doesn't fix things so that your 3rd rpc.statd > port stays on the port specified by "-o"... Here is the same patch in a slightly cleaner version (it gets rid of the redundant comparison)... Neil, could you please apply to the main nfs-utils tree? Cheers, Trond -- Trond Myklebust --=-Ym46F5bDriW11WPMG08f Content-Disposition: inline; filename=nfs-utils-1.0.7-fix_outgoing_port.dif Content-Type: text/plain; name=nfs-utils-1.0.7-fix_outgoing_port.dif; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Ehem... 1) sin.sin_port is supposed to be in network order. 2) bindresvport() is used to automatically choose the port for you. if you want to set the port yourself, use bind() --- rmtcall.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) Index: nfs-utils/utils/statd/rmtcall.c =================================================================== --- nfs-utils.orig/utils/statd/rmtcall.c +++ nfs-utils/utils/statd/rmtcall.c @@ -65,7 +65,7 @@ statd_get_socket(int port) memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; - sin.sin_port = port; + sin.sin_addr.s_addr = INADDR_ANY; /* * If a local hostname is given (-n option to statd), bind to the address * specified. This is required to support clients that ignore the mon_name in @@ -76,11 +76,18 @@ statd_get_socket(int port) if (hp) sin.sin_addr = *(struct in_addr *) hp->h_addr; } + if (port != 0) { + sin.sin_port = htons(port); + if (bind(sockfd, &sin, sizeof(sin)) == 0) + goto out_success; + note(N_CRIT, "statd: failed to bind to outgoing port, %d\n" + " falling back on randomly chosen port\n", port); + } if (bindresvport(sockfd, &sin) < 0) { dprintf(N_WARNING, "process_hosts: can't bind to reserved port\n"); } - +out_success: return sockfd; } --=-Ym46F5bDriW11WPMG08f-- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs