Maximum transactions
~~~~~~~~~~~~~~~~~~~~
-MQTT, FTP, PostgreSQL and NFS have each a `max-tx` parameter that can be customized.
+MQTT, FTP, PostgreSQL, SMB and NFS have each a `max-tx` parameter that can be customized.
`max-tx` refers to the maximum number of live transactions for each flow.
An app-layer event `protocol.too_many_transactions` is triggered when this value is reached.
The point of this parameter is to find a balance between the completeness of analysis
static mut ALPROTO_SMB: AppProto = ALPROTO_UNKNOWN;
+static mut SMB_MAX_TX: usize = 1024;
+
pub static mut SURICATA_SMB_FILE_CONFIG: Option<&'static SuricataFileContext> = None;
#[no_mangle]
/// transactions list
pub transactions: VecDeque<SMBTransaction>,
+ tx_index_completed: usize,
/// tx counter for assigning incrementing id's to tx's
tx_id: u64,
check_post_gap_file_txs: false,
post_gap_files_checked: false,
transactions: VecDeque::new(),
+ tx_index_completed: 0,
tx_id:0,
dialect:0,
dialect_vec: None,
self.tx_id += 1;
tx.id = self.tx_id;
SCLogDebug!("TX {} created", tx.id);
+ if self.transactions.len() > unsafe { SMB_MAX_TX } {
+ let mut index = self.tx_index_completed;
+ for tx_old in &mut self.transactions.range_mut(self.tx_index_completed..) {
+ index += 1;
+ if !tx_old.request_done || !tx_old.response_done {
+ tx_old.request_done = true;
+ tx_old.response_done = true;
+ tx_old.set_event(SMBEvent::TooManyTransactions);
+ break;
+ }
+ }
+ self.tx_index_completed = index;
+
+ }
return tx;
}
if found {
SCLogDebug!("freeing TX with ID {} TX.ID {} at index {} left: {} max id: {}",
tx_id, tx_id+1, index, self.transactions.len(), self.tx_id);
+ self.tx_index_completed = 0;
self.transactions.remove(index);
}
}
Err(_) => { SCLogError!("Invalid max-read-queue-cnt value"); }
}
}
+ if let Some(val) = conf_get("app-layer.protocols.smb.max-tx") {
+ if let Ok(v) = val.parse::<usize>() {
+ SMB_MAX_TX = v;
+ } else {
+ SCLogError!("Invalid value for smb.max-tx");
+ }
+ }
} else {
SCLogDebug!("Protocol detector and parser disabled for SMB.");
}