bgpd: initialise nh_flag attribute#21498
bgpd: initialise nh_flag attribute#21498fdumontet6WIND wants to merge 2 commits intoFRRouting:masterfrom
Conversation
Greptile SummaryThis PR fixes a bug in The code correctly sets Confidence Score: 5/5Safe to merge — the fix is correct and the refactoring is internally consistent with no logic regressions. The bug fix correctly initialises No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller as vpn_leak_to_vrf_update_onevrf
participant LU as leak_update()
participant AI as bgp_attr_intern()
participant NHV as leak_update_nexthop_valid()
Caller->>LU: leak_update(..., &static_attr [uninterned])
Note over LU: New-route path
LU->>LU: info_make(..., static_attr, bn) / new->attr = static_attr (uninterned)
LU->>NHV: leak_update_nexthop_valid(..., new, ...)
NHV-->>LU: nh_valid = true
LU->>LU: bgp_path_info_set_flag(BGP_PATH_VALID)
LU->>LU: SET_FLAG(new->attr->nh_flags, BGP_ATTR_NH_VALID)
LU->>AI: bgp_attr_intern(static_attr)
AI-->>LU: interned attr (nh_flags set)
LU->>LU: new->attr = interned attr
LU-->>Caller: new route
Caller->>Caller: bgp_attr_flush(&static_attr)
Reviews (2): Last reviewed commit: "bgpd: initialise nh_flag attribute" | Re-trigger Greptile |
c2cf998 to
dd5baf1
Compare
| source_bpi, new, bgp_orig, p, debug)) { | ||
| bgp_path_info_set_flag(bn, new, BGP_PATH_VALID); | ||
| else | ||
| SET_FLAG(new->attr->nh_flags, BGP_ATTR_NH_VALID); |
There was a problem hiding this comment.
Is this BGP_ATTR_NH_VALID flag used anywhere at all in the code?
There was a problem hiding this comment.
@greptileai is this nh_flags (BGP_ATTR_NH_VALID) used anywhere despite SET/UNSET?
There was a problem hiding this comment.
Confirmed — BGP_ATTR_NH_VALID is not checked anywhere in the codebase. Searching the entire repo, it only appears in:
bgpd/bgp_attr.h— the#definebgpd/bgp_mplsvpn.c— this PR'sSET_FLAGcall (and the correspondingUNSET_FLAGin theelsebranch)
There are zero CHECK_FLAG(attr->nh_flags, BGP_ATTR_NH_VALID) calls anywhere. The flag is defined, set, and unset — but never consumed. That makes this change a no-op from a behavioral standpoint, which raises the question of whether the fix is addressing the real bug, or whether BGP_ATTR_NH_VALID needs to actually be wired into nexthop resolution/route selection logic somewhere to have any meaningful effect.
Tip: You can customize Greptile's behavior for this repo with .greptile/rules and .greptile/config.
b55ece2 to
ab122b2
Compare
This patch modifies `leak_update()` to accept a non-interned static attribute rather than requiring an already-interned one. Previously, callers such as `vpn_leak_to_vrf_update_onevrf()` and `_vpn_leak_from_vrf_update_leak_attr()` would intern the attribute prior to calling `leak_update()`. If `leak_update()` determined that the route was unchanged, it would simply unintern the attribute and continue, resulting in unnecessary memory allocation and hash table overhead. With this change, the caller passes a pointer to the static attribute, and `leak_update()` now defers calling `bgp_attr_intern()` until it actually needs to update an existing path or allocate a new one. The callers handle flushing the static attribute when done. Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
this commit fixes an issue during new path creation: if the new leaked path is determined to have a valid nexthop, the `BGP_ATTR_NH_VALID` flag is now correctly set on the `nh_flags`. Fixes: 879bfc0 (bgpd: fix VRF leaking with 'network import-check') Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
ab122b2 to
fd8e0ca
Compare
|
failure not linked with commit |
|
so you've now added a completely unrelated second commit - why? |
preparatory commit. |
|
@greptile review |
|
in fact BGP_ATTR_NH_VALID flag is tested in "attrhash_cmp" function. |
|
90c0b89 |
in "leak_update" function
nh_flag is not initialized when nexthop is valid at route creation.