diff --git a/src/rust/lqos_sys/src/bpf/common/flows.h b/src/rust/lqos_sys/src/bpf/common/flows.h index d2f34e55..d97a5dd6 100644 --- a/src/rust/lqos_sys/src/bpf/common/flows.h +++ b/src/rust/lqos_sys/src/bpf/common/flows.h @@ -79,7 +79,7 @@ struct flow_data_t { // This is pinned and not per-CPU, because half the data appears on either side of the bridge. struct { - __uint(type, BPF_MAP_TYPE_LRU_HASH); // TODO: BPF_MAP_TYPE_LRU_PERCPU_HASH? + __uint(type, BPF_MAP_TYPE_HASH); // TODO: BPF_MAP_TYPE_LRU_PERCPU_HASH? __type(key, struct flow_key_t); __type(value, struct flow_data_t); __uint(max_entries, MAX_FLOWS); diff --git a/src/rust/lqos_sys/src/bpf_iterator.rs b/src/rust/lqos_sys/src/bpf_iterator.rs index c1ba3b83..1980299d 100644 --- a/src/rust/lqos_sys/src/bpf_iterator.rs +++ b/src/rust/lqos_sys/src/bpf_iterator.rs @@ -252,8 +252,7 @@ pub fn end_flows(flows: &mut [FlowbeeKey]) -> anyhow::Result<()> { let mut map = BpfMap::::from_path("/sys/fs/bpf/flowbee")?; for flow in flows { - let mut empty = FlowbeeData::default(); - map.insert_or_update(flow, &mut empty)?; + map.delete(flow)?; } Ok(()) diff --git a/src/rust/lqosd/src/throughput_tracker/tracking_data.rs b/src/rust/lqosd/src/throughput_tracker/tracking_data.rs index 28e53e00..dc2cd56e 100644 --- a/src/rust/lqosd/src/throughput_tracker/tracking_data.rs +++ b/src/rust/lqosd/src/throughput_tracker/tracking_data.rs @@ -182,6 +182,8 @@ impl ThroughputTracker { // Track the expired keys let mut expired_keys = Vec::new(); + + let mut lock = ALL_FLOWS.lock().unwrap(); // Track through all the flows iterate_flows(&mut |key, data| { @@ -193,7 +195,6 @@ impl ThroughputTracker { // This flow has expired but not been handled yet. Add it to the list to be cleaned. expired_keys.push(key.clone()); } else { - let mut lock = ALL_FLOWS.lock().unwrap(); // We have a valid flow, so it needs to be tracked if let Some(this_flow) = lock.get_mut(&key) { this_flow.0.last_seen = data.last_seen; @@ -237,7 +238,6 @@ impl ThroughputTracker { }); // End flow iterator if !expired_keys.is_empty() { - let mut lock = ALL_FLOWS.lock().unwrap(); for key in expired_keys.iter() { // Send it off to netperf for analysis if we are supporting doing so. if let Some(d) = lock.get(&key) { @@ -256,10 +256,7 @@ impl ThroughputTracker { } // Cleaning run - { - let mut lock = ALL_FLOWS.lock().unwrap(); - lock.retain(|_k,v| v.0.last_seen >= expire); - } + lock.retain(|_k,v| v.0.last_seen >= expire); } }