bgpd: refactor bgp_aggregate_{increment,decrement}#22126
Conversation
Greptile SummaryThis PR refactors
Confidence Score: 5/5Safe to merge — pure refactor with no behavioral changes. Every guard, the traversal loop, and the unlock call are carried over verbatim into the shared helper; only the inner branch that selects add vs. remove is new. The public function signatures are unchanged, so all callers are unaffected. The previously flagged stale comment has been corrected in this revision. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[bgp_aggregate_increment] -->|increment=true| C[bgp_aggregate_adjust_count]
B[bgp_aggregate_decrement] -->|increment=false| C
C --> D{Guards pass?}
D -- No --> E[return]
D -- Yes --> F[bgp_node_match]
F --> G{child found?}
G -- No --> E
G -- Yes --> H["Loop: dest → bgp_dest_parent_nolock"]
H --> I{aggregate != NULL && prefixlen <}
I -- No --> H
I -- Yes --> J{increment?}
J -- true --> K[bgp_add_route_to_aggregate]
J -- false --> L[bgp_remove_route_from_aggregate]
K --> H
L --> H
H -->|loop done| M[bgp_dest_unlock_node]
Reviews (2): Last reviewed commit: "bgpd: refactor bgp_aggregate_{increment,..." | Re-trigger Greptile |
The two functions share identical guard logic and loop structure; the only difference is whether they call bgp_add_route_to_aggregate() or bgp_remove_route_from_aggregate(). Factor the common body into a static helper bgp_aggregate_adjust_count() controlled by a bool increment parameter, and reduce bgp_aggregate_increment/decrement to thin wrappers. Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
c577928 to
113499f
Compare
|
@greptileai review |
|
ci:rerun |
The two functions share identical guard logic and loop structure; the only difference is whether they call bgp_add_route_to_aggregate() or bgp_remove_route_from_aggregate(). Factor the common body into a static helper bgp_aggregate_adjust_count() controlled by a bool increment parameter, and reduce bgp_aggregate_increment/decrement to thin wrappers.