From 094c01506bf53eb90b413866a4ed02c231e2bb09 Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Wed, 1 Nov 2017 13:09:50 +0900 Subject: packet/bgp: Remove non route key fields from string RFC7432 and draft-ietf-bess-evpn-prefix-advertisement says some fields in EVPN NLRIs (e.g., MPLS Label(s)) should no be treated as the route key, but currently, GoBGP's string representations of EVPN NLRIs include all fields. So the paths should be treated as the same (e.g., only different in MPLS Label and other field is the same) can be treated as the different. This patch removes non route key fields from NLRI string representation and fixes this problem. Signed-off-by: IWASE Yusuke --- packet/bgp/bgp.go | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'packet') diff --git a/packet/bgp/bgp.go b/packet/bgp/bgp.go index babfd96f..ebab8712 100644 --- a/packet/bgp/bgp.go +++ b/packet/bgp/bgp.go @@ -2055,7 +2055,13 @@ func (er *EVPNEthernetAutoDiscoveryRoute) Serialize() ([]byte, error) { } func (er *EVPNEthernetAutoDiscoveryRoute) String() string { - return fmt.Sprintf("[type:A-D][rd:%s][esi:%s][etag:%d][label:%d]", er.RD, er.ESI.String(), er.ETag, er.Label) + // RFC7432: BGP MPLS-Based Ethernet VPN + // 7.1. Ethernet Auto-discovery Route + // For the purpose of BGP route key processing, only the Ethernet + // Segment Identifier and the Ethernet Tag ID are considered to be part + // of the prefix in the NLRI. The MPLS Label field is to be treated as + // a route attribute as opposed to being part of the route. + return fmt.Sprintf("[type:A-D][rd:%s][esi:%s][etag:%d]", er.RD, er.ESI.String(), er.ETag) } func (er *EVPNEthernetAutoDiscoveryRoute) MarshalJSON() ([]byte, error) { @@ -2165,7 +2171,15 @@ func (er *EVPNMacIPAdvertisementRoute) Serialize() ([]byte, error) { } func (er *EVPNMacIPAdvertisementRoute) String() string { - return fmt.Sprintf("[type:macadv][rd:%s][esi:%s][etag:%d][mac:%s][ip:%s][labels:%v]", er.RD, er.ESI.String(), er.ETag, er.MacAddress, er.IPAddress, er.Labels) + // RFC7432: BGP MPLS-Based Ethernet VPN + // 7.2. MAC/IP Advertisement Route + // For the purpose of BGP route key processing, only the Ethernet Tag + // ID, MAC Address Length, MAC Address, IP Address Length, and IP + // Address fields are considered to be part of the prefix in the NLRI. + // The Ethernet Segment Identifier, MPLS Label1, and MPLS Label2 fields + // are to be treated as route attributes as opposed to being part of the + // "route". + return fmt.Sprintf("[type:macadv][rd:%s][etag:%d][mac:%s][ip:%s]", er.RD, er.ETag, er.MacAddress, er.IPAddress) } func (er *EVPNMacIPAdvertisementRoute) MarshalJSON() ([]byte, error) { @@ -2241,6 +2255,12 @@ func (er *EVPNMulticastEthernetTagRoute) Serialize() ([]byte, error) { } func (er *EVPNMulticastEthernetTagRoute) String() string { + // RFC7432: BGP MPLS-Based Ethernet VPN + // 7.3. Inclusive Multicast Ethernet Tag Route + // ...(snip)... For the purpose of BGP route key + // processing, only the Ethernet Tag ID, IP Address Length, and + // Originating Router's IP Address fields are considered to be part of + // the prefix in the NLRI. return fmt.Sprintf("[type:multicast][rd:%s][etag:%d][ip:%s]", er.RD, er.ETag, er.IPAddress) } @@ -2311,6 +2331,11 @@ func (er *EVPNEthernetSegmentRoute) Serialize() ([]byte, error) { } func (er *EVPNEthernetSegmentRoute) String() string { + // RFC7432: BGP MPLS-Based Ethernet VPN + // 7.4. Ethernet Segment Route + // For the purpose of BGP route key processing, only the Ethernet + // Segment ID, IP Address Length, and Originating Router's IP Address + // fields are considered to be part of the prefix in the NLRI. return fmt.Sprintf("[type:esi][rd:%s][esi:%d][ip:%s]", er.RD, er.ESI, er.IPAddress) } @@ -2420,7 +2445,12 @@ func (er *EVPNIPPrefixRoute) Serialize() ([]byte, error) { } func (er *EVPNIPPrefixRoute) String() string { - return fmt.Sprintf("[type:Prefix][rd:%s][esi:%s][etag:%d][prefix:%s/%d][gw:%s][label:%d]", er.RD, er.ESI.String(), er.ETag, er.IPPrefix, er.IPPrefixLength, er.GWIPAddress, er.Label) + // draft-ietf-bess-evpn-prefix-advertisement: IP Prefix Advertisement in EVPN + // 3.1 IP Prefix Route Encoding + // The RD, Eth-Tag ID, IP Prefix Length and IP Prefix will be part of + // the route key used by BGP to compare routes. The rest of the fields + // will not be part of the route key. + return fmt.Sprintf("[type:Prefix][rd:%s][etag:%d][prefix:%s/%d]", er.RD, er.ETag, er.IPPrefix, er.IPPrefixLength) } func (er *EVPNIPPrefixRoute) MarshalJSON() ([]byte, error) { -- cgit v1.2.3