Skip to content

bgpd: clear several parameters in subgroup_announce_check() - #20884

Merged
donaldsharp merged 2 commits into
FRRouting:masterfrom
enkechen-panw:bgp-outbound-attr
Feb 24, 2026
Merged

bgpd: clear several parameters in subgroup_announce_check()#20884
donaldsharp merged 2 commits into
FRRouting:masterfrom
enkechen-panw:bgp-outbound-attr

Conversation

@enkechen-panw

@enkechen-panw enkechen-panw commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Clear tag, weight and distance in the outbound attribute. Also clear MED, aigp, and local-preference when appropriate.

This helps avoid unnecessary attributes in the outbound attribute table, and also helps reduce duplicate updates to neighbors.

@greptile-apps

greptile-apps Bot commented Feb 20, 2026

Copy link
Copy Markdown

Greptile Summary

This PR clears local-only and protocol-specific BGP attributes in outbound announcements to optimize the attribute table and reduce duplicate updates to neighbors.

Key changes:

  • Clears attr->med value (not just flag) when removing MED for EBGP peers
  • Restructures AIGP handling to explicitly clear AIGP when transmission is not allowed (previously left attribute in place)
  • Adds cleanup at end of function to clear local-only attributes (tag, weight, distance) for all peers
  • Clears local_pref for EBGP peers after route-map processing

Timing: All attribute clearing happens after the outbound route-map is applied (lines 2841-2846), allowing route-map match clauses like "match tag" or "match local-preference" to operate on original values as documented in the added comment.

Confidence Score: 4/5

  • Safe to merge with low risk - well-structured attribute cleanup that follows BGP protocol semantics
  • The changes correctly clear BGP attributes that should not be transmitted or are local-only. The timing is correct (after route-map processing), and the logic properly differentiates between IBGP/EBGP. The AIGP restructuring adds proper cleanup when transmission is not allowed. Minor confidence deduction for lack of test coverage verification.
  • No files require special attention

Important Files Changed

Filename Overview
bgpd/bgp_route.c Clears local-only BGP attributes (tag, weight, distance) and conditional attributes (MED, AIGP, local-preference) after route-map processing to reduce attribute table bloat and duplicate updates

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[subgroup_announce_check entry] --> B{EBGP peer?}
    B -->|Yes| C[Clear MED if conditions met<br/>NEW: attr->med = 0]
    B -->|No| D[Skip MED clearing]
    C --> E[Apply outbound route-map<br/>lines 2841-2846]
    D --> E
    E --> F{AIGP exists?}
    F -->|Yes| G{AIGP_TRANSMIT_ALLOWED?}
    F -->|No| I[Continue processing]
    G -->|Yes| H[Adjust AIGP metric if nh_reset]
    G -->|No| J[NEW: Clear AIGP<br/>attr->aigp_metric = 0<br/>bgp_attr_unset]
    H --> I
    J --> I
    I --> K[NEW: Clear local attributes<br/>tag, weight, distance = 0]
    K --> L{EBGP peer?}
    L -->|Yes| M[NEW: Clear local_pref<br/>attr->local_pref = 0]
    L -->|No| N[Keep local_pref]
    M --> O[Return true]
    N --> O
Loading

Last reviewed commit: bc5801f

@frrbot frrbot Bot added the tests Topotests, make check, etc label Feb 20, 2026
Comment thread bgpd/bgp_route.c Outdated
Comment thread bgpd/bgp_route.c Outdated
Clear tag, weight and distance in the outbound attribute. Also
clear MED, aigp, and local-preference when appropriate.

This helps avoid unnecessary attributes in the outbound attribute
table, and also helps reduce duplicate updates to neighbors.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
Adjust the topotests bgp_vpnv4_noretain.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
@donaldsharp
donaldsharp merged commit e8a7d87 into FRRouting:master Feb 24, 2026
19 checks passed
@enkechen-panw
enkechen-panw deleted the bgp-outbound-attr branch February 24, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bgp master size/M tests Topotests, make check, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants