mirror of
https://github.com/threefoldtech/mycelium.git
synced 2026-10-23 06:01:16 +00:00
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:
1 file changed
+38
-1
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user