Skip to content

bgpd: Don't mark nexthop as changed if a set next-hop unchanged is applied - #21445

Merged
riw777 merged 2 commits into
FRRouting:masterfrom
opensourcerouting:fix/bgp_nexthop_unchanged_outbound
Apr 14, 2026
Merged

bgpd: Don't mark nexthop as changed if a set next-hop unchanged is applied#21445
riw777 merged 2 commits into
FRRouting:masterfrom
opensourcerouting:fix/bgp_nexthop_unchanged_outbound

Conversation

@ton31337

@ton31337 ton31337 commented Apr 1, 2026

Copy link
Copy Markdown
Member

No description provided.

@ton31337
ton31337 force-pushed the fix/bgp_nexthop_unchanged_outbound branch from f544e6f to 2cca7b9 Compare April 1, 2026 19:41
@github-actions github-actions Bot added size/S and removed size/XS labels Apr 1, 2026
@greptile-apps

greptile-apps Bot commented Apr 1, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a bug in bgpd where a set next-hop unchanged directive in an inbound route-map was incorrectly preventing the nexthop from being reset during outbound announcement processing.

  • Root cause: bgp_rmap_nhop_changed accepted two flag sets β€” out_rmap_flags (attr->rmap_change_flags, the outbound working copy) and in_rmap_flags (piattr->rmap_change_flags, the stored/original path attributes). It checked BATTR_RMAP_NEXTHOP_UNCHANGED in both. If an inbound route-map set this flag (i.e., a peer had set next-hop unchanged on its import policy), the flag persisted in piattr, causing bgp_rmap_nhop_changed to return true and suppressing the nexthop reset on all subsequent outbound announcements β€” even when no outbound policy requested it.
  • Fix: Drops the in_rmap_flags parameter entirely. The BATTR_RMAP_NEXTHOP_UNCHANGED bit is still checked in out_rmap_flags, so an outbound set next-hop unchanged route-map action continues to work correctly; only the erroneous bleed-through from inbound route-maps is eliminated.
  • Scope: The function has exactly one callsite (subgroup_announce_check in bgp_route.c), so the API change is clean and complete. No other logic paths are affected.

Confidence Score: 5/5

  • Safe to merge β€” the fix is minimal, targeted, and correctly removes an erroneous cross-contamination between inbound and outbound route-map flag state.
  • The change is a two-file, ~5-line fix with a single callsite. The BATTR_RMAP_NEXTHOP_UNCHANGED flag remains correctly checked for outbound route-maps; only the inbound bleed-through is removed. No new logic is introduced, and the function signature change is exhaustively propagated. No P0 or P1 issues found.
  • No files require special attention.

Important Files Changed

Filename Overview
bgpd/bgp_attr.h Removes the unused in_rmap_flags parameter from bgp_rmap_nhop_changed, retaining all checks on out_rmap_flags including the BATTR_RMAP_NEXTHOP_UNCHANGED flag for outbound route-maps.
bgpd/bgp_route.c Updates the single callsite of bgp_rmap_nhop_changed in subgroup_announce_check to drop the now-removed piattr->rmap_change_flags argument.

Sequence Diagram

sequenceDiagram
    participant Peer_In as Inbound Peer
    participant BGP as BGP (route store)
    participant RM_In as Inbound Route-Map
    participant RM_Out as Outbound Route-Map
    participant Peer_Out as Outbound Peer

    Peer_In->>BGP: Receive prefix
    BGP->>RM_In: Apply inbound route-map
    Note over RM_In: "set next-hop unchanged"<br/>sets BATTR_RMAP_NEXTHOP_UNCHANGED<br/>in piattr->rmap_change_flags

    BGP->>RM_Out: Apply outbound route-map (subgroup_announce_check)
    RM_Out->>RM_Out: bgp_rmap_nhop_changed(attr->rmap_change_flags)
    Note over RM_Out: OLD: also checked piattr->rmap_change_flags<br/>β†’ incorrectly saw BATTR_RMAP_NEXTHOP_UNCHANGED<br/>β†’ skipped nexthop reset<br/><br/>NEW: only checks attr->rmap_change_flags<br/>β†’ inbound flag has no effect<br/>β†’ nexthop reset proceeds normally
    RM_Out->>Peer_Out: Announce with correct nexthop
Loading

Reviews (1): Last reviewed commit: "bgpd: Don't mark nexthop as changed if a..." | Re-trigger Greptile

@enkechen-panw

Copy link
Copy Markdown
Contributor

LGTM.

@riw777 riw777 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good ... are there any topo test changes for this? I wouldn't think so, but thought I'd ask before pushing.

mwinter-osr and others added 2 commits April 7, 2026 15:27
…plied

An inbound policy preserving the received nexthop into the RIB shouldn't
prevent the outbound decision to set next-hop-self or reset the nexthop
for EBGP. Those are independent decisions. If an operator wants the nexthop
preserved on outbound, they configure neighbor X next-hop-unchanged
or an outbound route-map with set ip next-hop unchanged (which would
set the flag in out_rmap_flags).

Fixes: a725bf4 ("bgpd:Fixing a conflict issue between rmap_in_change_flag and rmap_out_change_flag.")

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
… outgoing

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
@ton31337
ton31337 force-pushed the fix/bgp_nexthop_unchanged_outbound branch from 2cca7b9 to 8de3f04 Compare April 7, 2026 13:13
@frrbot frrbot Bot added the tests Topotests, make check, etc label Apr 7, 2026
@github-actions github-actions Bot added size/L and removed size/S labels Apr 7, 2026
@ton31337

ton31337 commented Apr 7, 2026

Copy link
Copy Markdown
Member Author

looks good ... are there any topo test changes for this? I wouldn't think so, but thought I'd ask before pushing.

@riw777, added.

@ton31337

ton31337 commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

@Mergifyio backport stable/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2

@mergify

mergify Bot commented Apr 8, 2026

Copy link
Copy Markdown

backport stable/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2

βœ… Backports have been created

Details

donaldsharp added a commit that referenced this pull request Apr 14, 2026
bgpd: Don't mark nexthop as changed if a set next-hop unchanged is applied (backport #21445)
donaldsharp added a commit that referenced this pull request Apr 15, 2026
bgpd: Don't mark nexthop as changed if a set next-hop unchanged is applied (backport #21445)
donaldsharp added a commit that referenced this pull request Apr 16, 2026
bgpd: Don't mark nexthop as changed if a set next-hop unchanged is applied (backport #21445)
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.

4 participants