Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ The following tools must be installed, and their paths must be accessible and sp
|------|---------|
| Suricata | 9.0.0-dev (d030a9c4e 2026-04-01) |
| ethtool | 5.13 |
| ifconfig | net-tools 2.10-alpha |
| ip | iproute2-6.8.0, libbpf 0.5.0 |

## Configuration
Expand Down
4 changes: 0 additions & 4 deletions src/argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ pub enum Commands {
#[clap(short='e', long)]
ethtool_bin: Option<PathBuf>,

/// Ifconfig path to bin
#[clap(short='i', long)]
ifconfig_bin: Option<PathBuf>,

/// IP path to bin
#[clap(short='p', long)]
ip_bin: Option<PathBuf>,
Expand Down
13 changes: 8 additions & 5 deletions src/cpu_affinity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ impl Module for CpuAffinityModule {
Keys::interface,
Keys::capture_mode,
Keys::ethtool,
Keys::ifconfig,
Keys::capture_kernel_drops,
Keys::capture_kernel_packets,
Keys::capture_errors,
Expand All @@ -44,9 +43,9 @@ impl Module for CpuAffinityModule {
Keys::ethtool_stat,
Keys::flow_managers,
Keys::flow_recyclers,
Keys::ifconfig,
Keys::af_packet_interface_threads,
Keys::datetime
Keys::datetime,
Keys::ip
];

let questions: HashMap<Keys, Value> =
Expand Down Expand Up @@ -350,6 +349,10 @@ impl CpuAffinityModule {
answers.iter().find(|h| h.key == &Keys::ethtool).and_then(|h| h.value.as_str()).expect("Ethtool cannot be found.")
}

fn get_ip_stat<'a>(&self, answers: &Vec<Answer<'a>>) -> &'a str {
answers.iter().find(|h| h.key == &Keys::ip).and_then(|h| h.value.as_str()).expect("Ip cannot be found.")
}

