bgpd: improve packet parsing for EVPN and ENCAP/VNC#21098
Merged
riw777 merged 1 commit intoFRRouting:masterfrom Mar 18, 2026
Merged
bgpd: improve packet parsing for EVPN and ENCAP/VNC#21098riw777 merged 1 commit intoFRRouting:masterfrom
riw777 merged 1 commit intoFRRouting:masterfrom
Conversation
Greptile SummaryThis PR hardens packet parsing for EVPN (Types 2, 3, and 4) and VNC/RFAPI by adding cross-validation between the internally-declared IP address length field and the overall NLRI wire-length, and by adding stricter sub-TLV length guards in the rfapi RIB path. Key changes:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Receive NLRI packet] --> B{Route Type?}
B -->|Type-2| T2A[Validate psize is one of 33 36 37 40 49 52]
T2A -->|invalid| FAIL1[return -1]
T2A -->|valid| T2B[Read macaddr_len and ipaddr_len]
T2B --> T2C{ipaddr_len is 0 or 32 or 128?}
T2C -->|no| FAIL2[goto fail]
T2C -->|yes| T2D{psize == 33 + ipaddr_len/8 OR 36 + ipaddr_len/8? NEW}
T2D -->|no| FAIL3[goto fail]
T2D -->|yes| T2E[Read IP and VNI labels then process route]
B -->|Type-3| T3A{psize == 17 or 29?}
T3A -->|no| FAIL4[return -1]
T3A -->|yes| T3B[Read Eth Tag then ipaddr_len]
T3B --> T3C{psize == 13 + ipaddr_len/8? NEW}
T3C -->|no| FAIL5[return -1]
T3C -->|yes| T3D{ipaddr_len == 32 or 128?}
T3D -->|no| FAIL6[return -1]
T3D -->|yes| T3E[Read IP then process route]
B -->|Type-4| T4A{psize == 23 or 35?}
T4A -->|no| FAIL7[return -1]
T4A -->|yes| T4B[Read ESI then ipaddr_len]
T4B --> T4C{psize == 19 + ipaddr_len/8? NEW}
T4C -->|no| FAIL8[return -1]
T4C -->|yes| T4D{ipaddr_len == 32 or 128?}
T4D -->|no| FAIL9[return -1]
T4D -->|yes| T4E[Read IP then process route]
B -->|VNC RFPOPTION| V1{pEncap length less than 3? NEW}
V1 -->|yes| VBREAK[skip sub-TLV]
V1 -->|no| V2{pEncap value index 1 equals 0? NEW}
V2 -->|yes| VBREAK
V2 -->|no| V3[Allocate hop copy value bytes shrink length if mismatch]
Last reviewed commit: 7676cad |
Improve packet validation for EVPN NLRIs and for ENCAP/VNC. Signed-off-by: Mark Stapp <mjs@cisco.com>
4369990 to
7676cad
Compare
Member
|
@Mergifyio backport stable/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2 stable/10.1 stable/10.0 |
✅ Backports have been createdDetails
|
Member
|
@greptile review |
This was referenced Mar 18, 2026
riw777
added a commit
that referenced
this pull request
Mar 18, 2026
bgpd: improve packet parsing for EVPN and ENCAP/VNC (backport #21098)
riw777
added a commit
that referenced
this pull request
Mar 18, 2026
bgpd: improve packet parsing for EVPN and ENCAP/VNC (backport #21098)
riw777
added a commit
that referenced
this pull request
Mar 18, 2026
bgpd: improve packet parsing for EVPN and ENCAP/VNC (backport #21098)
riw777
added a commit
that referenced
this pull request
Mar 18, 2026
bgpd: improve packet parsing for EVPN and ENCAP/VNC (backport #21098)
riw777
added a commit
that referenced
this pull request
Mar 18, 2026
bgpd: improve packet parsing for EVPN and ENCAP/VNC (backport #21098)
riw777
added a commit
that referenced
this pull request
Mar 18, 2026
bgpd: improve packet parsing for EVPN and ENCAP/VNC (backport #21098)
riw777
added a commit
that referenced
this pull request
Mar 18, 2026
bgpd: improve packet parsing for EVPN and ENCAP/VNC (backport #21098)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve packet validation for EVPN NLRIs and for ENCAP/VNC. Validate internal ip address fields against overall message length; impose stricter validation for VNC sub-tlvs in the rfapi code.