From patchwork Tue Apr 10 21:30:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 10333865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7AA946053C for ; Tue, 10 Apr 2018 21:30:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6257B28479 for ; Tue, 10 Apr 2018 21:30:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60CB1284F5; Tue, 10 Apr 2018 21:30:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 515DD284D1 for ; Tue, 10 Apr 2018 21:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751770AbeDJVar (ORCPT ); Tue, 10 Apr 2018 17:30:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40744 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752016AbeDJVaq (ORCPT ); Tue, 10 Apr 2018 17:30:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C1145D68B; Tue, 10 Apr 2018 21:30:46 +0000 (UTC) Received: from steved.boston.devel.redhat.com (ovpn-117-159.phx2.redhat.com [10.3.117.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32BA98E3F3; Tue, 10 Apr 2018 21:30:46 +0000 (UTC) From: Steve Dickson To: Libtirpc-devel Mailing List Cc: Linux NFS Mailing list Subject: [PATCH 2/2] Restore creating listening connection to server connections Date: Tue, 10 Apr 2018 17:30:43 -0400 Message-Id: <20180410213043.5545-2-steved@redhat.com> In-Reply-To: <20180410213043.5545-1-steved@redhat.com> References: <20180410213043.5545-1-steved@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 10 Apr 2018 21:30:46 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 46e04a73 changed svc_com_create() to avoid using reserve ports but removed the listen() call which could break, undocumented expectations, of legacy server apps. Reserve ports are not needed for listening ports, so the new __binddynport() is used to avoid squatting on ports that are assigned to other network services, but it is important to say backwards compatible with the legacy glibc code so the the listen() call is added back. Signed-off-by: Steve Dickson --- src/rpc_soc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/rpc_soc.c b/src/rpc_soc.c index f32a27c..cf15216 100644 --- a/src/rpc_soc.c +++ b/src/rpc_soc.c @@ -331,6 +331,13 @@ svc_com_create(fd, sendsize, recvsize, netid) madefd = TRUE; } + if (__binddynport(fd) == -1) { + if (madefd) + (void)close(fd); + (void) syslog(LOG_ERR, + "svc%s_create: could not bind connection: %m", netid); + } + listen(fd, SOMAXCONN); svc = svc_tli_create(fd, nconf, NULL, sendsize, recvsize); (void) freenetconfigent(nconf); if (svc == NULL) {