From: Victor Julien Date: Mon, 20 Jul 2020 12:18:52 +0000 (+0200) Subject: nfs: update ts only if it changed X-Git-Tag: suricata-5.0.4~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77c79ebb86b0056f6dd8d123c07e3f04ee06fe17;p=thirdparty%2Fsuricata.git nfs: update ts only if it changed Based on 8aa380600da15b95e74a6649e6003a1c484c4ce0 (cherry picked from commit f8e9fe95cb233ede9941e893b0e9789900368949) --- diff --git a/rust/src/nfs/nfs.rs b/rust/src/nfs/nfs.rs index 0879d3a31f..b9dcd59c33 100644 --- a/rust/src/nfs/nfs.rs +++ b/rust/src/nfs/nfs.rs @@ -386,6 +386,13 @@ impl NFSState { ts: 0, } } + + fn update_ts(&mut self, ts: u64) { + if ts != self.ts { + self.ts = ts; + } + } + pub fn free(&mut self) { self.files.free(); } @@ -1463,12 +1470,8 @@ pub extern "C" fn rs_nfs_parse_request(flow: &mut Flow, let buf = unsafe{std::slice::from_raw_parts(input, input_len as usize)}; SCLogDebug!("parsing {} bytes of request data", input_len); - state.ts = flow.get_last_time().as_secs(); - if state.parse_tcp_data_ts(buf) == 0 { - 1 - } else { - -1 - } + state.update_ts(flow.get_last_time().as_secs()); + return state.parse_tcp_data_ts(buf) as i8; } #[no_mangle] @@ -1495,12 +1498,8 @@ pub extern "C" fn rs_nfs_parse_response(flow: &mut Flow, SCLogDebug!("parsing {} bytes of response data", input_len); let buf = unsafe{std::slice::from_raw_parts(input, input_len as usize)}; - state.ts = flow.get_last_time().as_secs(); - if state.parse_tcp_data_tc(buf) == 0 { - 1 - } else { - -1 - } + state.update_ts(flow.get_last_time().as_secs()); + return state.parse_tcp_data_tc(buf) as i8; } #[no_mangle]