Only mark a subnet as queried if we have no routes for it

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
Lee Smet committed 2025-05-08 12:07:33 +02:00
1 parent b954cda4b2
commit f302d5c645
1 file changed
+38 -1
+38 -1
View File
@@ -336,7 +336,7 @@ impl RoutingTable {
}
let mut write_handle = self.writer.lock().expect("Can lock writer");
write_handle.append(RoutingTableOplogEntry::Upsert(
write_handle.append(RoutingTableOplogEntry::Queried(
subnet,
Arc::new(SubnetEntry::Queried { query_timeout }),
));
@@ -534,6 +534,8 @@ impl Drop for WriteGuard<'_> {
enum RoutingTableOplogEntry {
/// Insert or Update the value for the given subnet.
Upsert(Subnet, Arc<SubnetEntry>),
/// Mark a subnet as queried.
Queried(Subnet, Arc<SubnetEntry>),
/// Delete the entry for the given subnet.
Delete(Subnet),
/// The route request for a subnet expired, if it is still in query state mark it as not
@@ -563,6 +565,24 @@ impl left_right::Absorb<RoutingTableOplogEntry> for RoutingTableInner {
Arc::clone(list),
);
}
RoutingTableOplogEntry::Queried(subnet, se) => {
// Mark a query only if we don't have a valid entry
let entry = self
.table
.exact_match(expect_ipv6(subnet.address()), subnet.prefix_len().into())
.map(Arc::deref);
// If we have no route, transition to query, if we have a route or existing query,
// do nothing
if matches!(entry, None | Some(SubnetEntry::NoRoute { .. })) {
self.table.insert(
expect_ipv6(subnet.address()),
subnet.prefix_len().into(),
Arc::clone(se),
);
}
}
RoutingTableOplogEntry::Delete(subnet) => {
self.table
.remove(expect_ipv6(subnet.address()), subnet.prefix_len().into());
@@ -610,6 +630,23 @@ impl left_right::Absorb<RoutingTableOplogEntry> for RoutingTableInner {
list,
);
}
RoutingTableOplogEntry::Queried(subnet, se) => {
// Mark a query only if we don't have a valid entry
let entry = self
.table
.exact_match(expect_ipv6(subnet.address()), subnet.prefix_len().into())
.map(Arc::deref);
// If we have no route, transition to query, if we have a route or existing query,
// do nothing
if matches!(entry, None | Some(SubnetEntry::NoRoute { .. })) {
self.table.insert(
expect_ipv6(subnet.address()),
subnet.prefix_len().into(),
se,
);
}
}
RoutingTableOplogEntry::Delete(subnet) => {
self.table
.remove(expect_ipv6(subnet.address()), subnet.prefix_len().into());