]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
nfs: update ts only if it changed
authorVictor Julien <victor@inliniac.net>
Mon, 20 Jul 2020 12:18:52 +0000 (14:18 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 25 Aug 2020 12:49:26 +0000 (14:49 +0200)
Based on 8aa380600da15b95e74a6649e6003a1c484c4ce0

(cherry picked from commit f8e9fe95cb233ede9941e893b0e9789900368949)

rust/src/nfs/nfs.rs

index 0879d3a31ff4b4a82072eb32dd3550474ee22af9..b9dcd59c3328d95229850f200e2ab9766123c5cd 100644 (file)
@@ -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]