Blame SOURCES/libtirpc-1.1.4-v2proto-mech.patch

076892
diff -up libtirpc-1.1.4/man/rpcbind.3t.orig libtirpc-1.1.4/man/rpcbind.3t
076892
--- libtirpc-1.1.4/man/rpcbind.3t.orig	2018-08-27 10:06:49.000000000 -0400
076892
+++ libtirpc-1.1.4/man/rpcbind.3t	2022-08-02 11:21:30.134642780 -0400
076892
@@ -187,6 +187,8 @@ in
076892
 .El
076892
 .Sh AVAILABILITY
076892
 These functions are part of libtirpc.
076892
+.Sh ENVIRONMENT
076892
+If RPCB_V2FIRST is defined, rpcbind protocol version tryout algorithm changes from v4,v2,v3 to v2,v4,v3.
076892
 .Sh SEE ALSO
076892
 .Xr rpc_clnt_calls 3 ,
076892
 .Xr rpc_svc_calls 3 ,
076892
diff -up libtirpc-1.1.4/src/rpcb_clnt.c.orig libtirpc-1.1.4/src/rpcb_clnt.c
076892
--- libtirpc-1.1.4/src/rpcb_clnt.c.orig	2022-08-02 11:20:42.795833195 -0400
076892
+++ libtirpc-1.1.4/src/rpcb_clnt.c	2022-08-02 11:21:30.135642797 -0400
076892
@@ -818,7 +818,8 @@ error:
076892
  * The algorithm used: If the transports is TCP or UDP, it first tries
076892
  * version 4 (srv4), then 3 and then fall back to version 2 (portmap).
076892
  * With this algorithm, we get performance as well as a plan for
076892
- * obsoleting version 2.
076892
+ * obsoleting version 2. This behaviour is reverted to old algorithm
076892
+ * if RPCB_V2FIRST environment var is defined
076892
  *
076892
  * For all other transports, the algorithm remains as 4 and then 3.
076892
  *
076892
@@ -839,6 +840,10 @@ __rpcb_findaddr_timed(program, version,
076892
 #ifdef NOTUSED
076892
 	static bool_t check_rpcbind = TRUE;
076892
 #endif
076892
+
076892
+#ifdef PORTMAP
076892
+	static bool_t portmap_first = FALSE;
076892
+#endif
076892
 	CLIENT *client = NULL;
076892
 	RPCB parms;
076892
 	enum clnt_stat clnt_st;
076892
@@ -895,8 +900,18 @@ __rpcb_findaddr_timed(program, version,
076892
 		parms.r_addr = (char *) &nullstring[0];
076892
 	}
076892
 
076892
-	/* First try from start_vers(4) and then version 3 (RPCBVERS) */
076892
+	/* First try from start_vers(4) and then version 3 (RPCBVERS), except
076892
+	 * if env. var RPCB_V2FIRST is defined */
076892
+
076892
+#ifdef PORTMAP
076892
+	if (getenv(V2FIRST)) {
076892
+		portmap_first = TRUE;
076892
+		LIBTIRPC_DEBUG(3, ("__rpcb_findaddr_timed: trying v2-port first\n"));
076892
+		goto portmap;
076892
+	}
076892
+#endif
076892
 
076892
+rpcbind:
076892
 	CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *) &rpcbrmttime);
076892
 	for (vers = start_vers;  vers >= RPCBVERS; vers--) {
076892
 		/* Set the version */
076892
@@ -944,10 +959,17 @@ __rpcb_findaddr_timed(program, version,
076892
 	}
076892
 
076892
 #ifdef PORTMAP 	/* Try version 2 for TCP or UDP */
076892
+	if (portmap_first)
076892
+		goto error; /* we tried all versions if reached here */
076892
+portmap:
076892
 	if (strcmp(nconf->nc_protofmly, NC_INET) == 0) {
076892
 		address = __try_protocol_version_2(program, version, nconf, host, tp);
076892
-		if (address == NULL)
076892
-			goto error;
076892
+		if (address == NULL) {
076892
+			if (portmap_first)
076892
+				goto rpcbind;
076892
+			else
076892
+				goto error;
076892
+		}
076892
 	}
076892
 #endif		/* PORTMAP */
076892
 
076892
diff -up libtirpc-1.1.4/tirpc/rpc/pmap_prot.h.orig libtirpc-1.1.4/tirpc/rpc/pmap_prot.h
076892
--- libtirpc-1.1.4/tirpc/rpc/pmap_prot.h.orig	2018-08-27 10:06:49.000000000 -0400
076892
+++ libtirpc-1.1.4/tirpc/rpc/pmap_prot.h	2022-08-02 11:21:30.135642797 -0400
076892
@@ -84,6 +84,8 @@
076892
 #define PMAPPROC_DUMP		((u_long)4)
076892
 #define PMAPPROC_CALLIT		((u_long)5)
076892
 
076892
+#define V2FIRST		"RPCB_V2FIRST"
076892
+
076892
 struct pmap {
076892
 	long unsigned pm_prog;
076892
 	long unsigned pm_vers;