Skip to content

pimd: clean stale upstream NHT tracking on RP delete (backport #22505)#22605

Merged
donaldsharp merged 2 commits into
stable/10.7from
mergify/bp/stable/10.7/pr-22505
Jul 8, 2026
Merged

pimd: clean stale upstream NHT tracking on RP delete (backport #22505)#22605
donaldsharp merged 2 commits into
stable/10.7from
mergify/bp/stable/10.7/pr-22505

Conversation

@mergify

@mergify mergify Bot commented Jul 8, 2026

Copy link
Copy Markdown

Issue:
Faced a crash in below sequence.
pim_upstream_mroute_iif_update+0x16 -> pimd/pim_mroute.c:1256
pimd(+0x78a94) -> pimd/pim_nht.c
pim_nexthop_update+0x587 -> pimd/pim_nht.c

Rootcause:
pim_rpf_update() tracks upstreams in pnc->upstream_hash keyed by up->upstream_addr.

Some RP delete/BSM cleanup paths clear RPF state and then mutate up->upstream_addr to PIMADDR_ANY without first removing the upstream from the old RP nexthop cache bucket. If the upstream was previously tracked under the old RP address, a later Zebra NHT update for that address can still walk the stale upstream entry.

Fix:
1)Guard channel_oil at appropriate places.
2)Wrote an api for cleanup.
RP delete and BSM cleanup now remove the upstream from the old NHT bucket before up->upstream_addr is changed to PIMADDR_ANY. This prevents the old pnc->upstream_hash from retaining a stale upstream pointer.


This is an automatic backport of pull request #22505 done by Mergify.

Issue:
Faced a crash in below sequence.
pim_upstream_mroute_iif_update+0x16 -> pimd/pim_mroute.c:1256
pimd(+0x78a94)                     -> pimd/pim_nht.c
pim_nexthop_update+0x587           -> pimd/pim_nht.c

Rootcause:
pim_rpf_update() tracks upstreams in pnc->upstream_hash keyed by
up->upstream_addr.

Some RP delete/BSM cleanup paths clear RPF state and then mutate
up->upstream_addr to PIMADDR_ANY without first removing the upstream from
the old RP nexthop cache bucket. If the upstream was previously tracked
under the old RP address, a later Zebra NHT update for that address can
still walk the stale upstream entry.

Fix:
Add pim_nht_delete_tracked_upstream() and call it from RP delete and
BSM cleanup paths to remove the upstream from the old NHT bucket before
up->upstream_addr is changed to PIMADDR_ANY. This prevents the old
pnc->upstream_hash from retaining a stale upstream pointer.

Signed-off-by: harini <hnattamaisub@nvidia.com>
(cherry picked from commit 04f04ca)
pim_upstream_mroute_iif_update() dereferences c_oil via
oil_incoming_vif() and pim_upstream_get_mroute_iif() with no NULL
check. Some upstream cleanup paths can reach these callers after
channel_oil has been freed, producing a NULL dereference.

Add a defensive NULL check at the top of
pim_upstream_mroute_iif_update(), and skip the call in
pim_upstream_rpf_clear() and the PIM_RPF_CHANGED branch of
pim_update_upstream_nh_helper() when up->channel_oil is NULL.

Signed-off-by: harini <hnattamaisub@nvidia.com>
(cherry picked from commit 18aba5c)
@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown

Target branch is not in the allowed branches list.

@frrbot frrbot Bot added the pim label Jul 8, 2026
@donaldsharp donaldsharp merged commit bfeb146 into stable/10.7 Jul 8, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants