Skip to content
Snippets Groups Projects
Commit bab19735 authored by Oliver Herms's avatar Oliver Herms
Browse files

RIS: Add option to specify VRF in human readable form

parent cb622cba
No related branches found
No related tags found
No related merge requests found
......@@ -77,6 +77,7 @@ func (DumpRIBRequest_AFISAFI) EnumDescriptor() ([]byte, []int) {
type LPMRequest struct {
Router string `protobuf:"bytes,1,opt,name=router,proto3" json:"router,omitempty"`
VrfId uint64 `protobuf:"varint,2,opt,name=vrf_id,json=vrfId,proto3" json:"vrf_id,omitempty"`
Vrf string `protobuf:"bytes,4,opt,name=vrf,proto3" json:"vrf,omitempty"`
Pfx *api.Prefix `protobuf:"bytes,3,opt,name=pfx,proto3" json:"pfx,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
......@@ -122,6 +123,13 @@ func (m *LPMRequest) GetVrfId() uint64 {
return 0
}
func (m *LPMRequest) GetVrf() string {
if m != nil {
return m.Vrf
}
return ""
}
func (m *LPMRequest) GetPfx() *api.Prefix {
if m != nil {
return m.Pfx
......@@ -171,6 +179,7 @@ func (m *LPMResponse) GetRoutes() []*api1.Route {
type GetRequest struct {
Router string `protobuf:"bytes,1,opt,name=router,proto3" json:"router,omitempty"`
VrfId uint64 `protobuf:"varint,2,opt,name=vrf_id,json=vrfId,proto3" json:"vrf_id,omitempty"`
Vrf string `protobuf:"bytes,4,opt,name=vrf,proto3" json:"vrf,omitempty"`
Pfx *api.Prefix `protobuf:"bytes,3,opt,name=pfx,proto3" json:"pfx,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
......@@ -216,6 +225,13 @@ func (m *GetRequest) GetVrfId() uint64 {
return 0
}
func (m *GetRequest) GetVrf() string {
if m != nil {
return m.Vrf
}
return ""
}
func (m *GetRequest) GetPfx() *api.Prefix {
if m != nil {
return m.Pfx
......@@ -265,6 +281,7 @@ func (m *GetResponse) GetRoutes() []*api1.Route {
type GetLongerRequest struct {
Router string `protobuf:"bytes,1,opt,name=router,proto3" json:"router,omitempty"`
VrfId uint64 `protobuf:"varint,2,opt,name=vrf_id,json=vrfId,proto3" json:"vrf_id,omitempty"`
Vrf string `protobuf:"bytes,4,opt,name=vrf,proto3" json:"vrf,omitempty"`
Pfx *api.Prefix `protobuf:"bytes,3,opt,name=pfx,proto3" json:"pfx,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
......@@ -310,6 +327,13 @@ func (m *GetLongerRequest) GetVrfId() uint64 {
return 0
}
func (m *GetLongerRequest) GetVrf() string {
if m != nil {
return m.Vrf
}
return ""
}
func (m *GetLongerRequest) GetPfx() *api.Prefix {
if m != nil {
return m.Pfx
......@@ -359,6 +383,7 @@ func (m *GetLongerResponse) GetRoutes() []*api1.Route {
type ObserveRIBRequest struct {
Router string `protobuf:"bytes,1,opt,name=router,proto3" json:"router,omitempty"`
VrfId uint64 `protobuf:"varint,2,opt,name=vrf_id,json=vrfId,proto3" json:"vrf_id,omitempty"`
Vrf string `protobuf:"bytes,4,opt,name=vrf,proto3" json:"vrf,omitempty"`
Afisafi ObserveRIBRequest_AFISAFI `protobuf:"varint,3,opt,name=afisafi,proto3,enum=bio.ris.ObserveRIBRequest_AFISAFI" json:"afisafi,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
......@@ -404,6 +429,13 @@ func (m *ObserveRIBRequest) GetVrfId() uint64 {
return 0
}
func (m *ObserveRIBRequest) GetVrf() string {
if m != nil {
return m.Vrf
}
return ""
}
func (m *ObserveRIBRequest) GetAfisafi() ObserveRIBRequest_AFISAFI {
if m != nil {
return m.Afisafi
......@@ -708,49 +740,49 @@ func init() {
}
var fileDescriptor_ffe1202aa518913f = []byte{
// 659 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4d, 0x4f, 0xdb, 0x4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 0x70, 0xab, 0x20, 0xa4,
0xf9, 0xf0, 0x5a, 0x5f, 0x16, 0xe8, 0x10, 0x2a, 0xd9, 0x44, 0xe3, 0x8d, 0xfc, 0xdd, 0xc2, 0x2e,
0x31, 0xcd, 0xeb, 0x5c, 0x59, 0x94, 0x37, 0x00, 0xd3, 0xd9, 0xcb, 0xd1, 0xb9, 0x32, 0x90, 0x26,
0x9e, 0x0a, 0x3b, 0x19, 0xac, 0x1d, 0x84, 0x5f, 0x82, 0x91, 0xb6, 0x0e, 0x5e, 0xff, 0x4d, 0x73,
0x9a, 0x6b, 0x57, 0x1d, 0xf1, 0xc5, 0x78, 0x07, 0x1d, 0x6c, 0x7f, 0xdc, 0xfa, 0xeb, 0x27, 0xad,
0x5f, 0x56, 0x0f, 0xcc, 0xee, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x57, 0x19, 0x12, 0xf0, 0x06,
0x07, 0x00, 0x00,
// 670 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x5d, 0x4f, 0xdb, 0x3c,
0x14, 0x26, 0x04, 0x1a, 0x7a, 0xfa, 0x42, 0x8b, 0x79, 0x79, 0x09, 0x79, 0x2f, 0xd6, 0x45, 0x13,
0x2a, 0x42, 0x4b, 0x51, 0x99, 0x98, 0xa6, 0x7d, 0x09, 0x84, 0xa8, 0x22, 0xc1, 0x56, 0x19, 0xb1,
0x8b, 0xdd, 0x54, 0x69, 0xe3, 0x30, 0x4b, 0xe4, 0x63, 0xb6, 0x1b, 0xd1, 0xcb, 0xfd, 0x82, 0xfd,
0x8c, 0xfd, 0x8c, 0xfd, 0xb5, 0x29, 0x76, 0x9a, 0xa6, 0x83, 0xb1, 0xb1, 0x4d, 0xdc, 0xb4, 0xf6,
0x39, 0x7e, 0x7c, 0x9e, 0xe7, 0xd1, 0xf1, 0x09, 0xec, 0x5d, 0x50, 0xf1, 0x61, 0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9f, 0xc6, 0x41, 0x45, 0x7e, 0xa8, 0xf6,
0xbe, 0x05, 0x00, 0x00, 0xff, 0xff, 0xc5, 0xf1, 0x19, 0x78, 0x4e, 0x07, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
......
......@@ -18,6 +18,7 @@ service RoutingInformationService {
message LPMRequest {
string router = 1;
uint64 vrf_id = 2;
string vrf = 4;
bio.net.Prefix pfx = 3;
}
......@@ -28,6 +29,7 @@ message LPMResponse {
message GetRequest {
string router = 1;
uint64 vrf_id = 2;
string vrf = 4;
bio.net.Prefix pfx = 3;
}
......@@ -38,6 +40,7 @@ message GetResponse {
message GetLongerRequest {
string router = 1;
uint64 vrf_id = 2;
string vrf = 4;
bio.net.Prefix pfx = 3;
}
......@@ -48,6 +51,7 @@ message GetLongerResponse {
message ObserveRIBRequest {
string router = 1;
uint64 vrf_id = 2;
string vrf = 4;
enum AFISAFI {
IPv4Unicast = 0;
IPv6Unicast = 1;
......
......@@ -88,9 +88,14 @@ func (s Server) getRIB(rtr string, vrfID uint64, ipVersion netapi.IP_Version) (*
// LPM provides a longest prefix match service
func (s *Server) LPM(ctx context.Context, req *pb.LPMRequest) (*pb.LPMResponse, error) {
rib, err := s.getRIB(req.Router, req.VrfId, req.Pfx.Address.Version)
vrfID, err := getVRF(req)
if err != nil {
return nil, wrapGetRIBErr(err, req.Router, req.VrfId, req.Pfx.Address.Version)
return nil, err
}
rib, err := s.getRIB(req.Router, vrfID, req.Pfx.Address.Version)
if err != nil {
return nil, wrapGetRIBErr(err, req.Router, vrfID, req.Pfx.Address.Version)
}
routes := rib.LPM(bnet.NewPrefixFromProtoPrefix(req.Pfx))
......@@ -106,9 +111,14 @@ func (s *Server) LPM(ctx context.Context, req *pb.LPMRequest) (*pb.LPMResponse,
// Get gets a prefix (exact match)
func (s *Server) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse, error) {
rib, err := s.getRIB(req.Router, req.VrfId, req.Pfx.Address.Version)
vrfID, err := getVRF(req)
if err != nil {
return nil, err
}
rib, err := s.getRIB(req.Router, vrfID, req.Pfx.Address.Version)
if err != nil {
return nil, wrapGetRIBErr(err, req.Router, req.VrfId, req.Pfx.Address.Version)
return nil, wrapGetRIBErr(err, req.Router, vrfID, req.Pfx.Address.Version)
}
route := rib.Get(bnet.NewPrefixFromProtoPrefix(req.Pfx))
......@@ -127,9 +137,14 @@ func (s *Server) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse,
// GetLonger gets all more specifics of a prefix
func (s *Server) GetLonger(ctx context.Context, req *pb.GetLongerRequest) (*pb.GetLongerResponse, error) {
rib, err := s.getRIB(req.Router, req.VrfId, req.Pfx.Address.Version)
vrfID, err := getVRF(req)
if err != nil {
return nil, wrapGetRIBErr(err, req.Router, req.VrfId, req.Pfx.Address.Version)
return nil, err
}
rib, err := s.getRIB(req.Router, vrfID, req.Pfx.Address.Version)
if err != nil {
return nil, wrapGetRIBErr(err, req.Router, vrfID, req.Pfx.Address.Version)
}
routes := rib.GetLonger(bnet.NewPrefixFromProtoPrefix(req.Pfx))
......@@ -145,6 +160,11 @@ func (s *Server) GetLonger(ctx context.Context, req *pb.GetLongerRequest) (*pb.G
// ObserveRIB implements the ObserveRIB RPC
func (s *Server) ObserveRIB(req *pb.ObserveRIBRequest, stream pb.RoutingInformationService_ObserveRIBServer) error {
vrfID, err := getVRF(req)
if err != nil {
return err
}
ipVersion := netapi.IP_IPv4
switch req.Afisafi {
case pb.ObserveRIBRequest_IPv4Unicast:
......@@ -155,9 +175,9 @@ func (s *Server) ObserveRIB(req *pb.ObserveRIBRequest, stream pb.RoutingInformat
return fmt.Errorf("Unknown AFI/SAFI")
}
rib, err := s.getRIB(req.Router, req.VrfId, ipVersion)
rib, err := s.getRIB(req.Router, vrfID, ipVersion)
if err != nil {
return wrapGetRIBErr(err, req.Router, req.VrfId, ipVersion)
return wrapGetRIBErr(err, req.Router, vrfID, ipVersion)
}
risObserveFIBClients.WithLabelValues(req.Router, fmt.Sprintf("%d", req.VrfId), fmt.Sprintf("%d", req.Afisafi)).Inc()
......@@ -250,6 +270,24 @@ func (s *Server) GetRouters(c context.Context, request *pb.GetRoutersRequest) (*
return resp, nil
}
type RequestWithVRF interface {
GetVrfId() uint64
GetVrf() string
}
func getVRF(req RequestWithVRF) (uint64, error) {
if req.GetVrf() != "" {
vrfID, err := vrf.ParseHumanReadableRouteDistinguisher(req.GetVrf())
if err != nil {
return 0, errors.Wrap(err, "Unable to parse VRF")
}
return vrfID, nil
}
return req.GetVrfId(), nil
}
type update struct {
advertisement bool
prefix net.Prefix
......
......@@ -15,9 +15,10 @@ require (
github.com/urfave/cli v1.21.0
github.com/vishvananda/netlink v1.0.0
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc // indirect
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20200714190737-9048b464a08d // indirect
google.golang.org/genproto v0.0.0-20200413115906-b5235f65be36 // indirect
google.golang.org/grpc v1.28.0
google.golang.org/protobuf v1.21.0
......
......@@ -98,33 +98,48 @@ github.com/vishvananda/netlink v1.0.0 h1:bqNY2lgheFIu1meHUFSH3d7vG93AFyqg3oGbJCO
github.com/vishvananda/netlink v1.0.0/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc h1:R83G5ikgLMxrBvLh22JhdfI8K6YXEPHx5P03Uu3DRs4=
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 h1:dfGZHvZk057jK2MCeWus/TowKpJ8y4AmooUzdBSR9GU=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 h1:opSr2sbRXk5X5/givKrrKj9HXxFpW2sdCiP8MJSKLQY=
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
......@@ -136,7 +151,14 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 h1:5Beo0mZN8dRzgrMMkDp0jc8YXQKx9DiJ2k1dkvGsn5A=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200714190737-9048b464a08d h1:hYhnolbefSSt3WZp66sgmgnEOFv5PD6a5PIcnKJ8jdU=
golang.org/x/tools v0.0.0-20200714190737-9048b464a08d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
......
......@@ -2,9 +2,12 @@ package vrf
import (
"fmt"
"strconv"
"strings"
"sync"
"github.com/bio-routing/bio-rd/routingtable/locRIB"
"github.com/pkg/errors"
)
const (
......@@ -147,3 +150,28 @@ func RouteDistinguisherHumanReadable(rdi uint64) string {
return fmt.Sprintf("%d:%d", asn, netID)
}
// ParseHumanReadableRouteDistinguisher parses a human readable route distinguisher
func ParseHumanReadableRouteDistinguisher(x string) (uint64, error) {
parts := strings.Split(x, ":")
if len(parts) != 2 {
return 0, fmt.Errorf("Invalid format")
}
asn, err := strconv.Atoi(parts[0])
if err != nil {
return 0, errors.Wrap(err, "Unable to convert first part to int")
}
netID, err := strconv.Atoi(parts[1])
if err != nil {
return 0, errors.Wrap(err, "Unable to convert second part to int")
}
ret := uint64(0)
ret = uint64(asn)
ret = ret << 32
ret += uint64(netID)
return ret, nil
}
......@@ -95,3 +95,39 @@ func TestRouteDistinguisherHumanReadable(t *testing.T) {
assert.Equal(t, test.expected, res, test.name)
}
}
func TestParseHumanReadableRouteDistinguisher(t *testing.T) {
tests := []struct {
name string
input string
expected uint64
wantFail bool
}{
{
name: "Test #1",
input: "51324:65201",
expected: 0x0000C87C0000FEB1,
wantFail: false,
},
{
name: "Test #2",
input: "51324",
wantFail: true,
},
}
for _, test := range tests {
res, err := ParseHumanReadableRouteDistinguisher(test.input)
if !test.wantFail && err != nil {
t.Errorf("Unexpected failure for test %q", test.name)
continue
}
if test.wantFail && err == nil {
t.Errorf("Unexpected success for test %q", test.name)
continue
}
assert.Equal(t, test.expected, res, test.name)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment