summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-11-16 11:24:22 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-11-21 10:56:23 +0900
commit511535e130cf3c187662f6662a4a6d58421475aa (patch)
tree2704df95189c981067900a4865d4e8311d709fed
parentbbd560c2ebd31f7e086ac8862050867f97f742d2 (diff)
server: Auto derived ES-Import RT for EVPN Ethernet Segment route
According to RFC7432, the ES-Import RT can be derived automatically when using the ESI Types 1, 2 and 3. This patch enables to derive automatically the ES-Import RT for the given path from BgpServer's API. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
-rw-r--r--server/server.go39
1 files changed, 30 insertions, 9 deletions
diff --git a/server/server.go b/server/server.go
index 7d6194f4..050ab81d 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1285,20 +1285,41 @@ func (server *BgpServer) fixupApiPath(vrfId string, pathList []*table.Path) erro
}
}
- if path.GetRouteFamily() == bgp.RF_EVPN {
- nlri := path.GetNlri()
- evpnNlri := nlri.(*bgp.EVPNNLRI)
- if evpnNlri.RouteType == bgp.EVPN_ROUTE_TYPE_MAC_IP_ADVERTISEMENT {
- macIpAdv := evpnNlri.RouteTypeData.(*bgp.EVPNMacIPAdvertisementRoute)
- etag := macIpAdv.ETag
- mac := macIpAdv.MacAddress
+ // Address Family specific Handling
+ switch nlri := path.GetNlri().(type) {
+ case *bgp.EVPNNLRI:
+ switch r := nlri.RouteTypeData.(type) {
+ case *bgp.EVPNMacIPAdvertisementRoute:
+ // MAC Mobility Extended Community
paths := server.globalRib.GetBestPathList(table.GLOBAL_RIB_NAME, []bgp.RouteFamily{bgp.RF_EVPN})
- if m := getMacMobilityExtendedCommunity(etag, mac, paths); m != nil {
+ if m := getMacMobilityExtendedCommunity(r.ETag, r.MacAddress, paths); m != nil {
path.SetExtCommunities([]bgp.ExtendedCommunityInterface{m}, false)
}
+ case *bgp.EVPNEthernetSegmentRoute:
+ // RFC7432: BGP MPLS-Based Ethernet VPN
+ // 7.6. ES-Import Route Target
+ // The value is derived automatically for the ESI Types 1, 2,
+ // and 3, by encoding the high-order 6-octet portion of the 9-octet ESI
+ // Value, which corresponds to a MAC address, in the ES-Import Route
+ // Target.
+ // Note: If the given path already has the ES-Import Route Target,
+ // skips deriving a new one.
+ found := false
+ for _, extComm := range path.GetExtCommunities() {
+ if _, found = extComm.(*bgp.ESImportRouteTarget); found {
+ break
+ }
+ }
+ if !found {
+ switch r.ESI.Type {
+ case bgp.ESI_LACP, bgp.ESI_MSTP, bgp.ESI_MAC:
+ mac := net.HardwareAddr(r.ESI.Value[0:6])
+ rt := &bgp.ESImportRouteTarget{ESImport: mac}
+ path.SetExtCommunities([]bgp.ExtendedCommunityInterface{rt}, false)
+ }
+ }
}
}
-
}
return nil
}