From 257ed82dbded434d18095b72b5008435fb31599e Mon Sep 17 00:00:00 2001 From: Jhonny Sousa Date: Mon, 27 Oct 2025 15:45:48 -0300 Subject: [PATCH] nfs: Fix NFSv2 STATFS procedure parsing Ticket: #5140 --- rust/src/nfs/log.rs | 8 +++++++- rust/src/nfs/types.rs | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/rust/src/nfs/log.rs b/rust/src/nfs/log.rs index 291a519c01..2c6c171c2e 100644 --- a/rust/src/nfs/log.rs +++ b/rust/src/nfs/log.rs @@ -82,12 +82,18 @@ fn nfs_common_header( state: &NFSState, tx: &NFSTransaction, js: &mut JsonBuilder, ) -> Result<(), JsonError> { js.set_uint("version", state.nfs_version as u64)?; - if state.nfs_version < 4 { + if state.nfs_version == 3 { if let Some(proc) = NfsProc3::from_u(tx.procedure) { js.set_string("procedure", &proc.to_str().to_uppercase())?; } else { js.set_string("procedure", &format!("{}", tx.procedure))?; } + } else if state.nfs_version <= 2 { + if let Some(proc) = NfsProc2::from_u(tx.procedure) { + js.set_string("procedure", &proc.to_str().to_uppercase())?; + } else { + js.set_string("procedure", &format!("{}", tx.procedure))?; + } } else if let Some(proc) = NfsProc4::from_u(tx.procedure) { js.set_string("procedure", &proc.to_str().to_uppercase())?; } else { diff --git a/rust/src/nfs/types.rs b/rust/src/nfs/types.rs index 6315a6de76..0b09881c0c 100644 --- a/rust/src/nfs/types.rs +++ b/rust/src/nfs/types.rs @@ -15,6 +15,31 @@ * 02110-1301, USA. */ +/* RFC 1094, section '2.2 Server Procedures' */ +#[repr(u32)] +#[derive(EnumStringU32)] +#[allow(non_camel_case_types)] +pub enum NfsProc2 { + NULL = 0, + GETATTR = 1, + SETATTR = 2, + ROOT = 3, + LOOKUP = 4, + READLINK = 5, + READ = 6, + WRITECACHE = 7, + WRITE = 8, + CREATE = 9, + REMOVE = 10, + RENAME = 11, + LINK = 12, + SYMLINK = 13, + MKDIR = 14, + RMDIR = 15, + READDIR = 16, + STATFS = 17, +} + /* RFC 1813, section '3. Server Procedures' */ pub const NFSPROC3_NULL: u32 = 0; pub const NFSPROC3_GETATTR: u32 = 1;