Skip to content

Commit

Permalink
Improve the flow cleanup logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
thebracket committed Mar 12, 2024
1 parent 79247e0 commit 213a274
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/rust/lqos_sys/src/bpf/common/flows.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,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);
Expand Down
10 changes: 8 additions & 2 deletions src/rust/lqosd/src/throughput_tracker/tracking_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ impl ThroughputTracker {
iterate_flows(&mut |key, data| {

if data.end_status == 2 {
// The flow has been handled already and should be ignored
// The flow has been handled already and should be ignored.
// This shouldn't happen in our deletion logic. If it DID happen,
// we'll take this opportunity to clean it up.
expired_keys.push(key.clone());
ALL_FLOWS.lock().unwrap().remove(&key);
return;
}

Expand Down Expand Up @@ -221,7 +225,7 @@ impl ThroughputTracker {
for i in 1..60 {
tracker.recent_rtt_data[i] = tracker.recent_rtt_data[i - 1];
}
tracker.recent_rtt_data[0] = (data.last_rtt[0] / 10000) as u32;
tracker.recent_rtt_data[0] = (data.last_rtt[1] / 10000) as u32;
tracker.last_fresh_rtt_data_cycle = self_cycle;
if let Some(parents) = &tracker.network_json_parents {
let net_json = NETWORK_JSON.write().unwrap();
Expand All @@ -246,6 +250,8 @@ impl ThroughputTracker {
if let Some(d) = lock.get(&key) {
let _ = sender.send((key.clone(), (d.0.clone(), d.1.clone())));
}
// Remove the flow from circulation
lock.remove(&key);
}

lock.remove(&key);
Expand Down

0 comments on commit 213a274

Please sign in to comment.