[PATCH 04/10] fs: nfs: use net_eth_to_udp() for packet parsing

Sascha Hauer s.hauer at pengutronix.de
Wed Apr 1 23:36:43 PDT 2026


Replace net_eth_to_udp_payload() with the new consolidated
net_eth_to_udp() helper.

This also fixes a bug where the old code used the NIC-level frame
length (which includes ethernet, IP, and UDP headers) instead of the
UDP payload length when copying packet data.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
---
 fs/nfs.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/nfs.c b/fs/nfs.c
index 0b40c56ff3..39c92e4736 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1193,13 +1193,16 @@ static int nfs_read_req(struct file_priv *priv, uint64_t offset,
 
 static void nfs_handler(void *ctx, char *p, unsigned len)
 {
-	char *pkt = net_eth_to_udp_payload(p);
 	struct nfs_priv *npriv = ctx;
+	struct net_udp_pkt udp;
 	struct packet *packet;
 
-	packet = xmalloc(sizeof(*packet) + len);
-	memcpy(packet->data, pkt, len);
-	packet->len = len;
+	if (net_eth_to_udp(p, len, &udp))
+		return;
+
+	packet = xmalloc(sizeof(*packet) + udp.len);
+	memcpy(packet->data, udp.payload, udp.len);
+	packet->len = udp.len;
 	packet->pos = 0;
 
 	list_add_tail(&packet->list, &npriv->packets);

-- 
2.47.3




More information about the barebox mailing list