mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fs: nfs: Error if a port is unregistered
@ 2023-02-01 22:34 John Watts
  2023-02-02  7:39 ` Sascha Hauer
  2023-02-02 11:20 ` [PATCH v2] " John Watts
  0 siblings, 2 replies; 8+ messages in thread
From: John Watts @ 2023-02-01 22:34 UTC (permalink / raw)
  To: barebox; +Cc: John Watts

If a server doesn't provide a service the port lookup will return 0.
Check for this and return an appropriate error code.

This was tested by running NFS with UDP disabled, which seems to be
the default in Arch at least.

Signed-off-by: John Watts <contact@jookia.org>
---
 fs/nfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/nfs.c b/fs/nfs.c
index 446d0f7946..696630684e 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -571,6 +571,9 @@ static int rpc_lookup_req(struct nfs_priv *npriv, uint32_t prog, uint32_t ver)
 
 	nfs_free_packet(nfs_packet);
 
+	if (port == 0)
+		return -ENOENT;
+
 	return port;
 }
 
-- 
2.39.1




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

* Re: [PATCH] fs: nfs: Error if a port is unregistered
  2023-02-01 22:34 [PATCH] fs: nfs: Error if a port is unregistered John Watts
@ 2023-02-02  7:39 ` Sascha Hauer
  2023-02-02  9:33   ` Jookia
  2023-02-02 11:20 ` [PATCH v2] " John Watts
  1 sibling, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2023-02-02  7:39 UTC (permalink / raw)
  To: John Watts; +Cc: barebox

On Thu, Feb 02, 2023 at 09:34:04AM +1100, John Watts wrote:
> If a server doesn't provide a service the port lookup will return 0.
> Check for this and return an appropriate error code.
> 
> This was tested by running NFS with UDP disabled, which seems to be
> the default in Arch at least.
> 
> Signed-off-by: John Watts <contact@jookia.org>
> ---
>  fs/nfs.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/nfs.c b/fs/nfs.c
> index 446d0f7946..696630684e 100644
> --- a/fs/nfs.c
> +++ b/fs/nfs.c
> @@ -571,6 +571,9 @@ static int rpc_lookup_req(struct nfs_priv *npriv, uint32_t prog, uint32_t ver)
>  
>  	nfs_free_packet(nfs_packet);
>  
> +	if (port == 0)
> +		return -ENOENT;
> +

When this happens do we see a meaningful error message on the barebox
side? From a feeling I would say -ECONNREFUSED might be a better error
code, but I don't know if that's suitable for UDP connections.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH] fs: nfs: Error if a port is unregistered
  2023-02-02  7:39 ` Sascha Hauer
@ 2023-02-02  9:33   ` Jookia
  2023-02-02  9:45     ` Ahmad Fatoum
  0 siblings, 1 reply; 8+ messages in thread
From: Jookia @ 2023-02-02  9:33 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Thu, Feb 02, 2023 at 08:39:48AM +0100, Sascha Hauer wrote:
> When this happens do we see a meaningful error message on the barebox
> side? From a feeling I would say -ECONNREFUSED might be a better error
> code, but I don't know if that's suitable for UDP connections.

Currently the error looks like this:

mounting failed with -110
ERROR: nfs nfs0: probe failed: Connection timed out
mount: Invalid argument
    probe-> nfs0
lookup mount port failed with -110
ERROR: nfs nfs0: probe failed: Connection timed out

Now it looks like:

lookup mount port failed with -2
ERROR: nfs nfs0: probe failed: No such file or directory
mount: Invalid argument
    probe-> nfs0

Not sure how this could be improved.

> Sascha

John.



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

* Re: [PATCH] fs: nfs: Error if a port is unregistered
  2023-02-02  9:33   ` Jookia
@ 2023-02-02  9:45     ` Ahmad Fatoum
  2023-02-02 10:31       ` John Watts
  0 siblings, 1 reply; 8+ messages in thread
From: Ahmad Fatoum @ 2023-02-02  9:45 UTC (permalink / raw)
  To: Jookia, Sascha Hauer; +Cc: barebox

On 02.02.23 10:33, Jookia wrote:
> On Thu, Feb 02, 2023 at 08:39:48AM +0100, Sascha Hauer wrote:
>> When this happens do we see a meaningful error message on the barebox
>> side? From a feeling I would say -ECONNREFUSED might be a better error
>> code, but I don't know if that's suitable for UDP connections.
> 
> Currently the error looks like this:
> 
> mounting failed with -110
> ERROR: nfs nfs0: probe failed: Connection timed out
> mount: Invalid argument
>     probe-> nfs0
> lookup mount port failed with -110
> ERROR: nfs nfs0: probe failed: Connection timed out
> 
> Now it looks like:
> 
> lookup mount port failed with -2
> ERROR: nfs nfs0: probe failed: No such file or directory
> mount: Invalid argument
>     probe-> nfs0
> 
> Not sure how this could be improved.

Add a pr_warn with a descriptive message?

> 
>> Sascha
> 
> John.
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

* Re: [PATCH] fs: nfs: Error if a port is unregistered
  2023-02-02  9:45     ` Ahmad Fatoum
