bgpd: remove unneeded sort of communities in rmap delete - #22151
Conversation
Greptile SummaryThis PR removes a redundant sort-and-dedup step (
Confidence Score: 5/5This is a safe, well-reasoned cleanup that removes redundant memory allocations and sorting in three symmetric code paths without changing observable behavior. The *_list_match_delete functions iterate in forward order and delete entries in reverse-index order via memmove, which provably preserves the sorted order of surviving elements. Because communities are already interned without duplicates, the removed *_uniq_sort call was doing no useful work. Memory ownership transfers cleanly β the dup is now used directly as new with the same lifetime and free/intern path as before. No behavioral difference is introduced. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant RM as route_set_*_delete
participant DUP as community_dup
participant DEL as *_list_match_delete
participant SORT as *_uniq_sort (removed)
participant ATTR as bgp_attr_set_*
Note over RM,ATTR: Before this PR
RM->>DUP: dup(old)
DUP-->>RM: merge (heap alloc)
RM->>DEL: match_delete(merge, list)
DEL-->>RM: merge (in-place, sorted)
RM->>SORT: uniq_sort(merge)
SORT-->>RM: new (another heap alloc)
RM->>RM: free(merge)
RM->>ATTR: set_attr(new) or free(new)
Note over RM,ATTR: After this PR
RM->>DUP: dup(old)
DUP-->>RM: new (heap alloc)
RM->>DEL: match_delete(new, list)
DEL-->>RM: new (in-place, sorted preserved)
RM->>ATTR: set_attr(new) or free(new)
Reviews (1): Last reviewed commit: "bgpd: remove unneeded sort of communitie..." | Re-trigger Greptile |
|
@Mergifyio backport stable/10.6 stable/10.5 |
β Backports have been createdDetails
|
When routemaps delete from a community list, don't need to re-sort the community list: the delete code preserves the sorted order. Signed-off-by: Mark Stapp <mjs@cisco.com> Reported-by: Qifan Zhang <qzhang@paloaltonetworks.com>
adef297 to
a603e0f
Compare
|
It seems like this should be labeled a bug fix? |
bgpd: remove unneeded sort of communities in rmap delete (backport #22151)
bgpd: remove unneeded sort of communities in rmap delete (backport #22151)
When routemaps delete from a community list, don't need to re-sort the community list: the delete code preserves the sorted order.
this was F-079 from the 2026_05_27 batch of reports from Qifan Zhang