2003-01-13 20:19:49

by Jochen Friedrich

[permalink] [raw]
Subject: [BUG 2.5.57] NFSv2 READDIR broken

Hi,

if mounting a Linux partition with NFSv2, READDIR fills in the last cookie
byte-swapped. The following READDIR will fail, so the NFS client sees a
truncated directory:

Frame 43 (1074 bytes on wire, 1074 bytes captured)
Ethernet II, Src: 00:00:e8:d4:01:61, Dst: 00:60:b3:1f:52:7c
Internet Protocol, Src Addr: 192.168.94.2 (192.168.94.2), Dst Addr: 192.168.95.4 (192.168.95.4)
User Datagram Protocol, Src Port: 2049 (2049), Dst Port: 800 (800)
Remote Procedure Call
Network File System
Program Version: 2
V2 Procedure: READDIR (16)
Status: OK (0)
Value Follows: Yes
Entry: file ID 1274231, name .
File ID: 1274231
Name: .
length: 1
contents: .
fill bytes: opaque data
Cookie: 12
Value Follows: Yes
[...]
Entry: file ID 1274709, name LICENSE.SRC
File ID: 1274709
Name: LICENSE.SRC
length: 11
contents: LICENSE.SRC
fill bytes: opaque data
Cookie: 644
Value Follows: Yes
Entry: file ID 1275342, name Makefile
File ID: 1275342
Name: Makefile
length: 8
contents: Makefile
Cookie: 2483159040 <<<<<<<<<<< should be 678
Value Follows: No
EOF: 0

This patch corrects the problem:

===== nfsproc.c 1.23 vs edited =====
--- 1.23/fs/nfsd/nfsproc.c Sat Jan 11 02:00:12 2003
+++ edited/nfsproc.c Mon Jan 13 21:03:28 2003
@@ -482,7 +482,7 @@

resp->count = resp->buffer - argp->buffer;
if (resp->offset)
- *resp->offset = (u32)offset;
+ *resp->offset = htonl(offset);

fh_put(&argp->fh);
return nfserr;

--jochen