All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clnt_create: Restore using reserve ports for client connections
@ 2018-04-11 15:08 Steve Dickson
  2018-04-11 15:20 ` Chuck Lever
  2018-04-12 14:26 ` Steve Dickson
  0 siblings, 2 replies; 4+ messages in thread
From: Steve Dickson @ 2018-04-11 15:08 UTC (permalink / raw)
  To: Libtirpc-devel Mailing List; +Cc: Linux NFS Mailing list

Commit 46e04a73 changed clnt_create(3) not to
use reserve ports when binding a connection to
a server.

For certain legacy apps, like some of the NIS commands,
the client has to used reserve port to be able
to communicate with the server.

So the use of reserve ports in clnt_create(3)
has been restored.

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 src/clnt_generic.c | 3 +--
 src/rpc_soc.c      | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/clnt_generic.c b/src/clnt_generic.c
index e5a314f..774292b 100644
--- a/src/clnt_generic.c
+++ b/src/clnt_generic.c
@@ -341,8 +341,7 @@ clnt_tli_create(int fd, const struct netconfig *nconf,
 		servtype = nconf->nc_semantics;
 		if (!__rpc_fd2sockinfo(fd, &si))
 			goto err;
-		if (__binddynport(fd) == -1)
-			goto err;
+		bindresvport(fd, NULL);
 	} else {
 		if (!__rpc_fd2sockinfo(fd, &si))
 			goto err;
diff --git a/src/rpc_soc.c b/src/rpc_soc.c
index af6c482..f32a27c 100644
--- a/src/rpc_soc.c
+++ b/src/rpc_soc.c
@@ -147,8 +147,7 @@ clnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp, flags)
 	bindaddr.maxlen = bindaddr.len =  sizeof (struct sockaddr_in);
 	bindaddr.buf = raddr;
 
-	if (__binddynport(fd) == -1)
-		goto err;
+	bindresvport(fd, NULL);
 	cl = clnt_tli_create(fd, nconf, &bindaddr, prog, vers,
 				sendsz, recvsz);
 	if (cl) {
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] clnt_create: Restore using reserve ports for client connections
  2018-04-11 15:08 [PATCH] clnt_create: Restore using reserve ports for client connections Steve Dickson
@ 2018-04-11 15:20 ` Chuck Lever
  2018-04-11 15:52   ` Steve Dickson
  2018-04-12 14:26 ` Steve Dickson
  1 sibling, 1 reply; 4+ messages in thread
From: Chuck Lever @ 2018-04-11 15:20 UTC (permalink / raw)
  To: Steve Dickson; +Cc: libtirpc List, Linux NFS Mailing List

Hi Steve-

> On Apr 11, 2018, at 9:08 AM, Steve Dickson <steved@redhat.com> wrote:
>=20
> Commit 46e04a73 changed clnt_create(3) not to
> use reserve ports when binding a connection to
> a server.
>=20
> For certain legacy apps, like some of the NIS commands,
> the client has to used reserve port to be able
> to communicate with the server.

This is still not clear.

The problem is not that the RPC client has to use a reserved
port, it's that the client implementations currently assume
that clnt_create(3) will allocate a reserved port for them,
which is undocumented API behavior.

One more comment below.


> So the use of reserve ports in clnt_create(3)
> has been restored.
>=20
> Signed-off-by: Steve Dickson <steved@redhat.com>
> ---
> src/clnt_generic.c | 3 +--
> src/rpc_soc.c      | 3 +--
> 2 files changed, 2 insertions(+), 4 deletions(-)
>=20
> diff --git a/src/clnt_generic.c b/src/clnt_generic.c
> index e5a314f..774292b 100644
> --- a/src/clnt_generic.c
> +++ b/src/clnt_generic.c
> @@ -341,8 +341,7 @@ clnt_tli_create(int fd, const struct netconfig =
*nconf,
> 		servtype =3D nconf->nc_semantics;
> 		if (!__rpc_fd2sockinfo(fd, &si))
> 			goto err;
> -		if (__binddynport(fd) =3D=3D -1)
> -			goto err;
> +		bindresvport(fd, NULL);

If this is the last __binddynport call site in clnt_generic.c,
you can remove its forward declaration (line 50 in my copy of
the source).


> 	} else {
> 		if (!__rpc_fd2sockinfo(fd, &si))
> 			goto err;
> diff --git a/src/rpc_soc.c b/src/rpc_soc.c
> index af6c482..f32a27c 100644
> --- a/src/rpc_soc.c
> +++ b/src/rpc_soc.c
> @@ -147,8 +147,7 @@ clnt_com_create(raddr, prog, vers, sockp, sendsz, =
recvsz, tp, flags)
> 	bindaddr.maxlen =3D bindaddr.len =3D  sizeof (struct =
sockaddr_in);
> 	bindaddr.buf =3D raddr;
>=20
> -	if (__binddynport(fd) =3D=3D -1)
> -		goto err;
> +	bindresvport(fd, NULL);
> 	cl =3D clnt_tli_create(fd, nconf, &bindaddr, prog, vers,
> 				sendsz, recvsz);
> 	if (cl) {
> --=20
> 2.14.3
>=20
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" =
in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
Chuck Lever




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] clnt_create: Restore using reserve ports for client connections
  2018-04-11 15:20 ` Chuck Lever
