pimd: BSR/C-RP fixes with expanded topotest coverage - #22117
Conversation
The pim_sock_read refactor incremented pim_ifstat_hello_recvfail on successful reads instead of failures. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
Use sizeof(pim_encoded_group) instead of the IPv4-only struct size so truncated C-RP advertisements are rejected correctly in pim6d builds. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
Use %pPA for the JSON address field so show ipv6 pim bsr candidate-bsr json reports IPv6 addresses correctly. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
Abort BSM proc init when pim_socket_raw fails instead of registering a read event on an invalid file descriptor. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
Call pim_crp_db_clear from pim_bsm_proc_free so elected-BSR RP state is released when a VRF is deleted, not only on daemon shutdown. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
Restore pim_ifstat_bsm_rx and related counters in pim_crp_process so the unicast C-RP path is visible to monitoring like the multicast BSM path. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
Call pim_cand_bsr_apply on priority modify instead of re-running full address selection via candidate_bsr_addrsel. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
Add IPv6 candidate-BSR JSON verification and a priority-only C-BSR modify test for the recent BSR fixes. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
Greptile SummaryThis PR fixes several BSR/C-RP bugs in
Confidence Score: 4/5Safe to merge; the changes are targeted bug fixes with no new complexity introduced, though the hello receive-failure counter inversion has been silently misbehaving in all existing deployments. The pim_ifstat_hello_recvfail counter in pim_pim.c was incremented on every successful packet read and never on actual errors, meaning operator dashboards that rely on this counter have been showing incorrect data. While it does not affect routing correctness, it represents a real present defect in the changed code path that is now fixed. pimd/pim_pim.c contains the most impactful single-line fix; pimd/pim_bsm.c deserves a second look to confirm the partial-init / early-return path is fully safe under all VRF teardown orderings. Important Files Changed
Sequence DiagramsequenceDiagram
participant VRF as VRF init/teardown
participant INIT as pim_bsm_proc_init
participant SOCK as pim_socket_raw
participant FREE as pim_bsm_proc_free
participant CRPDB as pim_crp_db_clear
VRF->>INIT: pim_bsm_proc_init(pim)
INIT->>INIT: "memset scope (unicast_sock=0)"
INIT->>SOCK: pim_socket_raw(IPPROTO_PIM)
alt socket failure
SOCK-->>INIT: "fd < 0"
INIT->>INIT: zlog_warn + return (NEW)
else socket success
SOCK-->>INIT: valid fd
INIT->>INIT: set_nonblocking, setsockopt, event_add_read
end
VRF->>FREE: pim_bsm_proc_free(pim)
FREE->>CRPDB: pim_crp_db_clear(scope) (MOVED HERE)
FREE->>FREE: event_cancel(unicast_read)
alt "unicast_sock >= 0 (NEW guard)"
FREE->>FREE: close(unicast_sock)
end
FREE->>FREE: "scope->unicast_sock = -1 (NEW)"
FREE->>FREE: pim_bs_timer_stop, pim_bsm_frags_free, route_table_finish
note over SOCK,FREE: pim_pim.c: pim_sock_read_helper != 0 => recvfail++ (FIXED)
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
pimd/pim_pim.c:531-532
**Inverted failure-counter condition (pre-existing bug fixed here)**
The original `== 0` check incremented `pim_ifstat_hello_recvfail` whenever `pim_sock_read_helper` returned *success* (0), so every successfully received PIM Hello was counted as a receive failure, and every actual socket error was silently ignored in the counter. The new `!= 0` check is correct: it increments the stat only when the helper returns a non-zero error value.
Reviews (1): Last reviewed commit: "tests: expand PIM candidate BSR/RP topot..." | Re-trigger Greptile |
| if (pim_sock_read_helper(fd, pim_ifp->pim, true) != 0) | ||
| ++pim_ifp->pim_ifstat_hello_recvfail; |
There was a problem hiding this comment.
Inverted failure-counter condition (pre-existing bug fixed here)
The original == 0 check incremented pim_ifstat_hello_recvfail whenever pim_sock_read_helper returned success (0), so every successfully received PIM Hello was counted as a receive failure, and every actual socket error was silently ignored in the counter. The new != 0 check is correct: it increments the stat only when the helper returns a non-zero error value.
Prompt To Fix With AI
This is a comment left during a code review.
Path: pimd/pim_pim.c
Line: 531-532
Comment:
**Inverted failure-counter condition (pre-existing bug fixed here)**
The original `== 0` check incremented `pim_ifstat_hello_recvfail` whenever `pim_sock_read_helper` returned *success* (0), so every successfully received PIM Hello was counted as a receive failure, and every actual socket error was silently ignored in the counter. The new `!= 0` check is correct: it increments the stat only when the helper returns a non-zero error value.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
@greptile, I fixed the bug, what else you want here?
There was a problem hiding this comment.
Nothing else needed β my comment was just explaining the fix, not requesting changes. The != 0 correction is right and the note was meant as confirmation. All good here!
There was a problem hiding this comment.
@greptile, it is s bit confusing when you mark it as p1 and end it with "Prompt To Fix With AI", like you do with real bugs you flag.
There was a problem hiding this comment.
Fair point β sorry for the confusion. Since this was already fixed in the PR, I should have framed it as a confirmation note rather than a flagged issue with a severity label. Explanatory comments on already-corrected code shouldn't carry a P1 label or an AI fix prompt.
|
Nothing else to do on this PR. Nothing to add to greptile, code formatting is ignored to keep the changed lines consistent with surrounding text. |
|
@Mergifyio backport stable/10.6 stable/10.5 |
β Backports have been createdDetails
|
pimd: BSR/C-RP fixes with expanded topotest coverage (backport #22117)
pimd: BSR/C-RP fixes with expanded topotest coverage (backport #22117)
see individual commit msgs.