Skip to content

Commit

Permalink
bgp: remove routing table entries that no longer hold any data
Browse files Browse the repository at this point in the history
Signed-off-by: Renato Westphal <[email protected]>
  • Loading branch information
rwestphal committed Apr 25, 2024
1 parent 05911e0 commit 02992ee
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion holo-bgp/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ where
let queued_prefixes = std::mem::take(&mut table.queued_prefixes);
let mut reach = vec![];
let mut unreach = vec![];
for prefix in queued_prefixes {
for prefix in queued_prefixes.iter().copied() {
let Some(dest) = table.prefixes.get_mut(&prefix) else {
continue;
};
Expand Down Expand Up @@ -794,6 +794,25 @@ where
}
}

// Remove routing table entries that no longer hold any data.
for prefix in queued_prefixes {
if let prefix_trie::map::Entry::Occupied(mut entry) =
table.prefixes.entry(prefix)
{
let dest = entry.get();
if dest.local.is_none()
&& dest.adj_rib.values().all(|adj_rib| {
adj_rib.in_pre.is_none()
&& adj_rib.in_post.is_none()
&& adj_rib.out_pre.is_none()
&& adj_rib.out_post.is_none()
})
{
entry.remove();
}
}
}

Ok(())
}

Expand Down

0 comments on commit 02992ee

Please sign in to comment.