fn get_datetime_stat(&self, answers: &Vec<Answer<'_>>) -> DateTime<Utc> {
answers.iter().find(|h| h.key == &Keys::datetime)
.and_then(|h| h.value.as_str()).and_then(|v| DateTime::parse_from_rfc3339(v).ok())
Expand Down Expand Up @@ -532,9 +535,9 @@ impl CpuAffinityModule {
fn module_af_packet_tuning(&self, answers: &Vec<Answer<'_>>, nic_file: &mut File) {
let interface = self.get_interface_stat(answers);
let ethtool = self.get_ethtool_stat(answers);
let ifconfig = answers.iter().find(|h| h.key == &Keys::ifconfig).and_then(|h| h.value.as_str()).expect("Ifconfig cannot be found.");
let ip = self.get_ip_stat(answers);
let wrk_cpu_set_len = self.get_wrk_cpu_set().len() as u64;
yaml::af_packet_tuning(interface, wrk_cpu_set_len, ethtool, ifconfig, nic_file);
yaml::af_packet_tuning(interface, wrk_cpu_set_len, ethtool, ip, nic_file);
}

fn module_set_rss(&self, answers: &Vec<Answer<'_>>, nic_file: &mut File) {
Expand Down
7 changes: 0 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ fn main() {
Ok(()) => {}
}

match suriconf.find_ifconfig_executable_file() {
Err(e) => {
panic!("{}", e);
}
Ok(()) => {}
}

match suriconf.find_ip_executable_file() {
Err(e) => {
panic!("{}", e);
Expand Down
3 changes: 0 additions & 3 deletions src/query/suriconf.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
"ethtool" : {
"path_to_value": "/ethtool-bin"
},
"ifconfig" : {
"path_to_value": "/ifconfig-bin"
},
"ip" :{
"path_to_value": "/ip-bin"

Expand Down
2 changes: 0 additions & 2 deletions src/structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ pub enum Keys { // JUST FOR FLOW
decoder_pkts,
decoder_invalid,
ethtool,
ifconfig,
ip,
ethtool_stat,
af_packet_interface_threads
Expand Down Expand Up @@ -367,7 +366,6 @@ impl Keys {
"decoder_pkts" => Keys::decoder_pkts,
"decoder_invalid" => Keys::decoder_invalid,
"ethtool" => Keys::ethtool,
"ifconfig" => Keys::ifconfig,
"ip" => Keys::ip,
"ethtool_stat" => Keys::ethtool_stat,
"af_packet_interface_threads" => Keys::af_packet_interface_threads,
Expand Down
1 change: 0 additions & 1 deletion src/suriconf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ suriconf-version: 1.0-dev
suri-configuration: suricata.yaml
suricata-bin: /usr/bin/suricata
ethtool-bin: /usr/bin/ethtool
ifconfig-bin: /usr/sbin/ifconfig
ip-bin: /usr/sbin/ip
log-dir: /var/log/suricata/
socket: /var/run/suricata/suricata-command.socket
Expand Down
30 changes: 5 additions & 25 deletions src/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ fn run_command_and_write_it_down(cmd: &str, args: &[&str], nic_file: &mut File)
output
}

pub fn af_packet_tuning(interface: &str, threads: u64, ethtool: &str, ifconfig: &str, nic_file: &mut File) {
pub fn af_packet_tuning(interface: &str, threads: u64, ethtool: &str, ip: &str, nic_file: &mut File) {
run_command_and_write_it_down("sudo", &["sysctl", "-w", "net.core.rmem_max=268435456"], nic_file);
run_command_and_write_it_down("sudo", &["sysctl", "-w", "net.core.netdev_max_backlog=16384"], nic_file);

Expand Down Expand Up @@ -393,7 +393,7 @@ pub fn af_packet_tuning(interface: &str, threads: u64, ethtool: &str, ifconfig:
None => { panic!("Unable to get driver.")}
};

run_command_and_write_it_down("sudo", &[format!("{ifconfig}").as_str(), format!("{interface}").as_str(), "down"], nic_file);
run_command_and_write_it_down("sudo", &[format!("{ip}").as_str(), "link", "set", format!("{interface}").as_str(), "down"], nic_file);
run_command_and_write_it_down("sudo", &[format!("{ethtool}").as_str(), "-X", format!("{interface}").as_str(), "default"], nic_file);
run_command_and_write_it_down("sudo", &[format!("{ethtool}").as_str(), "-L", interface, "combined", &threads.to_string()], nic_file);
run_command_and_write_it_down("sudo", &[format!("{ethtool}").as_str(), "-K", interface, "rxhash", "on"], nic_file);
Expand All @@ -403,7 +403,7 @@ pub fn af_packet_tuning(interface: &str, threads: u64, ethtool: &str, ifconfig:

}

run_command_and_write_it_down("sudo", &[format!("{ifconfig}").as_str(), format!("{interface}").as_str(), "up"], nic_file);
run_command_and_write_it_down("sudo", &[format!("{ip}").as_str(), "link", "set", format!("{interface}").as_str(), "up"], nic_file);

output = run_command_and_write_it_down("sudo", &[format!("{ethtool}").as_str(), "-x" ,format!("{interface}").as_str()], nic_file);

Expand Down Expand Up @@ -565,8 +565,8 @@ pub fn set_interface_with_threads(suricata_string: &mut Value, suriconf: &Surico
if shrink != 0 { // remove cpus to match RSS queues
cpus.drain(0..shrink as usize);
};
let ifconfig = suriconf.ifconfig_bin.to_str().expect("Unable to transform path to Ifconfig to str.");
af_packet_tuning(&suriconf.interface, cpus.len() as u64, ethtool, ifconfig, &mut nic_file);
let ip = suriconf.ip_bin.to_str().expect("Unable to transform path to Ip to str.");
af_packet_tuning(&suriconf.interface, cpus.len() as u64, ethtool, ip, &mut nic_file);
set_hard_irq(&suriconf.interface, &cpus, &mut nic_file);
}

Expand Down Expand Up @@ -723,7 +723,6 @@ pub struct Suriconf {
pub suri_configuration: PathBuf,
pub suricata_bin: PathBuf,
pub ethtool_bin: PathBuf,
pub ifconfig_bin: PathBuf,
pub ip_bin: PathBuf,
pub log_dir: PathBuf,
pub socket: PathBuf,
Expand Down Expand Up @@ -754,14 +753,6 @@ impl Suriconf {
}
}

pub fn find_ifconfig_executable_file(&self) -> Result<(), String> {
if self.ifconfig_bin.is_executable() {
Ok(())
} else {
Err(String::from("Unable to parse path to Ifconfig or Ifconfig is not executable."))
}
}

pub fn find_ip_executable_file(&self) -> Result<(), String> {
if self.ip_bin.is_executable() {
Ok(())
Expand Down Expand Up @@ -824,13 +815,6 @@ impl Suriconf {
self.find_ethtool_bin(suriconf_string).expect("Unable to parse path to Ethtool binary file.")
};

self.ifconfig_bin = if let Some(Commands::Suricata {ifconfig_bin: Some(p), ..}) = &args.cmd {
p.clone()
}
else {
self.find_ifconfig_bin(suriconf_string).expect("Unable to parse path to Ifconfig binary file.")
};

self.ip_bin = if let Some(Commands::Suricata {ip_bin: Some(p), ..}) = &args.cmd {
p.clone()
}
Expand Down Expand Up @@ -948,10 +932,6 @@ impl Suriconf {
text.get("ethtool-bin").and_then(|c| c.as_str()).map(|c| PathBuf::from(c))
}

pub fn find_ifconfig_bin(&self, text: &Value) -> Option<PathBuf> {
text.get("ifconfig-bin").and_then(|c| c.as_str()).map(|c| PathBuf::from(c))
}

pub fn find_ip_bin(&self, text: &Value) -> Option<PathBuf> {
text.get("ip-bin").and_then(|c| c.as_str()).map(|c| PathBuf::from(c))
}
Expand Down
Loading