From patchwork Tue Apr 11 12:11:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Dan_Hor=C3=A1k?= X-Patchwork-Id: 13207500 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 558F1C77B70 for ; Tue, 11 Apr 2023 12:18:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229588AbjDKMSk (ORCPT ); Tue, 11 Apr 2023 08:18:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229707AbjDKMSj (ORCPT ); Tue, 11 Apr 2023 08:18:39 -0400 X-Greylist: delayed 412 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 11 Apr 2023 05:18:37 PDT Received: from redcrew.org (redcrew.org [37.157.195.192]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9101D2D4E for ; Tue, 11 Apr 2023 05:18:37 -0700 (PDT) Received: from server.danny.cz (85-71-161-19.rce.o2.cz [85.71.161.19]) by redcrew.org (Postfix) with ESMTP id 07C902C49; Tue, 11 Apr 2023 14:11:44 +0200 (CEST) Received: from talos.danny.cz (unknown [IPv6:2001:470:5c11:160:47df:83f6:718e:218]) by server.danny.cz (Postfix) with ESMTP id 6BE1C11AA3F; Tue, 11 Apr 2023 14:11:43 +0200 (CEST) From: =?utf-8?q?Dan_Hor=C3=A1k?= To: libtirpc-devel@lists.sourceforge.net Cc: linux-nfs@vger.kernel.org, Rob Riggs Subject: [PATCH] allow TCP-only portmapper Date: Tue, 11 Apr 2023 14:11:42 +0200 Message-Id: <20230411121142.23312-1-dan@danny.cz> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Code that works in GLIBC's runrpc implementation fails with libtirpc. libtirpc forces the RPC library to talk to the portmapper via UDP, even when the client specifies TCP. This breaks existing code which expect the protocol specified to be honored, even when talking to portmapper. This is upstreaming of an old patch by Rob Riggs reported in Fedora. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1725329 Signed-off-by: Rob Riggs Signed-off-by: Dan HorĂ¡k --- src/rpcb_clnt.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c index 9a9de69..d178d86 100644 --- a/src/rpcb_clnt.c +++ b/src/rpcb_clnt.c @@ -496,11 +496,7 @@ getpmaphandle(nconf, hostname, tgtaddr) CLIENT *client = NULL; rpcvers_t pmapvers = 2; - /* - * Try UDP only - there are some portmappers out - * there that use UDP only. - */ - if (nconf == NULL || strcmp(nconf->nc_proto, NC_TCP) == 0) { + if (nconf == NULL) { struct netconfig *newnconf; if ((newnconf = getnetconfigent("udp")) == NULL) { @@ -509,7 +505,8 @@ getpmaphandle(nconf, hostname, tgtaddr) } client = getclnthandle(hostname, newnconf, tgtaddr); freenetconfigent(newnconf); - } else if (strcmp(nconf->nc_proto, NC_UDP) == 0) { + } else if (strcmp(nconf->nc_proto, NC_UDP) == 0 || + strcmp(nconf->nc_proto, NC_TCP) == 0) { if (strcmp(nconf->nc_protofmly, NC_INET) != 0) return NULL; client = getclnthandle(hostname, nconf, tgtaddr);