Skip to content

bgpd: Skip route-map LPM optimisation for AF_FLOWSPEC#22083

Merged
donaldsharp merged 1 commit into
FRRouting:masterfrom
opensourcerouting:fix/rmap_flowspec
May 28, 2026
Merged

bgpd: Skip route-map LPM optimisation for AF_FLOWSPEC#22083
donaldsharp merged 1 commit into
FRRouting:masterfrom
opensourcerouting:fix/rmap_flowspec

Conversation

@ton31337
Copy link
Copy Markdown
Member

No description provided.

@ton31337
Copy link
Copy Markdown
Member Author

@Mergifyio backport stable/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2

@mergify
Copy link
Copy Markdown

mergify Bot commented May 27, 2026

backport stable/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2

✅ Backports have been created

Details

Cherry-pick of 6038df7 has failed:

On branch mergify/bp/stable/10.2/pr-22083
Your branch is up to date with 'origin/stable/10.2'.

You are currently cherry-picking commit 6038df722.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   lib/routemap.c

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 27, 2026

Greptile Summary

This single-line condition change in route_map_apply_ext fixes a silent route-map match bypass for AF_FLOWSPEC routes by generalizing the existing AF_EVPN guard. Previously, only AF_EVPN fell through to the linear (full-sequence) walk; any other non-IPv4/IPv6 family — including AF_FLOWSPEC — incorrectly entered the LPM optimisation path, where route_map_get_index blindly used map->ipv6_prefix_table for the lookup and could evict IPv4 prefix-list clauses, silently failing to evaluate them.

  • Root cause addressed: route_map_get_index uses map->ipv6_prefix_table as a fallback for any non-AF_INET family (line 1893–1894), but AF_FLOWSPEC prefixes are never indexed into that trie, so LPM lookups always miss and route-map clauses are skipped.
  • Fix is correctly generalised: The new condition prefix->family != AF_INET && prefix->family != AF_INET6 replaces the narrower == AF_EVPN check, meaning any present or future non-IPv4/IPv6 address family automatically gets the safe linear walk without needing a separate code change.

Confidence Score: 5/5

Safe to merge — the change is a minimal, targeted guard that restores correct route-map evaluation for AF_FLOWSPEC without touching the LPM path used by IPv4/IPv6.

The changed condition is small and surgical: it widens an existing family-bypass guard from AF_EVPN-only to all non-IPv4/IPv6 families. The LPM optimisation path for AF_INET/AF_INET6 is completely unchanged. The linear-walk path being restored for AF_FLOWSPEC was already in place and tested for AF_EVPN, so there is no new code to worry about. The accompanying comment clearly documents the reasoning.

No files require special attention. The only change is in lib/routemap.c at the family-dispatch branch in route_map_apply_ext.

Important Files Changed

Filename Overview
lib/routemap.c Broadens the LPM optimization bypass from AF_EVPN-only to all non-AF_INET/AF_INET6 families, fixing silent match failures for AF_FLOWSPEC routes

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[route_map_apply_ext called] --> B{prefix->family}
    B -->|AF_INET or AF_INET6| C[skip_match_clause = true\nroute_map_get_index LPM lookup]
    B -->|AF_EVPN / AF_FLOWSPEC\nor any other family| D[index = map->head\nlinear walk, all clauses evaluated]
    C --> E{index found?}
    E -->|Yes| F[Loop: first clause skipped\nLPM already matched it]
    E -->|No| G[RMAP_DENYMATCH or RMAP_PERMITMATCH\nbased on match_ret]
    D --> H[Loop: every clause\nmatched explicitly]
    F --> I[Apply set actions, continue / permit / deny]
    H --> I
Loading

Reviews (1): Last reviewed commit: "bgpd: Skip route-map LPM optimisation fo..." | Re-trigger Greptile

Comment thread lib/routemap.c
Reported-by: Qifan Zhang, Palo Alto Networks
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
@ton31337 ton31337 force-pushed the fix/rmap_flowspec branch from b896782 to 6038df7 Compare May 28, 2026 08:58
@github-actions github-actions Bot added the rebase PR needs rebase label May 28, 2026
Copy link
Copy Markdown
Contributor

@nick-bouliane nick-bouliane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@donaldsharp donaldsharp merged commit 7e651e4 into FRRouting:master May 28, 2026
34 of 35 checks passed
Jafaral added a commit that referenced this pull request May 29, 2026
bgpd: Skip route-map LPM optimisation for AF_FLOWSPEC (backport #22083)
@ton31337 ton31337 deleted the fix/rmap_flowspec branch May 29, 2026 05:39
donaldsharp added a commit that referenced this pull request May 29, 2026
bgpd: Skip route-map LPM optimisation for AF_FLOWSPEC (backport #22083)
donaldsharp added a commit that referenced this pull request May 29, 2026
bgpd: Skip route-map LPM optimisation for AF_FLOWSPEC (backport #22083)
NetDEF-CI pushed a commit to opensourcerouting/frr that referenced this pull request May 29, 2026
…0.5/pr-22083

bgpd: Skip route-map LPM optimisation for AF_FLOWSPEC (backport FRRouting#22083)
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.

3 participants