@ 2018-04-11 15:52   ` Steve Dickson
  0 siblings, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2018-04-11 15:52 UTC (permalink / raw)
  To: Chuck Lever; +Cc: libtirpc List, Linux NFS Mailing List



On 04/11/2018 11:20 AM, Chuck Lever wrote:
> Hi Steve-
> 
>> On Apr 11, 2018, at 9:08 AM, Steve Dickson <steved@redhat.com> wrote:
>>
>> Commit 46e04a73 changed clnt_create(3) not to
>> use reserve ports when binding a connection to
>> a server.
>>
>> For certain legacy apps, like some of the NIS commands,
>> the client has to used reserve port to be able
>> to communicate with the server.
> 
> This is still not clear.
> 
> The problem is not that the RPC client has to use a reserved
> port, it's that the client implementations currently assume
> that clnt_create(3) will allocate a reserved port for them,
> which is undocumented API behavior.
An assumption that that has been valid for the last 20yrs
so that assumption is part of the API... IMHO... 

I'm going to leave as is... 

> 
> One more comment below.
> 
> 
>> So the use of reserve ports in clnt_create(3)
>> has been restored.
>>
>> Signed-off-by: Steve Dickson <steved@redhat.com>
>> ---
>> src/clnt_generic.c | 3 +--
>> src/rpc_soc.c      | 3 +--
>> 2 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/clnt_generic.c b/src/clnt_generic.c
>> index e5a314f..774292b 100644
>> --- a/src/clnt_generic.c
>> +++ b/src/clnt_generic.c
>> @@ -341,8 +341,7 @@ clnt_tli_create(int fd, const struct netconfig *nconf,
>> 		servtype = nconf->nc_semantics;
>> 		if (!__rpc_fd2sockinfo(fd, &si))
>> 			goto err;
>> -		if (__binddynport(fd) == -1)
>> -			goto err;
>> +		bindresvport(fd, NULL);
> 
> If this is the last __binddynport call site in clnt_generic.c,
> you can remove its forward declaration (line 50 in my copy of
> the source).
Yeah there is a couple of those... already cleaned up... 

Thanks..

steved.

> 
> 
>> 	} else {
>> 		if (!__rpc_fd2sockinfo(fd, &si))
>> 			goto err;
>> diff --git a/src/rpc_soc.c b/src/rpc_soc.c
>> index af6c482..f32a27c 100644
>> --- a/src/rpc_soc.c
>> +++ b/src/rpc_soc.c
>> @@ -147,8 +147,7 @@ clnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp, flags)
>> 	bindaddr.maxlen = bindaddr.len =  sizeof (struct sockaddr_in);
>> 	bindaddr.buf = raddr;
>>
>> -	if (__binddynport(fd) == -1)
>> -		goto err;
>> +	bindresvport(fd, NULL);
>> 	cl = clnt_tli_create(fd, nconf, &bindaddr, prog, vers,
>> 				sendsz, recvsz);
>> 	if (cl) {
>> -- 
>> 2.14.3
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> --
> Chuck Lever
> 
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] clnt_create: Restore using reserve ports for client connections
  2018-04-11 15:08 [PATCH] clnt_create: Restore using reserve ports for client connections Steve Dickson
  2018-04-11 15:20 ` Chuck Lever
@ 2018-04-12 14:26 ` Steve Dickson
  1 sibling, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2018-04-12 14:26 UTC (permalink / raw)
  To: Libtirpc-devel Mailing List; +Cc: Linux NFS Mailing list



On 04/11/2018 11:08 AM, Steve Dickson wrote:
> Commit 46e04a73 changed clnt_create(3) not to
> use reserve ports when binding a connection to
> a server.
> 
> For certain legacy apps, like some of the NIS commands,
> the client has to used reserve port to be able
> to communicate with the server.
> 
> So the use of reserve ports in clnt_create(3)
> has been restored.
> 
> Signed-off-by: Steve Dickson <steved@redhat.com>
Committed... 

steved.
> ---
>  src/clnt_generic.c | 3 +--
>  src/rpc_soc.c      | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/src/clnt_generic.c b/src/clnt_generic.c
> index e5a314f..774292b 100644
> --- a/src/clnt_generic.c
> +++ b/src/clnt_generic.c
> @@ -341,8 +341,7 @@ clnt_tli_create(int fd, const struct netconfig *nconf,
>  		servtype = nconf->nc_semantics;
>  		if (!__rpc_fd2sockinfo(fd, &si))
>  			goto err;
> -		if (__binddynport(fd) == -1)
> -			goto err;
> +		bindresvport(fd, NULL);
>  	} else {
>  		if (!__rpc_fd2sockinfo(fd, &si))
>  			goto err;
> diff --git a/src/rpc_soc.c b/src/rpc_soc.c
> index af6c482..f32a27c 100644
> --- a/src/rpc_soc.c
> +++ b/src/rpc_soc.c
> @@ -147,8 +147,7 @@ clnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp, flags)
>  	bindaddr.maxlen = bindaddr.len =  sizeof (struct sockaddr_in);
>  	bindaddr.buf = raddr;
>  
> -	if (__binddynport(fd) == -1)
> -		goto err;
> +	bindresvport(fd, NULL);
>  	cl = clnt_tli_create(fd, nconf, &bindaddr, prog, vers,
>  				sendsz, recvsz);
>  	if (cl) {
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-12 14:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-11 15:08 [PATCH] clnt_create: Restore using reserve ports for client connections Steve Dickson
2018-04-11 15:20 ` Chuck Lever
2018-04-11 15:52   ` Steve Dickson
2018-04-12 14:26 ` Steve Dickson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.