You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: decode EVPN NLRI and the MAC Mobility extended community - #355
EVPN (AFI 25 / SAFI 70) used to land in AttributeValue::Raw, so a BMP feed from an EVPN route reflector produced no fields at all: no route, no MAC, no VTEP. This adds the family and the semantics.
What changes
Afi::L2vpn (25) and Safi::Evpn (70).
Nlri::evpn_nlris, one EvpnNlri per route with its route type, route distinguisher, and a typed body for route type 2 (MAC/IP advertisement: ESI, Ethernet tag, MAC, optional IP, label), type 3 (inclusive multicast) and type 5 (IP prefix). Route types 1 and 4 keep their octets as EvpnRoutePayload::Raw.
ExtendedCommunity::MacMobility { sticky, sequence } for type 0x06 / sub-type 0x00, with its encoder. Other EVPN sub-types stay raw, and ExtendedCommunity::Raw now reports the registered type (Evpn) instead of Unknown.
A Type-2 route is how a fabric distributes a MAC address, and a MAC move is an explicit BGP event carrying a sequence number. That makes the route reflector the only place where a MAC mobility record exists, and BMP the only way to get it out: public MRT archives never carry the family.
Decisions a reviewer may want to weigh in on
Afi, Safi and ExtendedCommunity gain variants, so downstream exhaustive matches need a new arm. That is the cost of the family being representable at all; the alternative was a separate parallel type.
EVPN end-of-RIB decodes to evpn_nlris: Some(vec![]). An MP_UNREACH carrying the family and no NLRI is exactly what the wire says, so it stays distinguishable from a family that was not monitored.
Encoding is refused, not approximated.encode_to returns EncodingError::Unencodable for EVPN NLRI rather than writing an update whose NLRI a receiver would read as an empty prefix list. Decode-only is the scope here; the encoder can follow once something needs it.
The type-5 prefix family follows from the prefix length. RFC 9136 does not signal it separately, so a length above 32 means IPv6 and the gateway address length is validated against that; a mismatch is a parse error rather than a guess.
Evidence
tests/evpn.rs decodes a capture from a real fabric: FRR 10.7.1, two leaves and a route reflector, VXLAN VNI 100, exported with bmp monitor l2vpn evpn post-policy. One host starts sending frames with another host's MAC, and both leaves re-advertise it with MAC Mobility sequence 1, then 2, 3 and 4, each round preceded by a withdrawal of the previous claim, with the originator alternating between the two VTEPs. Every announcement names its own leaf as next hop and route distinguisher, which is what a consumer needs to tell the two claimants apart.
The capture is committed as tests/fixtures/evpn/mac-move.bmp (2881 bytes), so the test is a real-device fixture rather than hand-built bytes.
EVPN (AFI 25 / SAFI 70) used to land in `AttributeValue::Raw`, so a BMP feed
from an EVPN route reflector produced no usable fields at all. This adds the
family and the semantics a consumer needs to follow a MAC move:
- `Afi::L2vpn` (25) and `Safi::Evpn` (70).
- `Nlri::evpn_nlris` with one `EvpnNlri` per route: route type, route
distinguisher, and a typed body for route type 2 (MAC/IP advertisement:
ESI, Ethernet tag, MAC, optional IP, label), type 3 (inclusive multicast)
and type 5 (IP prefix). Types 1 and 4 keep their octets as
`EvpnRoutePayload::Raw`; an EVPN end-of-RIB marker decodes to an empty list.
- `ExtendedCommunity::MacMobility` for type 0x06 / sub-type 0x00, with its
encoder, so a route survives a decode/encode round trip of its communities.
Other EVPN sub-types stay raw, and `Raw` now reports the registered type
instead of `Unknown`.
- The encoder refuses EVPN NLRI instead of writing an empty prefix list.
Checked against a capture from a real fabric (BGPKIT Labs topologies/
evpn-mac-mobility, FRR 10.7.1, two leaves and a route reflector): one host
sending frames with another host's MAC makes both leaves re-advertise it with
MAC Mobility sequence 1, 2, 3 and 4, each announcement naming its own VTEP as
next hop and route distinguisher. The capture is the test fixture and is
committed with the test.
Closes#354
❌ Patch coverage is 88.21942% with 131 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.02%. Comparing base (061b6b2) to head (4c4fe94).
- Reject address-family combinations that mix L2VPN or EVPN with another
family. AFI 1 with SAFI 70 was reaching the IP-prefix parser and becoming an
IPv4 default-route withdrawal instead of staying raw.
- Parse the RFC 9136 type-5 layout: a 10-octet ESI before the Ethernet tag, and
full-width 4 or 16-octet prefix and gateway fields. The family comes from the
NLRI length (34 or 58), so an IPv6 prefix of /32 or shorter decodes, and the
ESI is exposed on `IpPrefixRoute`.
- Bound the MAC read before copying. A body that declares MAC length 48 and
ends there passed the fixed-field check and then panicked in `copy_to_slice`;
it is a parse error now.
- Keep the optional Label2 of a MAC/IP advertisement (IP-VRF forwarding) and the
ADD-PATH path identifier on each `EvpnNlri`, instead of discarding both.
- Fix `is_end_of_rib`: an EVPN withdrawal carries its routes in `evpn_nlris`, so
an empty `prefixes` no longer reads as an end-of-RIB marker.
- Regenerate the WASM TypeScript bindings for the new family and community.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Active issues remain in EVPN ADD-PATH handling, label interpretation, BMP-to-MRT conversion, route validation, and text rendering, along with an outdated README.
Unlike the type-2 and type-5 parsers, this accepts and silently discards trailing bytes in the route body. A type-3 NLRI with a valid IP followed by extra octets is therefore reported as a valid typed route with different wire contents; reject it so the attribute is retained raw instead.
Regenerate README to keep release synchronization check passing
src/lib.rs:863
Please regenerate and commit README.md with cargo readme > README.md. It still goes directly from “Advanced Features” to FlowSpec, so the synchronization check in .github/workflows/release.yml:74 will fail for releases containing this change.
…e does
Second review round on the EVPN decoding.
- Text output gains an `ANNOUNCED (EVPN)` / `WITHDRAWN (EVPN)` section with one
line per route (type, RD, MAC or prefix, label, path id). Before this an EVPN
update rendered no route at all, only the attribute summary line.
- The encoder writes EVPN NLRI instead of refusing them, so
`MrtRecord::try_from(&BmpMessage)` converts EVPN route monitoring messages
again; it re-encodes the parsed update, and the refusal broke that path.
Routes round-trip byte for byte, ADD-PATH identifiers included, and a path
identifier without ADD-PATH is an error rather than a silent drop.
- The label fields are `raw_label` / `raw_label2`: the 24-bit wire value is a
VNI in a VXLAN fabric and an MPLS label with TC/S/TTL in the low bits
elsewhere. `mpls_label()` gives the label interpretation without shifting a
VNI.
Declined: threading ADD-PATH state through the BMP entry points. Route
monitoring frames an Adj-RIB-In message, and neither RFC 7854's per-peer header
nor this crate's `parse_bmp_msg` carries the session's ADD-PATH negotiation for
any family, so EVPN is not specially affected; a collector today cannot express
it at all. `parse_evpn_nlri` already takes the flag and preserves the identifier
when a caller supplies it.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Active issues leave EVPN ADD-PATH handling incomplete, permit malformed or lossy encoding, and leave the public encoding round-trip insufficiently tested.
Third review round.
- A type-3 route with octets after the originating address is rejected, like
types 2 and 5. Accepting them meant dropping bytes on re-encode.
- The encoder refuses the two impossible next-hop states: an EVPN announcement
without a VTEP (the next-hop length would be missing and a receiver would read
the reserved octet as it) and a withdrawal with one (MP_UNREACH has no such
field). Both are checked before a byte is written.
- A route type that disagrees with its payload is an error instead of a header
describing one family and a body describing another; raw payloads keep the
type they were decoded with.
- `Attribute::encode_to` infers ADD-PATH from EVPN path identifiers as well as
labeled prefixes, and does so for withdrawals too, so a parsed ADD-PATH EVPN
route survives the public encoder.
- The BMP-to-MRT conversion test now encodes the record and parses the bytes
back. `TryFrom` clones the parsed message, so the previous assertion only
proved the conversion returned Ok, not that its encoding was valid.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
BMP decoding does not propagate negotiated ADD-PATH state, and encoding can include path identifiers in non-ADD-PATH records, leaving EVPN routes undecoded.
Fourth review round. ADD-PATH is signalled by the MRT record subtype
(RFC 8050), so an update carrying path identifiers under `MessageAs4` decodes
with the identifier read as NLRI.
- `Bgp4MpMessage::encode` refuses a subtype that disagrees with the payload:
identifiers under a plain subtype, or an ADD-PATH subtype without them.
- `MrtRecord::try_from(&BmpMessage)` picks `MessageAs4Addpath` when the parsed
update carries identifiers. A BMP session cannot express the negotiation, so
the update itself is the only evidence available.
- Round-trip tests for both directions, including the BMP conversion.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
BMP route-monitoring always disables ADD-PATH parsing, causing EVPN routes with path IDs to be misdecoded or fall back to raw attributes; existing tests do not exercise this path with a wire message.
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
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.
EVPN (AFI 25 / SAFI 70) used to land in
AttributeValue::Raw, so a BMP feed from an EVPN route reflector produced no fields at all: no route, no MAC, no VTEP. This adds the family and the semantics.What changes
Afi::L2vpn(25) andSafi::Evpn(70).Nlri::evpn_nlris, oneEvpnNlriper route with its route type, route distinguisher, and a typed body for route type 2 (MAC/IP advertisement: ESI, Ethernet tag, MAC, optional IP, label), type 3 (inclusive multicast) and type 5 (IP prefix). Route types 1 and 4 keep their octets asEvpnRoutePayload::Raw.ExtendedCommunity::MacMobility { sticky, sequence }for type0x06/ sub-type0x00, with its encoder. Other EVPN sub-types stay raw, andExtendedCommunity::Rawnow reports the registered type (Evpn) instead ofUnknown.A Type-2 route is how a fabric distributes a MAC address, and a MAC move is an explicit BGP event carrying a sequence number. That makes the route reflector the only place where a MAC mobility record exists, and BMP the only way to get it out: public MRT archives never carry the family.
Decisions a reviewer may want to weigh in on
Afi,SafiandExtendedCommunitygain variants, so downstream exhaustive matches need a new arm. That is the cost of the family being representable at all; the alternative was a separate parallel type.evpn_nlris: Some(vec![]). An MP_UNREACH carrying the family and no NLRI is exactly what the wire says, so it stays distinguishable from a family that was not monitored.encode_toreturnsEncodingError::Unencodablefor EVPN NLRI rather than writing an update whose NLRI a receiver would read as an empty prefix list. Decode-only is the scope here; the encoder can follow once something needs it.Evidence
tests/evpn.rsdecodes a capture from a real fabric: FRR 10.7.1, two leaves and a route reflector, VXLAN VNI 100, exported withbmp monitor l2vpn evpn post-policy. One host starts sending frames with another host's MAC, and both leaves re-advertise it with MAC Mobility sequence 1, then 2, 3 and 4, each round preceded by a withdrawal of the previous claim, with the originator alternating between the two VTEPs. Every announcement names its own leaf as next hop and route distinguisher, which is what a consumer needs to tell the two claimants apart.The capture is committed as
tests/fixtures/evpn/mac-move.bmp(2881 bytes), so the test is a real-device fixture rather than hand-built bytes.Closes #354