Skip to content

bgpd: honor 'no activate' for dynamic neighbors in peer-group - #21658

Merged
ton31337 merged 1 commit into
FRRouting:masterfrom
enissim:dynamicNeighbors
Apr 19, 2026
Merged

bgpd: honor 'no activate' for dynamic neighbors in peer-group#21658
ton31337 merged 1 commit into
FRRouting:masterfrom
enissim:dynamicNeighbors

Conversation

@enissim

@enissim enissim commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

When a dynamic peer connects via 'bgp listen range', peer_create() activates IPv4 unicast by default. peer_create_bind_dynamic_neighbor() then applies the group's AF config but only activates AFIs the group has enabled -- it never deactivates AFIs the group has disabled. This causes 'no neighbor activate' under an address-family to be ignored for dynamic peers.
Add peer_deactivate() for AFIs the group has deactivated, matching the fix in peer_group_bind() from commit 5f00745 ("bgpd: peer-group members 'activate' when they shouldn't").

@greptile-apps

greptile-apps Bot commented Apr 19, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a bug where dynamic peers (created via bgp listen range) would ignore no neighbor <group> activate under an address-family. peer_create() always enables IPv4 unicast by default; peer_create_bind_dynamic_neighbor() only activated group-enabled AFIs but never deactivated the defaults. The fix mirrors the existing pattern in peer_group_bind() by calling peer_deactivate() for each AFI/SAFI the group has not enabled, ensuring the peer's active address families exactly match the group's configuration.

Confidence Score: 5/5

This PR is safe to merge β€” the change is minimal, correct, and directly mirrors an existing proven fix in peer_group_bind().

The fix is a 4-line addition that replicates the exact same else if (peer->afc[afi][safi]) peer_deactivate(peer, afi, safi) logic already present in peer_group_bind(). peer_deactivate() handles newly created (non-established) peers correctly by clearing afc and deleting the peer_af structure. No P0/P1 issues found.

No files require special attention.

Important Files Changed

Filename Overview
bgpd/bgpd.c Adds peer_deactivate() for AFIs the group has disabled in peer_create_bind_dynamic_neighbor(), mirroring the existing fix in peer_group_bind() β€” correct, minimal, and well-targeted.

Sequence Diagram

sequenceDiagram
    participant TCP as Incoming TCP
    participant BGP as bgpd
    participant PCBDN as peer_create_bind_dynamic_neighbor()
    participant PC as peer_create()
    participant PD as peer_deactivate()

    TCP->>BGP: Dynamic peer connects (bgp listen range)
    BGP->>PCBDN: peer_create_bind_dynamic_neighbor(bgp, su, group)
    PCBDN->>PC: peer_create(...) β€” activates IPv4 unicast by default
    PC-->>PCBDN: peer (with afc[AFI_IP][SAFI_UNICAST]=1)
    PCBDN->>PCBDN: peer_group2peer_config_copy(group, peer)
    loop FOREACH_AFI_SAFI
        alt group->conf->afc[afi][safi] == 0 (group has disabled this AF)
            Note over PCBDN,PD: NEW: deactivate the AF the group does not want
            PCBDN->>PD: peer_deactivate(peer, afi, safi)
            PD->>PD: non_peergroup_deactivate_af() sets afc=0, deletes peer_af
        else group->conf->afc[afi][safi] == 1 (group has enabled this AF)
            PCBDN->>PCBDN: peer->afc[afi][safi] = 1, peer_af_create(), peer_group2peer_config_copy_af()
        end
    end
    PCBDN-->>BGP: peer (AFs match group exactly)
Loading

Reviews (1): Last reviewed commit: "bgpd: honor 'no activate' for dynamic ne..." | Re-trigger Greptile

When a dynamic peer connects via 'bgp listen range', peer_create()
activates IPv4 unicast by default. peer_create_bind_dynamic_neighbor()
then applies the group's AF config but only activates AFIs the group
has enabled -- it never deactivates AFIs the group has disabled.

This causes 'no neighbor <group> activate' under an address-family
to be ignored for dynamic peers.

Add peer_deactivate() for AFIs the group has deactivated, matching
the fix in peer_group_bind() from commit 5f00745 ("bgpd:
peer-group members 'activate' when they shouldn't").

Signed-off-by: Eyal Nissim <enissim@nvidia.com>
@ton31337

Copy link
Copy Markdown
Member

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

@ton31337
ton31337 merged commit 90d9be6 into FRRouting:master Apr 19, 2026
23 checks passed
@mergify

mergify Bot commented Apr 19, 2026

Copy link
Copy Markdown

backport stable/10.6 stable/10.5 stable/10.4

βœ… Backports have been created

Details

ton31337 added a commit that referenced this pull request Apr 20, 2026
bgpd: honor 'no activate' for dynamic neighbors in peer-group (backport #21658)
ton31337 added a commit that referenced this pull request Apr 20, 2026
bgpd: honor 'no activate' for dynamic neighbors in peer-group (backport #21658)
ton31337 added a commit that referenced this pull request Apr 20, 2026
bgpd: honor 'no activate' for dynamic neighbors in peer-group (backport #21658)
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