[NFS] fetching kernel via nfs

Dear u-boot people,
I encountered some problems trying to fetch the Linux kernel via nfs (v3). One problem was that the nfs file lookup always returned NFS3ERR_BADHANDLE. This is due to the following line in nfs_lookup_req() function (net/nfs.c):
len = (uint32_t *)p - (uint32_t *)&(data[0]); rpc_req(PROG_NFS, NFS_LOOKUP, data, len); } else { /* NFS_V3 */ *p++ = htonl(NFS_FHSIZE); /* Dir handle length */ <===== this line memcpy(p, dirfh, NFS_FHSIZE); p += (NFS_FHSIZE / 4); *p++ = htonl(fnamelen);
In the NFS_V3 case we add the dir file handle size to data and then the dir file handle. IUC, this is not correct here because dirfh includes already the size of the handle in the first 4 bytes. Feel free to correct me if I am wrong.
As a result, if I remove the line "*p++ = htonl(NFS_FHSIZE);", it works fine.
Don't have an in deps understanding of nfs, so I am not sure if this is the root problem here.
Best regards Johannes

Hello,
On 5/15/24 14:40, Johannes Kirchmair - SKIDATA wrote:
Dear u-boot people,
I encountered some problems trying to fetch the Linux kernel via nfs (v3). One problem was that the nfs file lookup always returned NFS3ERR_BADHANDLE.
I have fixed this. See:
https://source.denx.de/u-boot/u-boot/-/commit/d2986567b27dae764b19886bcda1d2...
Regards,
This is due to the following line in nfs_lookup_req() function (net/nfs.c):
len = (uint32_t *)p - (uint32_t *)&(data[0]); rpc_req(PROG_NFS, NFS_LOOKUP, data, len);
} else { /* NFS_V3 */ *p++ = htonl(NFS_FHSIZE); /* Dir handle length */ <===== this line memcpy(p, dirfh, NFS_FHSIZE); p += (NFS_FHSIZE / 4); *p++ = htonl(fnamelen);
In the NFS_V3 case we add the dir file handle size to data and then the dir file handle. IUC, this is not correct here because dirfh includes already the size of the handle in the first 4 bytes. Feel free to correct me if I am wrong.
As a result, if I remove the line "*p++ = htonl(NFS_FHSIZE);", it works fine.
Don't have an in deps understanding of nfs, so I am not sure if this is the root problem here.
Best regards Johannes

Hello Sébastien,
missed that because was testing on v2024.4. And did not think about looking at master branch because it seemed to be broken for quite a while.
Anyways, thanks for the quick response and for fixing this thing.
Best regards
-----Ursprüngliche Nachricht----- Von: Sébastien Szymanski sebastien.szymanski@armadeus.com Gesendet: Mittwoch, 15. Mai 2024 18:53 An: Johannes Kirchmair - SKIDATA Johannes.Kirchmair@skidata.com; u-boot@lists.denx.de Cc: joe.hershberger@ni.com; rfried.dev@gmail.com Betreff: Re: [NFS] fetching kernel via nfs
[Sie erhalten nicht häufig E-Mails von sebastien.szymanski@armadeus.com. Weitere Informationen, warum dies wichtig ist, finden Sie unter https://aka.ms/LearnAboutSenderIdentification ]
EXTERNAL EMAIL
Hello,
On 5/15/24 14:40, Johannes Kirchmair - SKIDATA wrote:
Dear u-boot people,
I encountered some problems trying to fetch the Linux kernel via nfs (v3). One problem was that the nfs file lookup always returned NFS3ERR_BADHANDLE.
I have fixed this. See:
https://source.denx.de/u-boot/u-boot/-/commit/d2986567b27dae764b19886bcda1d2...
Regards,
This is due to the following line in nfs_lookup_req() function (net/nfs.c):
len = (uint32_t *)p - (uint32_t *)&(data[0]); rpc_req(PROG_NFS, NFS_LOOKUP, data, len); } else { /* NFS_V3 */ *p++ = htonl(NFS_FHSIZE); /* Dir handle length */ <===== this line memcpy(p, dirfh, NFS_FHSIZE); p += (NFS_FHSIZE / 4); *p++ = htonl(fnamelen);
In the NFS_V3 case we add the dir file handle size to data and then the dir file handle. IUC, this is not correct here because dirfh includes already the size of the handle in the first 4 bytes. Feel free to correct me if I am wrong.
As a result, if I remove the line "*p++ = htonl(NFS_FHSIZE);", it works fine.
Don't have an in deps understanding of nfs, so I am not sure if this is the root problem here.
Best regards Johannes
-- Sébastien Szymanski, Armadeus Systems Software engineer
participants (2)
-
Johannes Kirchmair - SKIDATA
-
Sébastien Szymanski