Skip to content

bgpd: A couple link-state nits - #21842

Merged
cscarpitta merged 3 commits into
FRRouting:masterfrom
opensourcerouting:fix/bgp_ls_nits
May 6, 2026
Merged

bgpd: A couple link-state nits#21842
cscarpitta merged 3 commits into
FRRouting:masterfrom
opensourcerouting:fix/bgp_ls_nits

Conversation

@ton31337

@ton31337 ton31337 commented May 2, 2026

Copy link
Copy Markdown
Member

No description provided.

ton31337 added 3 commits May 2, 2026 20:59
Seems this was missed unintentionally(?).

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
And also replace/use it everywhere in the code. For maintainability.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
@greptile-apps

greptile-apps Bot commented May 2, 2026

Copy link
Copy Markdown

Greptile Summary

This PR encapsulates direct attr->ls_attr field accesses behind bgp_attr_get_ls_attr/bgp_attr_set_ls_attr accessor functions, aligning BGP-LS attribute handling with the existing patterns for other sub-attributes (community, ecommunity, NHC, etc.). The new setter additionally manages the BGP_ATTR_LINK_STATE presence flag, and a previously missing ls_attr cleanup block is added to bgp_attr_flush.

Confidence Score: 4/5

Safe to merge β€” changes are mechanical refactoring with a correct unintern-sub fix and a new flush cleanup path.

All changes follow established accessor patterns already used for other sub-attributes. The bgp_attr_unintern_sub fix correctly nulls the pointer after unintern, matching the community/ecommunity/nhc patterns. No logic regressions identified. Score is 4 rather than 5 only because the new bgp_attr_set_ls_attr setter silently adds a BGP_ATTR_LINK_STATE flag side-effect on every set, which is a subtle behavioral addition worth a reviewer double-checking against all call sites.

bgpd/bgp_attr.c β€” specifically the bgp_attr_intern and bgp_attr_flush paths that now implicitly toggle BGP_ATTR_LINK_STATE through the setter.

Important Files Changed

Filename Overview
bgpd/bgp_attr.h Adds bgp_attr_get_ls_attr / bgp_attr_set_ls_attr inline accessors; setter also manages the BGP_ATTR_LINK_STATE presence flag, consistent with other attribute accessors.
bgpd/bgp_attr.c Replaces direct attr->ls_attr accesses with accessors; fixes bgp_attr_unintern_sub to always null the pointer after unintern (matching other attribute patterns); adds missing flush cleanup; one mid-function variable declaration follows C99 style already used elsewhere in the file.
bgpd/bgp_route.c Mechanical replacement of attr->ls_attr with bgp_attr_get_ls_attr(attr) in display/JSON output path; no logic changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[bgp_attr_set_ls_attr called] --> B{ls_attr != NULL?}
    B -- Yes --> C[attr->ls_attr = ls_attr]
    C --> D[bgp_attr_set BGP_ATTR_LINK_STATE]
    B -- No --> E[attr->ls_attr = NULL]
    E --> F[bgp_attr_unset BGP_ATTR_LINK_STATE]

    G[bgp_attr_unintern_sub] --> H[ls_attr = bgp_attr_get_ls_attr]
    H --> I[bgp_ls_attr_unintern & ls_attr]
    I --> J{refcnt reaches 0?}
    J -- Yes --> K[free + set local ptr NULL]
    J -- No --> L[decrement refcnt only]
    K --> M[bgp_attr_set_ls_attr attr NULL]
    L --> M

    N[bgp_attr_flush] --> O[ls_attr = bgp_attr_get_ls_attr]
    O --> P{ls_attr && !refcnt?}
    P -- Yes --> Q[bgp_ls_attr_free]
    Q --> R[bgp_attr_set_ls_attr attr NULL]
    P -- No --> S[skip]
Loading

Reviews (1): Last reviewed commit: "bgpd: Set BGP_ATTR_LINK_STATE when we re..." | Re-trigger Greptile

@ton31337
ton31337 requested a review from cscarpitta May 2, 2026 18:16
@riw777
riw777 self-requested a review May 5, 2026 15:30
@cscarpitta
cscarpitta merged commit 2d7a2b1 into FRRouting:master May 6, 2026
25 checks passed
@ton31337
ton31337 deleted the fix/bgp_ls_nits branch May 6, 2026 13:39
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