nfs: fix applying nfs3 logging logic to nfs4

pull/3432/head
Victor Julien 7 years ago
parent cb3abba1e0
commit 90e0e3da27

@ -24,12 +24,13 @@ use nfs::nfs::*;
use crc::crc32; use crc::crc32;
#[no_mangle] #[no_mangle]
pub extern "C" fn rs_nfs_tx_logging_is_filtered(tx: &mut NFSTransaction) pub extern "C" fn rs_nfs_tx_logging_is_filtered(state: &mut NFSState,
-> libc::uint8_t tx: &mut NFSTransaction)
-> libc::uint8_t
{ {
// TODO probably best to make this configurable // TODO probably best to make this configurable
if tx.procedure == NFSPROC3_GETATTR { if state.nfs_version <= 3 && tx.procedure == NFSPROC3_GETATTR {
return 1; return 1;
} }
@ -68,13 +69,10 @@ fn nfs_file_object(tx: &NFSTransaction) -> Json
js.set_boolean("first", tx.is_first); js.set_boolean("first", tx.is_first);
js.set_boolean("last", tx.is_last); js.set_boolean("last", tx.is_last);
let ref tdf = match tx.type_data { if let Some(NFSTransactionTypeData::FILE(ref tdf)) = tx.type_data {
Some(NFSTransactionTypeData::FILE(ref x)) => x, js.set_integer("last_xid", tdf.file_last_xid as u64);
_ => { panic!("BUG") }, js.set_integer("chunks", tdf.chunk_count as u64);
}; }
js.set_integer("last_xid", tdf.file_last_xid as u64);
js.set_integer("chunks", tdf.chunk_count as u64);
return js; return js;
} }
/* /*
@ -130,15 +128,17 @@ pub extern "C" fn rs_nfs_log_json_response(state: &mut NFSState, tx: &mut NFSTra
js.set_string("status", &nfs3_status_string(tx.nfs_response_status)); js.set_string("status", &nfs3_status_string(tx.nfs_response_status));
if tx.procedure == NFSPROC3_READ { if state.nfs_version <= 3 {
let read_js = nfs_file_object(tx); if tx.procedure == NFSPROC3_READ {
js.set("read", read_js); let read_js = nfs_file_object(tx);
} else if tx.procedure == NFSPROC3_WRITE { js.set("read", read_js);
let write_js = nfs_file_object(tx); } else if tx.procedure == NFSPROC3_WRITE {
js.set("write", write_js); let write_js = nfs_file_object(tx);
} else if tx.procedure == NFSPROC3_RENAME { js.set("write", write_js);
let rename_js = nfs_rename_object(tx); } else if tx.procedure == NFSPROC3_RENAME {
js.set("rename", rename_js); let rename_js = nfs_rename_object(tx);
js.set("rename", rename_js);
}
} }
return js.unwrap(); return js.unwrap();

@ -95,7 +95,7 @@ static int JsonNFSLogger(ThreadVars *tv, void *thread_data,
NFSTransaction *nfstx = tx; NFSTransaction *nfstx = tx;
LogNFSLogThread *thread = thread_data; LogNFSLogThread *thread = thread_data;
if (rs_nfs_tx_logging_is_filtered(nfstx)) if (rs_nfs_tx_logging_is_filtered(state, nfstx))
return TM_ECODE_OK; return TM_ECODE_OK;
json_t *js = CreateJSONHeader(p, LOG_DIR_PACKET, "nfs"); json_t *js = CreateJSONHeader(p, LOG_DIR_PACKET, "nfs");

Loading…
Cancel
Save