@ 2023-02-02 10:31       ` John Watts
  2023-02-02 10:54         ` Ahmad Fatoum
  0 siblings, 1 reply; 8+ messages in thread
From: John Watts @ 2023-02-02 10:31 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Sascha Hauer, barebox

On Thu, Feb 02, 2023 at 10:45:05AM +0100, Ahmad Fatoum wrote:
> Add a pr_warn with a descriptive message?

Something like "hint: check your nfs server supports UDP"?

John.



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

* Re: [PATCH] fs: nfs: Error if a port is unregistered
  2023-02-02 10:31       ` John Watts
@ 2023-02-02 10:54         ` Ahmad Fatoum
  0 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-02-02 10:54 UTC (permalink / raw)
  To: John Watts; +Cc: Sascha Hauer, barebox

On 02.02.23 11:31, John Watts wrote:
> On Thu, Feb 02, 2023 at 10:45:05AM +0100, Ahmad Fatoum wrote:
>> Add a pr_warn with a descriptive message?
> 
> Something like "hint: check your nfs server supports UDP"?

Or maybe: "No UDP port announced. Is the NFS server TCP-only?"

Cheers,
Ahmad

> 
> John.
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

* [PATCH v2] fs: nfs: Error if a port is unregistered
  2023-02-01 22:34 [PATCH] fs: nfs: Error if a port is unregistered John Watts
  2023-02-02  7:39 ` Sascha Hauer
@ 2023-02-02 11:20 ` John Watts
  2023-02-03  8:00   ` Sascha Hauer
  1 sibling, 1 reply; 8+ messages in thread
From: John Watts @ 2023-02-02 11:20 UTC (permalink / raw)
  To: barebox; +Cc: John Watts

If a server doesn't provide a service the port lookup will return 0.

Check for this, return an appropriate error code and give a hint as to
why this might be happening.

This was tested by running NFS with UDP disabled, which seems to be
the default in Arch at least.

Signed-off-by: John Watts <contact@jookia.org>
---
Changes v1 -> v2:
- Added error message
---
 fs/nfs.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/nfs.c b/fs/nfs.c
index 446d0f7946..1a0b28442d 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -571,6 +571,12 @@ static int rpc_lookup_req(struct nfs_priv *npriv, uint32_t prog, uint32_t ver)
 
 	nfs_free_packet(nfs_packet);
 
+	if (port == 0) {
+		pr_warn("No UDP port for RPC program %i! "
+		        "Is your NFS server TCP only?\n", prog);
+		return -ENOENT;
+	}
+
 	return port;
 }
 
-- 
2.39.1




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

* Re: [PATCH v2] fs: nfs: Error if a port is unregistered
  2023-02-02 11:20 ` [PATCH v2] " John Watts
@ 2023-02-03  8:00   ` Sascha Hauer
  0 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2023-02-03  8:00 UTC (permalink / raw)
  To: John Watts; +Cc: barebox

On Thu, Feb 02, 2023 at 10:20:24PM +1100, John Watts wrote:
> If a server doesn't provide a service the port lookup will return 0.
> 
> Check for this, return an appropriate error code and give a hint as to
> why this might be happening.
> 
> This was tested by running NFS with UDP disabled, which seems to be
> the default in Arch at least.
> 
> Signed-off-by: John Watts <contact@jookia.org>
> ---
> Changes v1 -> v2:
> - Added error message
> ---
>  fs/nfs.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/fs/nfs.c b/fs/nfs.c
> index 446d0f7946..1a0b28442d 100644
> --- a/fs/nfs.c
> +++ b/fs/nfs.c
> @@ -571,6 +571,12 @@ static int rpc_lookup_req(struct nfs_priv *npriv, uint32_t prog, uint32_t ver)
>  
>  	nfs_free_packet(nfs_packet);
>  
> +	if (port == 0) {
> +		pr_warn("No UDP port for RPC program %i! "
> +		        "Is your NFS server TCP only?\n", prog);
> +		return -ENOENT;
> +	}
> +
>  	return port;
>  }
>  
> -- 
> 2.39.1
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2023-02-03  8:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-01 22:34 [PATCH] fs: nfs: Error if a port is unregistered John Watts
2023-02-02  7:39 ` Sascha Hauer
2023-02-02  9:33   ` Jookia
2023-02-02  9:45     ` Ahmad Fatoum
2023-02-02 10:31       ` John Watts
2023-02-02 10:54         ` Ahmad Fatoum
2023-02-02 11:20 ` [PATCH v2] " John Watts
2023-02-03  8:00   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox