diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/grpc_server.go | 2 | ||||
-rw-r--r-- | server/peer.go | 27 |
2 files changed, 29 insertions, 0 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go index 01acaf3d..c218a4ac 100644 --- a/server/grpc_server.go +++ b/server/grpc_server.go @@ -56,6 +56,8 @@ func convertAf2Rf(af *api.AddressFamily) (bgp.RouteFamily, error) { return bgp.RF_EVPN, nil } else if af.Equal(api.AF_ENCAP) { return bgp.RF_ENCAP, nil + } else if af.Equal(api.AF_RTC) { + return bgp.RF_RTC_UC, nil } return bgp.RouteFamily(0), fmt.Errorf("unsupported address family: %v", af) diff --git a/server/peer.go b/server/peer.go index 64235613..7af2653e 100644 --- a/server/peer.go +++ b/server/peer.go @@ -422,6 +422,33 @@ func (peer *Peer) handleGrpc(grpcReq *GrpcRequest) { } }(path.Attrs) + case bgp.RF_RTC_UC: + var ec bgp.ExtendedCommunityInterface + target := path.Nlri.RtNlri.Target + ec_type := target.Type + ec_subtype := target.Subtype + switch ec_type { + case api.EXTENDED_COMMUNITIE_TYPE_TWO_OCTET_AS_SPECIFIC: + if target.Asn == 0 && target.LocalAdmin == 0 { + break + } + ec = &bgp.TwoOctetAsSpecificExtended{ + SubType: bgp.ExtendedCommunityAttrSubType(ec_subtype), + AS: uint16(target.Asn), + LocalAdmin: target.LocalAdmin, + IsTransitive: true, + } + default: + result.ResponseErr = fmt.Errorf("Invalid endpoint ip address: %s", path.Nlri.Prefix) + grpcReq.ResponseCh <- result + close(grpcReq.ResponseCh) + return + } + + nlri = bgp.NewRouteTargetMembershipNLRI(peer.globalConfig.As, ec) + + pattr = append(pattr, bgp.NewPathAttributeMpReachNLRI("0.0.0.0", []bgp.AddrPrefixInterface{nlri})) + default: result.ResponseErr = fmt.Errorf("Unsupported address family: %s", rf) grpcReq.ResponseCh <- result |