Skip to content

Commit ed3b1df

Browse files
committed
NFS: Add a minimum support for NFSv4
tcpdump does not support NFSv4 and prints out wrong NFS data which always be "getattr" for NFSv4, because both NFSv4 COMPOUND procedure and NFSv2/3 GETATTR procedure are the same value '1'. This is a minimum support for NFSv4, which detects NFSv4 and can print out NULL procedure or COMPOUND procedure at least. Log of current no-NFSv4 support: NFS4_OK case 18:03:38.718964 IP client.815 > server.nfs: Flags [P.], seq 192:312, ack 177, win 22430, options [nop,nop,TS val 2190058497 ecr 3789310763], length 120: NFS request xid 1660218411 116 getattr fh 0,1/53 18:03:38.719279 IP server.nfs > client.815: Flags [P.], seq 177:261, ack 312, win 3333, options [nop,nop,TS val 3789310764 ecr 2190058497], length 84: NFS reply xid 1660218411 reply ok 80 getattr NON 1 ids 0/159 sz -719751424 NFS4ERR_NOENT case 18:03:44.707900 IP client.815 > server.nfs: Flags [P.], seq 312:512, ack 261, win 22430, options [nop,nop,TS val 2190064486 ecr 3789310864], length 200: NFS request xid 1676995627 196 getattr fh 0,1/53 18:03:44.708575 IP server.nfs > client.815: Flags [P.], seq 261:361, ack 512, win 3333, options [nop,nop,TS val 3789316753 ecr 2190064486], length 100: NFS reply xid 1676995627 reply ok 96 getattr ERROR: No such file or directory Log of this minimum NFSv4 support: NFS4_OK case 18:06:18.975026 IP client.815 > server.nfs: Flags [P.], seq 488:608, ack 549, win 22430, options [nop,nop,TS val 2190218753 ecr 3789464067], length 120: NFS request xid 1861545003 116 v4 compound 18:06:18.975276 IP server.nfs > client.815: Flags [P.], seq 549:633, ack 608, win 3333, options [nop,nop,TS val 3789471020 ecr 2190218753], length 84: NFS reply xid 1861545003 reply ok 80 v4 compound NFS4ERR_NOENT case 17:51:08.684565 IP client.815 > server.nfs: Flags [P.], seq 432:632, ack 345, win 22430, options [nop,nop,TS val 2189308462 ecr 3788560729], length 200: NFS request xid 888466475 196 v4 compound 17:51:08.685081 IP server.nfs > client.815: Flags [P.], seq 345:445, ack 632, win 3333, options [nop,nop,TS val 3788560730 ecr 2189308462], length 100: NFS reply xid 888466475 reply ok 96 v4 compound ERROR: No such file or directory Signed-off-by: Seiichi Ikarashi <[email protected]>
1 parent 87c9001 commit ed3b1df

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

nfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#define NFS_PROG 100003
5454
#define NFS_VER2 2
5555
#define NFS_VER3 3
56+
#define NFS_VER4 4
5657
#define NFS_V2MAXDATA 8192
5758
#define NFS_MAXDGRAMDATA 16384
5859
#define NFS_MAXDATA 32768

print-nfs.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,19 @@ nfsreq_noaddr_print(netdissect_options *ndo,
571571
v3 = (GET_BE_U_4(&rp->rm_call.cb_vers) == NFS_VER3);
572572
proc = GET_BE_U_4(&rp->rm_call.cb_proc);
573573

574+
if (GET_BE_U_4(&rp->rm_call.cb_vers) == NFS_VER4) {
575+
ND_PRINT(" v4");
576+
switch (proc) {
577+
case 0:
578+
ND_PRINT(" null");
579+
break;
580+
case 1:
581+
ND_PRINT(" compound");
582+
break;
583+
}
584+
return;
585+
}
586+
574587
if (!v3 && proc < NFS_NPROCS)
575588
proc = nfsv3_procid[proc];
576589

@@ -1539,6 +1552,25 @@ interp_reply(netdissect_options *ndo,
15391552
u_int er;
15401553
int nfserr = 0;
15411554

1555+
if (vers == NFS_VER4) {
1556+
ND_PRINT(" v4");
1557+
switch (proc) {
1558+
case 0:
1559+
ND_PRINT(" null");
1560+
break;
1561+
case 1:
1562+
ND_PRINT(" compound");
1563+
break;
1564+
}
1565+
dp = parserep(ndo, rp, length, &nfserr);
1566+
if (dp == NULL)
1567+
goto trunc;
1568+
dp = parsestatus(ndo, dp, &er, &nfserr);
1569+
if (dp == NULL)
1570+
goto trunc;
1571+
return;
1572+
}
1573+
15421574
v3 = (vers == NFS_VER3);
15431575

15441576
if (!v3 && proc < NFS_NPROCS)

0 commit comments

Comments
 (0)