Skip to content

Commit

Permalink
bier/birt: Fix nexthop selection and interface update
Browse files Browse the repository at this point in the history
  • Loading branch information
nrybowski committed Feb 20, 2025
1 parent 7b93b30 commit f2a077b
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions holo-routing/src/rib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ impl Birt {
pub(crate) fn bier_nbr_add(&mut self, msg: BierNbrInstallMsg) {
let bfr_id = msg.bier_info.bfr_id;
msg.bier_info.bfr_bss.iter().for_each(|bsl| {
if let Some(nexthop) = msg.nexthops.first()
if let Some(nexthop) = msg.nexthops.last()
&& let Nexthop::Address { addr, ifindex, .. } = nexthop
{
// Insert or update the entry in the BIRT
self.entries
.entry((msg.bier_info.sd_id, bfr_id, *bsl))
.and_modify(|be| be.bfr_nbr = *addr)
.and_modify(|be| {
be.bfr_nbr = *addr;
be.ifindex = *ifindex;
})
.or_insert(BirtEntry {
bfr_prefix: msg.prefix.ip(),
bfr_nbr: (*addr),
Expand Down Expand Up @@ -136,14 +139,16 @@ impl Birt {
// Pattern matching is mandatory as Bitstring does not implement Copy, hence cannot use Entry interface
let key = (*sd_id, nbr.bfr_nbr, bfr_bs.si);
match bift.get_mut(&key) {
Some((e, v, _, _)) => match e.mut_or(bfr_bs) {
Ok(()) => {
v.push((*bfr_id, nbr.bfr_prefix));
Some((bitstring, bfrs, _ifindex, _ifname)) => {
match bitstring.mut_or(bfr_bs) {
Ok(()) => {
bfrs.push((*bfr_id, nbr.bfr_prefix));
}
Err(e) => {
e.log();
}
}
Err(e) => {
e.log();
}
},
}
None => {
let _ = bift.insert(
key,
Expand Down

0 comments on commit f2a077b

Please sign in to comment.