Skip to contentSkip to conversation

fs: nfs: Error if a port is unregistered

PATCH Superseded John Watts 3 participants 8 messages Feb 1, 2023 – Feb 3, 2023 VFS

lore
Share & tools
lore

John Watts

author
#0 lore raw

PATCH 1/1 fs: nfs: Error if a port is unregistered

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.

---
 fs/nfs.c | 3 +++
 1 file changed, 3 insertions(+)
fs/nfs.c +3 -0
index 446d0f7946..696630684e 100644
@@ -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;
 }
 
Signature · 1 line
2.39.1
#1 lore raw
Quoted 16 lines · 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.

---
 fs/nfs.c | 3 +++
 1 file changed, 3 insertions(+)
fs/nfs.c +0 -0
index 446d0f7946..696630684e 100644

fs/nfs.c static int rpc_lookup_req(struct nfs_priv *npriv, uint32_t prog, uint32_t ver) · line 576

Quoted 6 lines
fs/nfs.c +3 -0
@@ -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

Signature · 4 lines
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 |
author
#2 lore raw
Quoted 3 lines · Sascha Hauer

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.

Quoted 1 line

Sascha

John.

#3 lore raw
Quoted 14 lines · Jookia
Quoted 3 lines · Sascha Hauer

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

Quoted 8 lines

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?

Quoted 6 lines
Quoted 2 lines

Sascha

John.

Signature · 4 lines
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 |
author
#4 lore raw
Quoted 1 line · Ahmad Fatoum

Add a pr_warn with a descriptive message?

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

John.

#5 lore raw
Quoted 4 lines · John Watts
Quoted 1 line · Ahmad Fatoum

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

Quoted 3 lines

John.

Signature · 4 lines
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 |
author
#6 lore raw

PATCH v2 1/1 fs: nfs: Error if a port is unregistered

In reply to 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.

---
Changes v1 -> v2:
- Added error message

---
 fs/nfs.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/nfs.c +6 -0
index 446d0f7946..1a0b28442d 100644
@@ -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;
 }
 
Signature · 1 line
2.39.1
Applied
#7 lore raw
Quoted 8 lines · 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.

Quoted 7 lines

---
Changes v1 -> v2:
- Added error message

---
 fs/nfs.c | 6 ++++++
 1 file changed, 6 insertions(+)

Applied, thanks

Sascha

Quoted 23 lines
fs/nfs.c +6 -0
index 446d0f7946..1a0b28442d 100644
@@ -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;
 }
 
Signature · 1 line
2.39.1
Signature · 4 lines
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 |