Documentation
¶
Overview ¶
Design: docs/architecture/wire/nlri-evpn.md — EVPN NLRI plugin RFC: rfc/short/rfc7432.md
Package evpn implements an EVPN family plugin for ze. It handles decoding of EVPN NLRI (RFC 7432, 9136) for the decode mode protocol.
Design: docs/architecture/wire/nlri-evpn.md — EVPN NLRI plugin RFC: rfc/short/rfc7432.md
Package evpn implements EVPN NLRI types for the evpn plugin. RFC 7432: BGP MPLS-Based Ethernet VPN RFC 9136: IP Prefix Advertisement in EVPN
Index ¶
- Constants
- Variables
- func DecodeNLRIHex(family, hexStr string) (any, error)
- func EVPNFamilies() []string
- func EncodeNLRIHex(family string, args []string) (string, error)
- func EncodeRoute(routeCmd, _ string, localAS uint32, isIBGP, asn4, addPath bool) ([]byte, []byte, error)
- func GetEVPNYANG() string
- func RunCLIDecode(hexData, family string, textOutput bool, output, errOut io.Writer) int
- func RunEVPNDecode(input io.Reader, output io.Writer) int
- func RunEVPNPlugin(conn net.Conn) int
- func SetEVPNLogger(l *slog.Logger)
- type ESI
- type EVPN
- type EVPNGeneric
- func (e *EVPNGeneric) AppendJSON(buf []byte) []byte
- func (e *EVPNGeneric) Bytes() []byte
- func (e *EVPNGeneric) Family() Family
- func (e *EVPNGeneric) HasPathID() bool
- func (e *EVPNGeneric) Len() int
- func (e *EVPNGeneric) PathID() uint32
- func (e *EVPNGeneric) RD() RouteDistinguisher
- func (e *EVPNGeneric) RouteType() EVPNRouteType
- func (e *EVPNGeneric) String() string
- func (e *EVPNGeneric) SupportsAddPath() bool
- func (e *EVPNGeneric) WriteTo(buf []byte, off int) int
- type EVPNRouteType
- type EVPNType1
- func (e *EVPNType1) AppendJSON(buf []byte) []byte
- func (e *EVPNType1) Bytes() []byte
- func (e *EVPNType1) ESI() ESI
- func (e *EVPNType1) EthernetTag() uint32
- func (e *EVPNType1) Family() Family
- func (e *EVPNType1) HasPathID() bool
- func (e *EVPNType1) Labels() []uint32
- func (e *EVPNType1) Len() int
- func (e *EVPNType1) PathID() uint32
- func (e *EVPNType1) RD() RouteDistinguisher
- func (e *EVPNType1) RouteType() EVPNRouteType
- func (e *EVPNType1) String() string
- func (e *EVPNType1) SupportsAddPath() bool
- func (e *EVPNType1) WriteTo(buf []byte, off int) int
- type EVPNType2
- func (e *EVPNType2) AppendJSON(buf []byte) []byte
- func (e *EVPNType2) Bytes() []byte
- func (e *EVPNType2) ESI() ESI
- func (e *EVPNType2) EthernetTag() uint32
- func (e *EVPNType2) Family() Family
- func (e *EVPNType2) HasPathID() bool
- func (e *EVPNType2) IP() netip.Addr
- func (e *EVPNType2) Labels() []uint32
- func (e *EVPNType2) Len() int
- func (e *EVPNType2) MAC() [6]byte
- func (e *EVPNType2) PathID() uint32
- func (e *EVPNType2) RD() RouteDistinguisher
- func (e *EVPNType2) RouteType() EVPNRouteType
- func (e *EVPNType2) String() string
- func (e *EVPNType2) SupportsAddPath() bool
- func (e *EVPNType2) WriteTo(buf []byte, off int) int
- type EVPNType3
- func (e *EVPNType3) AppendJSON(buf []byte) []byte
- func (e *EVPNType3) Bytes() []byte
- func (e *EVPNType3) EthernetTag() uint32
- func (e *EVPNType3) Family() Family
- func (e *EVPNType3) HasPathID() bool
- func (e *EVPNType3) Len() int
- func (e *EVPNType3) OriginatorIP() netip.Addr
- func (e *EVPNType3) PathID() uint32
- func (e *EVPNType3) RD() RouteDistinguisher
- func (e *EVPNType3) RouteType() EVPNRouteType
- func (e *EVPNType3) String() string
- func (e *EVPNType3) SupportsAddPath() bool
- func (e *EVPNType3) WriteTo(buf []byte, off int) int
- type EVPNType4
- func (e *EVPNType4) AppendJSON(buf []byte) []byte
- func (e *EVPNType4) Bytes() []byte
- func (e *EVPNType4) ESI() ESI
- func (e *EVPNType4) Family() Family
- func (e *EVPNType4) HasPathID() bool
- func (e *EVPNType4) Len() int
- func (e *EVPNType4) OriginatorIP() netip.Addr
- func (e *EVPNType4) PathID() uint32
- func (e *EVPNType4) RD() RouteDistinguisher
- func (e *EVPNType4) RouteType() EVPNRouteType
- func (e *EVPNType4) String() string
- func (e *EVPNType4) SupportsAddPath() bool
- func (e *EVPNType4) WriteTo(buf []byte, off int) int
- type EVPNType5
- func (e *EVPNType5) AppendJSON(buf []byte) []byte
- func (e *EVPNType5) Bytes() []byte
- func (e *EVPNType5) ESI() ESI
- func (e *EVPNType5) EthernetTag() uint32
- func (e *EVPNType5) Family() Family
- func (e *EVPNType5) Gateway() netip.Addr
- func (e *EVPNType5) HasPathID() bool
- func (e *EVPNType5) Labels() []uint32
- func (e *EVPNType5) Len() int
- func (e *EVPNType5) PathID() uint32
- func (e *EVPNType5) Prefix() netip.Prefix
- func (e *EVPNType5) RD() RouteDistinguisher
- func (e *EVPNType5) RouteType() EVPNRouteType
- func (e *EVPNType5) String() string
- func (e *EVPNType5) SupportsAddPath() bool
- func (e *EVPNType5) WriteTo(buf []byte, off int) int
- type Family
- type RouteDistinguisher
Constants ¶
const ( AFIL2VPN = family.AFIL2VPN SAFIEVPN = family.SAFIEVPN )
Re-export constants from nlri for local use.
const ( RouteNameEthernetAutoDiscovery = "ethernet-auto-discovery" RouteNameMACIPAdvertisement = "mac-ip-advertisement" RouteNameInclusiveMulticast = "inclusive-multicast" RouteNameEthernetSegment = "ethernet-segment" RouteNameIPPrefix = "ip-prefix" )
Variables ¶
var ( ParseRouteDistinguisher = nlri.ParseRouteDistinguisher ParseLabelStack = nlri.ParseLabelStack EncodeLabelStack = nlri.EncodeLabelStack WriteLabelStack = nlri.WriteLabelStack ParseRDString = nlri.ParseRDString )
Re-export parsing functions.
var ( ErrEVPNTruncated = errors.New("evpn: truncated data") ErrEVPNInvalidAddress = errors.New("evpn: invalid address") ErrEVPNInvalidPrefix = errors.New("evpn: invalid prefix") )
EVPN errors.
var L2VPNEVPN = family.MustRegister(AFIL2VPN, SAFIEVPN, "l2vpn", "evpn")
Family registration for EVPN.
Functions ¶
func DecodeNLRIHex ¶
DecodeNLRIHex decodes EVPN NLRI from hex bytes, returning a data structure. This is the in-process fast path registered in the plugin registry. Same logic as the OnDecodeNLRI SDK callback but callable without RPC.
func EVPNFamilies ¶
func EVPNFamilies() []string
EVPNFamilies returns the address families this plugin can decode.
func EncodeNLRIHex ¶
EncodeNLRIHex encodes EVPN NLRI from text args, returning hex bytes. Args format: <route-type> followed by key-value pairs:
"type2" "rd" <rd> "esi" <esi> "ethernet-tag" <tag> "mac" <mac> ["ip" <ip>] ["label" <l>]... "type3" "rd" <rd> "ethernet-tag" <tag> "ip" <ip> "type5" "rd" <rd> ["esi" <esi>] "ethernet-tag" <tag> "prefix" <pfx> ["gateway" <gw>] ["label" <l>]...
This is the in-process fast path registered in the plugin registry.
func EncodeRoute ¶
func EncodeRoute(routeCmd, _ string, localAS uint32, isIBGP, asn4, addPath bool) ([]byte, []byte, error)
EncodeRoute encodes an EVPN route command into UPDATE body bytes and NLRI bytes. This implements the InProcessRouteEncoder signature for the plugin registry.
func GetEVPNYANG ¶
func GetEVPNYANG() string
GetEVPNYANG returns the embedded YANG schema for the evpn plugin. EVPN plugin doesn't augment config schema, returns empty.
func RunCLIDecode ¶
RunCLIDecode decodes EVPN NLRI from hex string for CLI mode. This is for direct CLI invocation: ze plugin evpn --nlri <hex> Output is plain JSON array or text (no "decoded json" prefix). Errors go to errOut (typically stderr), results go to output (typically stdout).
func RunEVPNDecode ¶
RunEVPNDecode runs the plugin in decode mode for ze bgp decode (engine protocol).
func RunEVPNPlugin ¶
RunEVPNPlugin runs the EVPN plugin using the SDK RPC protocol. This is the in-process entry point called via InternalPluginRunner.
func SetEVPNLogger ¶
SetEVPNLogger sets the package-level logger. Called by cmd/ze/bgp/plugin_evpn.go with slogutil.PluginLogger().
Types ¶
type ESI ¶
type ESI [10]byte
ESI represents a 10-byte Ethernet Segment Identifier. RFC 7432 Section 5 defines the ESI format and types.
func ParseESIString ¶
ParseESIString parses an Ethernet Segment Identifier from string format.
type EVPN ¶
type EVPN interface {
RouteType() EVPNRouteType
RD() RouteDistinguisher
Family() Family
Bytes() []byte
Len() int
String() string
PathID() uint32
HasPathID() bool
SupportsAddPath() bool
WriteTo(buf []byte, off int) int
}
EVPN is the interface for all EVPN route types.
type EVPNGeneric ¶
type EVPNGeneric struct {
// contains filtered or unexported fields
}
EVPNGeneric holds unparsed EVPN routes.
func (*EVPNGeneric) AppendJSON ¶
func (e *EVPNGeneric) AppendJSON(buf []byte) []byte
AppendJSON for EVPNGeneric (unparsed / unknown route type). Keys: code, parsed, raw.
func (*EVPNGeneric) Bytes ¶
func (e *EVPNGeneric) Bytes() []byte
Bytes returns a standalone wire encoding, header included, matching every other EVPN route type. It used to return the bare body, so a caller that round-trips an unrecognized route through encode.go emitted an NLRI with no [type][length] header.
func (*EVPNGeneric) Family ¶
func (e *EVPNGeneric) Family() Family
func (*EVPNGeneric) HasPathID ¶
func (e *EVPNGeneric) HasPathID() bool
func (*EVPNGeneric) Len ¶
func (e *EVPNGeneric) Len() int
func (*EVPNGeneric) PathID ¶
func (e *EVPNGeneric) PathID() uint32
func (*EVPNGeneric) RD ¶
func (e *EVPNGeneric) RD() RouteDistinguisher
func (*EVPNGeneric) RouteType ¶
func (e *EVPNGeneric) RouteType() EVPNRouteType
func (*EVPNGeneric) String ¶
func (e *EVPNGeneric) String() string
func (*EVPNGeneric) SupportsAddPath ¶
func (e *EVPNGeneric) SupportsAddPath() bool
func (*EVPNGeneric) WriteTo ¶
func (e *EVPNGeneric) WriteTo(buf []byte, off int) int
WriteTo writes the full [route-type][length][body] encoding, like every other EVPN type, and returns the total written.
It used to copy only the body, which broke the two contracts its callers rely on: Len() promised len(data)+2, so plugin.go's `make([]byte, Len())` + WriteTo left two trailing zero octets on the wire; and appendRawField (json.go) skips `scratch[:2]` to drop the header, so the JSON "raw" field lost the first two octets of the body instead.
e.data comes from ParseEVPN, where the length is a single octet, so it cannot exceed 255.
type EVPNRouteType ¶
type EVPNRouteType uint8
EVPNRouteType identifies the EVPN route type. RFC 7432 Section 7 defines the EVPN NLRI format.
const ( EVPNRouteType1 EVPNRouteType = 1 // Ethernet Auto-Discovery (RFC 7432 Section 7.1) EVPNRouteType2 EVPNRouteType = 2 // MAC/IP Advertisement (RFC 7432 Section 7.2) EVPNRouteType3 EVPNRouteType = 3 // Inclusive Multicast Ethernet Tag (RFC 7432 Section 7.3) EVPNRouteType4 EVPNRouteType = 4 // Ethernet Segment (RFC 7432 Section 7.4) EVPNRouteType5 EVPNRouteType = 5 // IP Prefix (RFC 9136 Section 3) )
EVPN Route Types per RFC 7432 Section 7 and RFC 9136.
func (EVPNRouteType) String ¶
func (t EVPNRouteType) String() string
String returns the route type name.
type EVPNType1 ¶
type EVPNType1 struct {
// contains filtered or unexported fields
}
EVPNType1 represents an Ethernet Auto-Discovery route (RFC 7432 Section 7.1).
func NewEVPNType1 ¶
func NewEVPNType1(rd RouteDistinguisher, esi [10]byte, ethernetTag uint32, labels []uint32) *EVPNType1
NewEVPNType1 creates an Ethernet Auto-Discovery route (Type 1).
func (*EVPNType1) AppendJSON ¶
AppendJSON for EVPNType1 (Ethernet Auto-Discovery). Keys: code, esi, ethernet-tag, label, name, parsed, raw, rd.
func (*EVPNType1) Bytes ¶
Bytes returns a standalone wire encoding. Retained for JSON / test callers that need an owned slice; hot-path senders should call WriteTo directly into a pool buffer.
func (*EVPNType1) EthernetTag ¶
func (*EVPNType1) RD ¶
func (e *EVPNType1) RD() RouteDistinguisher
func (*EVPNType1) RouteType ¶
func (e *EVPNType1) RouteType() EVPNRouteType
func (*EVPNType1) SupportsAddPath ¶
type EVPNType2 ¶
type EVPNType2 struct {
// contains filtered or unexported fields
}
EVPNType2 represents a MAC/IP Advertisement route (RFC 7432 Section 7.2).
func NewEVPNType2 ¶
func NewEVPNType2(rd RouteDistinguisher, esi [10]byte, ethernetTag uint32, mac [6]byte, ip netip.Addr, labels []uint32) *EVPNType2
NewEVPNType2 creates a MAC/IP Advertisement route (Type 2).
func (*EVPNType2) AppendJSON ¶
AppendJSON for EVPNType2 (MAC/IP advertisement). Keys: code, esi, ethernet-tag, ip (optional), label, mac, name, parsed, raw, rd.
func (*EVPNType2) Bytes ¶
Bytes returns a standalone wire encoding. Retained for JSON / test callers; hot-path senders should call WriteTo into a pool buffer.
func (*EVPNType2) EthernetTag ¶
func (*EVPNType2) RD ¶
func (e *EVPNType2) RD() RouteDistinguisher
func (*EVPNType2) RouteType ¶
func (e *EVPNType2) RouteType() EVPNRouteType
func (*EVPNType2) SupportsAddPath ¶
type EVPNType3 ¶
type EVPNType3 struct {
// contains filtered or unexported fields
}
EVPNType3 represents an Inclusive Multicast Ethernet Tag route (RFC 7432 Section 7.3).
func NewEVPNType3 ¶
func NewEVPNType3(rd RouteDistinguisher, ethernetTag uint32, originatorIP netip.Addr) *EVPNType3
NewEVPNType3 creates an Inclusive Multicast Ethernet Tag route (Type 3).
func (*EVPNType3) AppendJSON ¶
AppendJSON for EVPNType3 (Inclusive Multicast Ethernet Tag). Keys: code, ethernet-tag, name, originator, parsed, raw, rd.
func (*EVPNType3) Bytes ¶
Bytes returns a standalone wire encoding. Retained for JSON / test callers; hot-path senders should call WriteTo into a pool buffer.
func (*EVPNType3) EthernetTag ¶
func (*EVPNType3) OriginatorIP ¶
func (*EVPNType3) RD ¶
func (e *EVPNType3) RD() RouteDistinguisher
func (*EVPNType3) RouteType ¶
func (e *EVPNType3) RouteType() EVPNRouteType
func (*EVPNType3) SupportsAddPath ¶
type EVPNType4 ¶
type EVPNType4 struct {
// contains filtered or unexported fields
}
EVPNType4 represents an Ethernet Segment route (RFC 7432 Section 7.4).
func NewEVPNType4 ¶
func NewEVPNType4(rd RouteDistinguisher, esi [10]byte, originatorIP netip.Addr) *EVPNType4
NewEVPNType4 creates an Ethernet Segment route (Type 4).
func (*EVPNType4) AppendJSON ¶
AppendJSON for EVPNType4 (Ethernet Segment). Keys: code, esi, name, originator, parsed, raw, rd.
func (*EVPNType4) Bytes ¶
Bytes returns a standalone wire encoding. Retained for JSON / test callers; hot-path senders should call WriteTo into a pool buffer.
func (*EVPNType4) OriginatorIP ¶
func (*EVPNType4) RD ¶
func (e *EVPNType4) RD() RouteDistinguisher
func (*EVPNType4) RouteType ¶
func (e *EVPNType4) RouteType() EVPNRouteType
func (*EVPNType4) SupportsAddPath ¶
type EVPNType5 ¶
type EVPNType5 struct {
// contains filtered or unexported fields
}
EVPNType5 represents an IP Prefix route (RFC 9136 Section 3).
func NewEVPNType5 ¶
func NewEVPNType5(rd RouteDistinguisher, esi [10]byte, ethernetTag uint32, prefix netip.Prefix, gateway netip.Addr, labels []uint32) *EVPNType5
NewEVPNType5 creates an IP Prefix route (Type 5).
func (*EVPNType5) AppendJSON ¶
AppendJSON for EVPNType5 (IP Prefix). Keys: code, esi, ethernet-tag, gateway (optional), label, name, parsed, prefix, raw, rd.
func (*EVPNType5) Bytes ¶
Bytes returns a standalone wire encoding. Retained for JSON / test callers; hot-path senders should call WriteTo into a pool buffer.
func (*EVPNType5) EthernetTag ¶
func (*EVPNType5) RD ¶
func (e *EVPNType5) RD() RouteDistinguisher
func (*EVPNType5) RouteType ¶
func (e *EVPNType5) RouteType() EVPNRouteType
func (*EVPNType5) SupportsAddPath ¶
type RouteDistinguisher ¶
type RouteDistinguisher = nlri.RouteDistinguisher
Type aliases for nlri types used by EVPN.