Skip to content

bgpd: Print neighbor link type correctly according to local-as#21486

Open
ton31337 wants to merge 4 commits intoFRRouting:masterfrom
opensourcerouting:fix/bgp_print_link_type_correctly_according_to_remote_as_auto
Open

bgpd: Print neighbor link type correctly according to local-as#21486
ton31337 wants to merge 4 commits intoFRRouting:masterfrom
opensourcerouting:fix/bgp_print_link_type_correctly_according_to_remote_as_auto

Conversation

@ton31337
Copy link
Copy Markdown
Member

@ton31337 ton31337 commented Apr 9, 2026

Closes #21474

@frrbot frrbot bot added bgp bugfix tests Topotests, make check, etc labels Apr 9, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 9, 2026

Greptile Summary

This PR fixes bgpd/bgp_vty.c to correctly classify a neighbor as an internal link when local-as <AS> no-prepend replace-as is configured with the same AS as the remote peer, adding the missing p->change_local_as && p->as == p->change_local_as check. It also aligns the external-link detection to use CHECK_FLAG(p->as_type, AS_EXTERNAL) instead of a raw equality comparison, consistent with how AS_INTERNAL is already checked. A new router r5 and associated topotest are added to cover this scenario end-to-end.

Confidence Score: 5/5

Safe to merge — targeted display-logic fix with a new topotest covering the reported scenario.

All changes are narrowly scoped to the neighbor link-type classification in bgp_show_peer. The new change_local_as guard is correctly gated on a non-zero value before the equality check, the CHECK_FLAG alignment for AS_EXTERNAL is a consistency improvement with no behaviour change in practice (enum values are powers-of-two and are not combined), and the topotest directly validates both the previously-broken and the already-correct cases. No P0 or P1 issues found.

No files require special attention.

Vulnerabilities

No security concerns identified. The change only affects display/classification logic in show bgp neighbors output and does not touch authentication, data handling, or network reachability decisions.

Important Files Changed

Filename Overview
bgpd/bgp_vty.c Adds change_local_as equality check to correctly classify iBGP peers when local-as masking is active; also fixes as_type == AS_EXTERNAL to CHECK_FLAG for consistency with the AS_INTERNAL path.
tests/topotests/bgp_remote_as_auto/test_bgp_remote_as_auto.py Adds _bgp_neighbors test verifying correct nbrExternalLink/nbrInternalLink classification, and extends _bgp_converge to include r5 in the established-peers check.
tests/topotests/bgp_remote_as_auto/r1/frr.conf Adds neighbor 192.168.1.5 with local-as 65005 no-prepend replace-as to simulate the iBGP masking scenario under test.
tests/topotests/bgp_remote_as_auto/r5/frr.conf New router configuration for r5 (AS 65005) with remote-as auto, forming the iBGP-masking peer for r1 in the new test case.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[bgp_show_peer: determine link type] --> B{p->as == p->local_as?}
    B -- Yes --> E[Internal / Confed-Internal Link]
    B -- No --> C{p->change_local_as != 0\nAND p->as == p->change_local_as?}
    C -- Yes --> E
    C -- No --> D{CHECK_FLAG as_type AS_INTERNAL?}
    D -- Yes --> E
    D -- No --> F{p->as != 0\nOR CHECK_FLAG as_type AS_EXTERNAL?}
    F -- Yes --> G[External / Confed-External Link]
    F -- No --> H[Unspecified Link]
Loading

Reviews (1): Last reviewed commit: "tests: Check if the correct link type is..." | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown

This pull request has conflicts, please resolve those before we can evaluate the pull request.

… auto

Fixes: 0dfe256 ("bgpd: Implement `neighbor X remote-as auto`")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Before this patch we compared remote-as vs. local-as (which is taken from BGP
instance). But if we use `local-as X`, we should compare it too.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
@ton31337 ton31337 force-pushed the fix/bgp_print_link_type_correctly_according_to_remote_as_auto branch from ec52dc7 to c4fe52d Compare April 14, 2026 13:48
Let's say we have something like:

router bgp 65001
 neighbor 192.168.1.5 remote-as internal
 neighbor 192.168.1.5 local-as 65005 no-prepend replace-as

This way when the BGP OPEN is received it's treating 192.168.1.5 as external,
because local-as is not evaluated, and 65001 is taken instead.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
@ton31337 ton31337 force-pushed the fix/bgp_print_link_type_correctly_according_to_remote_as_auto branch from c4fe52d to 4561cb2 Compare April 14, 2026 13:49
Copy link
Copy Markdown
Member

@riw777 riw777 left a comment

Choose a reason for hiding this comment

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

looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

local-as and the same remote-as not iBGP

2 participants