pimd,ospfd: Passing local source address as part of BFD session creation - #20739
Conversation
Greptile OverviewGreptile SummaryChanged OSPF and PIM to pass explicit local source addresses when creating BFD sessions (similar to BGP), instead of passing NULL which causes BFD to auto-select the source.
The OSPF implementation correctly handles the case where the interface address might not be set. The PIM implementation assumes Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant OSPF as OSPF Neighbor
participant PIM as PIM Neighbor
participant BFD as BFD Session
participant BFDD as BFD Daemon
Note over OSPF,BFDD: OSPF BFD Session Creation
OSPF->>BFD: ospf_neighbor_bfd_apply()
OSPF->>BFD: bfd_sess_new()
OSPF->>BFD: bfd_sess_set_ipv4_addrs(oi->address ? &oi->address->u.prefix4 : NULL, &nbr->src)
Note right of OSPF: Now passes local source<br/>with null check
OSPF->>BFD: bfd_sess_set_interface()
OSPF->>BFD: bfd_sess_set_vrf()
OSPF->>BFD: bfd_sess_set_timers()
OSPF->>BFD: bfd_sess_install()
BFD->>BFDD: Register session with local & remote addresses
Note over PIM,BFDD: PIM BFD Session Creation
PIM->>BFD: pim_bfd_info_nbr_create()
PIM->>BFD: bfd_sess_new()
PIM->>BFD: bfd_sess_set_timers()
PIM->>BFD: bfd_sess_set_ipv4_addrs(&pim_ifp->primary_address, &neigh->source_addr)
Note right of PIM: Now passes primary_address<br/>as local source
PIM->>BFD: bfd_sess_set_interface()
PIM->>BFD: bfd_sess_set_vrf()
PIM->>BFD: bfd_sess_install()
BFD->>BFDD: Register session with local & remote addresses
|
| pim_ifp->bfd_config.min_rx, pim_ifp->bfd_config.min_tx); | ||
| /* Pass local interface primary address as source (like BGP does with su_local) */ | ||
| #if PIM_IPV == 4 | ||
| bfd_sess_set_ipv4_addrs(neigh->bfd_session, NULL, &neigh->source_addr); | ||
| bfd_sess_set_ipv4_addrs(neigh->bfd_session, | ||
| &pim_ifp->primary_address, /* local source */ | ||
| &neigh->source_addr); /* remote dest */ | ||
| #else | ||
| bfd_sess_set_ipv6_addrs(neigh->bfd_session, NULL, &neigh->source_addr); | ||
| bfd_sess_set_ipv6_addrs(neigh->bfd_session, | ||
| &pim_ifp->primary_address, /* local source */ | ||
| &neigh->source_addr); /* remote dest */ | ||
| #endif |
There was a problem hiding this comment.
Source may be 0/unspecified
This change always passes &pim_ifp->primary_address as the BFD local source (pimd/pim_bfd.c:85-91). primary_address is allowed to be PIMADDR_ANY/unspecified during interface bring-up or address loss (pimd/pim_iface.c:316-334), and the code here doesn't guard against that. That can result in creating a session with an invalid explicit source (where previously NULL would allow BFD to auto-pick a source), or hit assertions/installation failures downstream depending on bfdd behavior.
Prompt To Fix With AI
This is a comment left during a code review.
Path: pimd/pim_bfd.c
Line: 82:92
Comment:
**Source may be 0/unspecified**
This change always passes `&pim_ifp->primary_address` as the BFD local source (`pimd/pim_bfd.c:85-91`). `primary_address` is allowed to be `PIMADDR_ANY`/unspecified during interface bring-up or address loss (`pimd/pim_iface.c:316-334`), and the code here doesn't guard against that. That can result in creating a session with an invalid explicit source (where previously `NULL` would allow BFD to auto-pick a source), or hit assertions/installation failures downstream depending on bfdd behavior.
How can I resolve this? If you propose a fix, please make it concise.
Additional Comments (1)
If address-change hooks already call Prompt To Fix With AIThis is a comment left during a code review.
Path: pimd/pim_bfd.c
Line: 77:97
Comment:
**BFD session not updated**
`pim_bfd_info_nbr_create()` updates timers, addrs, interface, vrf, and profile, then calls `bfd_sess_install()` unconditionally (`pimd/pim_bfd.c:80-97`). If the interface primary address changes, `bfd_sess_set_ipv[4|6]_addrs()` will internally uninstall the session (per `lib/bfd.h:99-116` and `lib/bfd.c:581-613`), so reinstalling is correct β but this function is only called from `pim_bfd_reg_dereg_all_nbr()` which appears to run on enable/disable, not on address-change events. As a result, PIM's BFD sessions may keep using the old local source until BFD is toggled or neighbors are re-registered.
If address-change hooks already call `pim_bfd_info_nbr_create()` elsewhere, please point to that callsite; otherwise this needs wiring so sessions update when `pim_ifp->primary_address` changes.
How can I resolve this? If you propose a fix, please make it concise. |
1f87bbe to
2f220de
Compare
β¦stered by pim Issue: While using BFD distributed mode to offload the sessions PIM is not sending out the local address. Fix: Fill the source address in bfd structure passed for neighbor creation Ticket: #4769364 Signed-off-by: Utkarsh Srivastava <usrivastava@nvidia.com>
2f220de to
2b4604b
Compare
β¦ed by OSPF. Issue: While using BFD distributed mode to offload the sessions OSPF is not sending out the local address. Fix: Fill the source address in bfd structure passed for neighbor creation Ticket: #4769347 Signed-off-by: Utkarsh Srivastava <usrivastava@nvidia.com>
2b4604b to
0df9faa
Compare
|
@greptile review |
1 similar comment
|
@greptile review |
riw777
left a comment
There was a problem hiding this comment.
code looks okay to me ... the AI comments might need to be addressed, though (?)
|
@greptile review |
I don't see any changes since the last review, so this request to review was skipped. |
|
I don't see any changes since the last review either. If you've made updates to address previous comments, please push the new commits to the PR branch. Once there are new changes, I'll be able to provide a fresh review. If you believe there are changes that aren't being detected, you might want to check:
|
|
@Mergifyio backport dev/10.6 |
β Backports have been createdDetails
|
pimd,ospfd: Passing local source address as part of BFD session creation (backport #20739)
While registering the sessions with BFD, pimd and ospfd are passing 0.0.0.0 as local source address to BFD.
With this fix, correct local source address will be passed for BFD session creation like BGP