Skip to content
Open
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
20 changes: 20 additions & 0 deletions lib/opte/src/engine/flow_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ impl Ttl {
}
}

/// An eviction policy table which makes TCP flow entries without live flowstate
/// parents trivially evictable. When present, the TCP flow state will signal
/// a value to be used in its place.
#[derive(Clone, Copy, Debug)]
pub struct TtlDelegateTcp(pub Ttl);

/// A metric of how stale a flow entry is, used to determine whether
/// any existing entry can be evicted to make room for a new one.
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Default)]
Expand Down Expand Up @@ -102,6 +108,20 @@ impl<S: FlowState> ExpiryPolicy<S> for Ttl {
self.is_expired(entry.last_hit(), now)
}

fn eviction_priority(
&self,
_entry: &FlowEntry<S>,
_now: Moment,
) -> Option<EvictionPriority> {
None
}
}

impl<S: FlowState> ExpiryPolicy<S> for TtlDelegateTcp {
fn is_expired(&self, entry: &FlowEntry<S>, now: Moment) -> bool {
self.0.is_expired(entry.last_hit(), now)
}

fn eviction_priority(
&self,
entry: &FlowEntry<S>,
Expand Down
16 changes: 14 additions & 2 deletions lib/opte/src/engine/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ use crate::ddi::kstat::KStatProvider;
use crate::ddi::kstat::KStatU64;
use crate::ddi::mblk::MsgBlk;
use crate::ddi::time::Moment;
use crate::engine::flow_table::FLOW_DEF_TTL;
use crate::engine::flow_table::FlowState;
use crate::engine::flow_table::TtlDelegateTcp;
use alloc::ffi::CString;
use alloc::string::String;
use alloc::string::ToString;
Expand Down Expand Up @@ -326,8 +328,18 @@ impl LayerFlowTable {
Self {
count: 0,
limit,
ft_in: FlowTable::new(port, &format!("{layer}_in"), limit, None),
ft_out: FlowTable::new(port, &format!("{layer}_out"), limit, None),
ft_in: FlowTable::new(
port,
&format!("{layer}_in"),
limit,
Some(Arc::new(TtlDelegateTcp(FLOW_DEF_TTL))),
),
ft_out: FlowTable::new(
port,
&format!("{layer}_out"),
limit,
Some(Arc::new(TtlDelegateTcp(FLOW_DEF_TTL))),
),
}
}

Expand Down