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

Ahmad Fatoum
2026-04-17T10:11:06Z

On 4/2/26 8:36 AM, Sascha Hauer wrote:
> 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@pengutronix.de>
> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
> 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);
>

--
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 |