Skip to content

Commit

Permalink
isis: set ATT bit in L1 LSPs when connected to L2 backbone
Browse files Browse the repository at this point in the history
This is necessary for L1 routers within the same area to compute
default routes to reach inter-area destinations.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
  • Loading branch information
rwestphal committed Feb 16, 2025
1 parent 14ebc3e commit 63f48ef
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
15 changes: 14 additions & 1 deletion holo-isis/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use holo_utils::{Receiver, Sender, UnboundedReceiver, UnboundedSender};
use ipnetwork::IpNetwork;
use tokio::sync::mpsc;

use crate::adjacency::Adjacency;
use crate::adjacency::{Adjacency, AdjacencyState};
use crate::collections::{Arena, Interfaces, Lsdb, LspEntryId};
use crate::debug::{
Debug, InstanceInactiveReason, InterfaceInactiveReason, LspPurgeReason,
Expand Down Expand Up @@ -496,6 +496,19 @@ impl MessageReceiver<ProtocolInputMsg> for ProtocolInputChannelsRx {
// ===== impl InstanceUpView =====

impl InstanceUpView<'_> {
// Checks if the instance is attached to the Level 2 backbone.
pub(crate) fn is_l2_attached_to_backbone(
&self,
interfaces: &Interfaces,
adjacencies: &Arena<Adjacency>,
) -> bool {
interfaces
.iter()
.flat_map(|iface| iface.adjacencies(adjacencies))
.filter(|adj| adj.state == AdjacencyState::Up)
.any(|adj| adj.level_usage.intersects(LevelNumber::L2))
}

pub(crate) fn schedule_lsp_origination(
&mut self,
level_type: impl Into<LevelType>,
Expand Down
15 changes: 13 additions & 2 deletions holo-isis/src/lsdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::packet::tlv::{
ExtIpv4Reach, ExtIsReach, Ipv4Reach, Ipv6Reach, IsReach, MAX_NARROW_METRIC,
Nlpid,
};
use crate::packet::{LanId, LevelNumber, LspId};
use crate::packet::{LanId, LevelNumber, LevelType, LspId};
use crate::spf::SpfType;
use crate::tasks::messages::input::LspPurgeMsg;
use crate::{spf, tasks};
Expand Down Expand Up @@ -149,6 +149,8 @@ fn lsp_build(

fn lsp_build_flags(
instance: &mut InstanceUpView<'_>,
arenas: &InstanceArenas,
level: LevelNumber,
lsp_id: LspId,
) -> LspFlags {
let mut lsp_flags = LspFlags::default();
Expand All @@ -158,6 +160,15 @@ fn lsp_build_flags(
if instance.config.level_type.intersects(LevelNumber::L2) {
lsp_flags.insert(LspFlags::IS_TYPE2);
}
if instance.config.level_type == LevelType::All
&& level == LevelNumber::L1
&& lsp_id.pseudonode == 0
&& lsp_id.fragment == 0
&& instance
.is_l2_attached_to_backbone(&arenas.interfaces, &arenas.adjacencies)
{
lsp_flags.insert(LspFlags::ATT);
}
if instance.config.overload_status
&& lsp_id.pseudonode == 0
&& lsp_id.fragment == 0
Expand Down Expand Up @@ -410,7 +421,7 @@ fn lsp_build_fragments(
.get_by_lspid(&arenas.lsp_entries, &lsp_id)
.map(|(_, lse)| lse.data.seqno + 1)
.unwrap_or(LSP_INIT_SEQNO);
let lsp_flags = lsp_build_flags(instance, lsp_id);
let lsp_flags = lsp_build_flags(instance, arenas, level, lsp_id);
let fragment = Lsp::new(
level,
instance.config.lsp_lifetime,
Expand Down

0 comments on commit 63f48ef

Please sign in to comment.