Skip to content

Commit

Permalink
Add per-cpu fanout mode
Browse files Browse the repository at this point in the history
see #33

By assigning packets on per-cpu basis we ensure kernel's skb
structure (incl locks) gets shared across fewer cores than other
fanout strategies. This should result in higher throughput/lower
resource usage.

As per `man 8 ethtool`, all the valid `-N -U --config-nfc
--config-ntuple` options make sure flows get always scheduled to the
same core so by using PACKET_FANOUT_CPU we ensure that packets from
the same flow get assigned to the same socket.

Let's give it a try
  • Loading branch information
pikrzysztof committed Mar 22, 2024
1 parent 072b992 commit 974bc2e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/fanout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ use crate::args::{Error, FromArg};

const PACKET_FANOUT_HASH: u32 = 0x0;
const PACKET_FANOUT_LB: u32 = 0x1;
const PACKET_FANOUT_CPU: u32 = 0x2;

#[derive(Debug)]
#[repr(u32)]
pub enum Mode {
Hash = PACKET_FANOUT_HASH,
LB = PACKET_FANOUT_LB,
CPU = PACKET_FANOUT_CPU,
}

#[cfg(target_os = "linux")]
Expand Down Expand Up @@ -48,6 +50,7 @@ impl FromArg for Mode {
match mode {
"hash" => Ok(Mode::Hash),
"lb" => Ok(Mode::LB),
"cpu" => Ok(Mode::CPU),
other => Err(Error::Invalid(format!("invalid fanout mode: {}", other))),
}
}
Expand Down

0 comments on commit 974bc2e

Please sign in to comment.