Skip to content

Commit

Permalink
isis: originate hello and link-state PDUs with IPv6 TLVs
Browse files Browse the repository at this point in the history
Signed-off-by: Renato Westphal <[email protected]>
  • Loading branch information
rwestphal committed Oct 22, 2024
1 parent 9a2f38e commit db22407
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
12 changes: 11 additions & 1 deletion holo-isis/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ impl Interface {
// Set IP information.
let mut protocols_supported = vec![];
let mut ipv4_addrs = vec![];
let mut ipv6_addrs = vec![];
if self
.config
.is_af_enabled(AddressFamily::Ipv4, instance.config)
Expand All @@ -454,6 +455,15 @@ impl Interface {
self.system.ipv4_addr_list.iter().map(|addr| addr.ip()),
);
}
if self
.config
.is_af_enabled(AddressFamily::Ipv6, instance.config)
{
protocols_supported.push(Nlpid::Ipv6 as u8);
ipv6_addrs.extend(
self.system.ipv6_addr_list.iter().map(|addr| addr.ip()),
);
}

Pdu::Hello(Hello::new(
level,
Expand All @@ -466,7 +476,7 @@ impl Interface {
area_addrs,
neighbors,
ipv4_addrs,
[],
ipv6_addrs,
),
))
}
Expand Down
2 changes: 1 addition & 1 deletion holo-isis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
feature = "testing",
allow(dead_code, unused_variables, unused_imports)
)]
#![feature(let_chains)]
#![feature(ip, let_chains)]

pub mod adjacency;
pub mod collections;
Expand Down
34 changes: 30 additions & 4 deletions holo-isis/src/lsdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::time::Instant;

use bitflags::bitflags;
use derive_new::new;
use holo_utils::ip::{AddressFamily, Ipv4NetworkExt};
use holo_utils::ip::{AddressFamily, Ipv4NetworkExt, Ipv6NetworkExt};
use holo_utils::task::TimeoutTask;
use holo_utils::UnboundedSender;

Expand All @@ -25,7 +25,9 @@ use crate::interface::{Interface, InterfaceType};
use crate::northbound::notification;
use crate::packet::consts::LspFlags;
use crate::packet::pdu::{Lsp, LspTlvs};
use crate::packet::tlv::{ExtIpv4Reach, ExtIsReach, Ipv4Reach, IsReach, Nlpid};
use crate::packet::tlv::{
ExtIpv4Reach, ExtIsReach, Ipv4Reach, Ipv6Reach, IsReach, Nlpid,
};
use crate::packet::{LanId, LevelNumber, LspId};
use crate::tasks::messages::input::LspPurgeMsg;
use crate::{spf, tasks};
Expand Down Expand Up @@ -171,11 +173,16 @@ fn lsp_build_tlvs(
let mut ipv4_addrs = vec![];
let mut ipv4_internal_reach = vec![];
let mut ext_ipv4_reach = vec![];
let mut ipv6_addrs = vec![];
let mut ipv6_reach = vec![];

// Add supported protocols.
if instance.config.is_af_enabled(AddressFamily::Ipv4) {
protocols_supported.push(Nlpid::Ipv4 as u8);
}
if instance.config.is_af_enabled(AddressFamily::Ipv6) {
protocols_supported.push(Nlpid::Ipv6 as u8);
}

// Iterate over all active interfaces.
for iface in arenas.interfaces.iter().filter(|iface| iface.state.active) {
Expand Down Expand Up @@ -247,6 +254,25 @@ fn lsp_build_tlvs(
}
}
}

// Add IPv6 information.
if instance.config.is_af_enabled(AddressFamily::Ipv6) {
for addr in iface
.system
.ipv6_addr_list
.iter()
.filter(|addr| !addr.ip().is_unicast_link_local())
{
ipv6_addrs.push(addr.ip());
ipv6_reach.push(Ipv6Reach {
metric,
up_down: false,
external: false,
prefix: addr.apply_mask(),
sub_tlvs: Default::default(),
});
}
}
}
LspTlvs::new(
protocols_supported,
Expand All @@ -257,8 +283,8 @@ fn lsp_build_tlvs(
ipv4_internal_reach,
[],
ext_ipv4_reach,
[],
[],
ipv6_addrs,
ipv6_reach,
)
}

Expand Down

0 comments on commit db22407

Please sign in to comment.