Improve the flow cleanup logic.

This commit is contained in:
Herbert Wolverson committed 2024-03-12 08:21:33 -05:00
1 parent 79247e07f0
commit 213a27498e
2 files changed
+9 -3

No files matched your search

+1 -1
View File
@@ -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);
@@ -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;
}
@@ -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();
@@ -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);