From a4f5772555f017fdfde44c5a352c5ae42eb207eb Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Wed, 28 Aug 2019 08:41:19 +0100 Subject: [PATCH] add network field to the routes --- network/default.go | 2 + router/handler/router.go | 4 ++ router/handler/table.go | 5 ++ router/proto/router.pb.go | 101 +++++++++++++++++++++----------------- router/proto/router.proto | 6 ++- 5 files changed, 70 insertions(+), 48 deletions(-) diff --git a/network/default.go b/network/default.go index 951221ba..8a612394 100644 --- a/network/default.go +++ b/network/default.go @@ -194,6 +194,7 @@ func (n *network) process(l tunnel.Listener) { Address: event.Route.Address, Gateway: event.Route.Gateway, Network: event.Route.Network, + Router: event.Route.Router, Link: event.Route.Link, Metric: int(event.Route.Metric), } @@ -238,6 +239,7 @@ func (n *network) advertise(client transport.Client, advertChan <-chan *router.A Address: event.Route.Address, Gateway: n.options.Address, Network: event.Route.Network, + Router: event.Route.Router, Link: DefaultLink, Metric: int64(event.Route.Metric), } diff --git a/router/handler/router.go b/router/handler/router.go index a7571024..ac05f012 100644 --- a/router/handler/router.go +++ b/router/handler/router.go @@ -33,6 +33,7 @@ func (r *Router) Lookup(ctx context.Context, req *pb.LookupRequest, resp *pb.Loo Address: route.Address, Gateway: route.Gateway, Network: route.Network, + Router: route.Router, Link: route.Link, Metric: int64(route.Metric), } @@ -58,6 +59,7 @@ func (r *Router) Advertise(ctx context.Context, req *pb.Request, stream pb.Route Address: event.Route.Address, Gateway: event.Route.Gateway, Network: event.Route.Network, + Router: event.Route.Router, Link: event.Route.Link, Metric: int64(event.Route.Metric), } @@ -97,6 +99,7 @@ func (r *Router) Process(ctx context.Context, req *pb.Advert, rsp *pb.ProcessRes Address: event.Route.Address, Gateway: event.Route.Gateway, Network: event.Route.Network, + Router: event.Route.Router, Link: event.Route.Link, Metric: int(event.Route.Metric), } @@ -161,6 +164,7 @@ func (r *Router) Watch(ctx context.Context, req *pb.WatchRequest, stream pb.Rout Address: event.Route.Address, Gateway: event.Route.Gateway, Network: event.Route.Network, + Router: event.Route.Router, Link: event.Route.Link, Metric: int64(event.Route.Metric), } diff --git a/router/handler/table.go b/router/handler/table.go index ad17fa51..63e3c96c 100644 --- a/router/handler/table.go +++ b/router/handler/table.go @@ -18,6 +18,7 @@ func (t *Table) Create(ctx context.Context, route *pb.Route, resp *pb.CreateResp Address: route.Address, Gateway: route.Gateway, Network: route.Network, + Router: route.Router, Link: route.Link, Metric: int(route.Metric), }) @@ -34,6 +35,7 @@ func (t *Table) Update(ctx context.Context, route *pb.Route, resp *pb.UpdateResp Address: route.Address, Gateway: route.Gateway, Network: route.Network, + Router: route.Router, Link: route.Link, Metric: int(route.Metric), }) @@ -50,6 +52,7 @@ func (t *Table) Delete(ctx context.Context, route *pb.Route, resp *pb.DeleteResp Address: route.Address, Gateway: route.Gateway, Network: route.Network, + Router: route.Router, Link: route.Link, Metric: int(route.Metric), }) @@ -74,6 +77,7 @@ func (t *Table) List(ctx context.Context, req *pb.Request, resp *pb.ListResponse Address: route.Address, Gateway: route.Gateway, Network: route.Network, + Router: route.Router, Link: route.Link, Metric: int64(route.Metric), } @@ -102,6 +106,7 @@ func (t *Table) Query(ctx context.Context, req *pb.QueryRequest, resp *pb.QueryR Address: route.Address, Gateway: route.Gateway, Network: route.Network, + Router: route.Router, Link: route.Link, Metric: int64(route.Metric), } diff --git a/router/proto/router.pb.go b/router/proto/router.pb.go index c448e484..6dedf13d 100644 --- a/router/proto/router.pb.go +++ b/router/proto/router.pb.go @@ -672,10 +672,12 @@ type Route struct { Gateway string `protobuf:"bytes,3,opt,name=gateway,proto3" json:"gateway,omitempty"` // the network for this destination Network string `protobuf:"bytes,4,opt,name=network,proto3" json:"network,omitempty"` + // router if the router id + Router string `protobuf:"bytes,5,opt,name=router,proto3" json:"router,omitempty"` // the network link - Link string `protobuf:"bytes,5,opt,name=link,proto3" json:"link,omitempty"` + Link string `protobuf:"bytes,6,opt,name=link,proto3" json:"link,omitempty"` // the metric / score of this route - Metric int64 `protobuf:"varint,6,opt,name=metric,proto3" json:"metric,omitempty"` + Metric int64 `protobuf:"varint,7,opt,name=metric,proto3" json:"metric,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -734,6 +736,13 @@ func (m *Route) GetNetwork() string { return "" } +func (m *Route) GetRouter() string { + if m != nil { + return m.Router + } + return "" +} + func (m *Route) GetLink() string { if m != nil { return m.Link @@ -861,51 +870,51 @@ func init() { } var fileDescriptor_6a36eee0b1adf739 = []byte{ - // 689 bytes of a gzipped FileDescriptorProto + // 699 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcd, 0x4e, 0xdb, 0x40, - 0x10, 0xb6, 0x93, 0xd8, 0x28, 0xd3, 0x10, 0xdc, 0x51, 0x05, 0x56, 0x5a, 0x20, 0xf2, 0x29, 0x42, - 0xd4, 0xa9, 0xd2, 0x6b, 0xff, 0x02, 0xa5, 0xaa, 0x54, 0x0e, 0xad, 0x0b, 0xea, 0xd9, 0xd8, 0x23, - 0x6a, 0x91, 0xd8, 0x66, 0x77, 0x03, 0xca, 0xb9, 0x8f, 0xd1, 0x27, 0xe8, 0x73, 0xf5, 0xda, 0x87, - 0xa8, 0xbc, 0xbb, 0x0e, 0x21, 0xc6, 0x48, 0x70, 0xf2, 0xce, 0xdf, 0x37, 0xff, 0x63, 0x18, 0x4c, - 0x93, 0x88, 0x65, 0xc3, 0xf3, 0xec, 0xa5, 0x7a, 0xb0, 0x6c, 0x26, 0x88, 0x0d, 0x73, 0x96, 0x89, - 0x92, 0xf0, 0x25, 0x81, 0x1b, 0xe7, 0x99, 0x2f, 0x75, 0x7c, 0xc5, 0xf6, 0xda, 0xb0, 0x16, 0xd0, - 0xe5, 0x8c, 0xb8, 0xf0, 0xde, 0x41, 0xe7, 0x38, 0xe1, 0x22, 0x20, 0x9e, 0x67, 0x29, 0x27, 0xf4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0x06, 0xba, 0x92, 0x71, 0xad, 0xf8, 0xef, + 0x61, 0x43, 0x79, 0xaf, 0x19, 0xde, 0x81, 0xee, 0x8f, 0x88, 0xc7, 0x3f, 0xab, 0xfb, 0xfc, 0xad, + 0x83, 0x35, 0x4e, 0xae, 0x09, 0xe5, 0xe8, 0x80, 0x91, 0x26, 0x22, 0x0d, 0x3b, 0x34, 0xd2, 0x04, + 0x87, 0xd0, 0xe6, 0xf3, 0x82, 0x78, 0x46, 0x5f, 0x1f, 0x38, 0xa3, 0xe7, 0x35, 0x62, 0xe9, 0x76, + 0x3a, 0x2f, 0x48, 0x28, 0x80, 0xf8, 0x02, 0x6c, 0x9e, 0x4e, 0x09, 0xe3, 0xd1, 0xb4, 0xf0, 0x5a, + 0x7d, 0x7d, 0xd0, 0x0a, 0x6f, 0x15, 0xe8, 0x42, 0x8b, 0xf3, 0x89, 0xd7, 0x16, 0xfa, 0xf2, 0x58, + 0xe6, 0x4e, 0xae, 0x49, 0xc6, 0x99, 0x67, 0x36, 0xe4, 0x7e, 0x5c, 0x9a, 0x43, 0x85, 0xf2, 0x9f, + 0xc2, 0xe6, 0x57, 0x9a, 0xc7, 0x84, 0xb1, 0xaa, 0x7c, 0xdf, 0x05, 0xe7, 0x88, 0x92, 0x88, 0x93, + 0x65, 0xcd, 0x47, 0x32, 0x21, 0x77, 0x35, 0x67, 0x45, 0xb2, 0x8c, 0xf9, 0xa5, 0x83, 0x29, 0xa8, + 0x31, 0x50, 0x35, 0xea, 0xa2, 0xc6, 0xde, 0xfd, 0x09, 0x34, 0x95, 0x68, 0xac, 0x96, 0x78, 0x00, + 0xa6, 0xf0, 0x13, 0xc5, 0x37, 0xbf, 0x85, 0x04, 0xf9, 0x67, 0x60, 0x8a, 0xb7, 0x44, 0x0f, 0x3a, + 0x8c, 0xd0, 0xeb, 0x34, 0x26, 0xea, 0xf6, 0x2b, 0xb1, 0xb4, 0x5c, 0x44, 0x9c, 0xdc, 0x44, 0x73, + 0x11, 0xc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0x04, 0x53, 0xcc, 0x32, 0xee, 0xd4, 0xb0, + 0xcb, 0x33, 0xde, 0x6b, 0x98, 0x2b, 0x5f, 0x7b, 0xa5, 0xe3, 0x21, 0xd8, 0xb2, 0xbc, 0x94, 0x11, + 0xf4, 0xea, 0x0d, 0xab, 0x28, 0xb6, 0x1b, 0xa6, 0x5f, 0x70, 0x7c, 0x82, 0x8e, 0x9a, 0x4b, 0x6c, + 0xc2, 0xf5, 0xfa, 0x35, 0xc3, 0xea, 0x28, 0x6b, 0x78, 0xbc, 0xe8, 0x81, 0xe6, 0x44, 0xf6, 0x9a, + 0x5e, 0x74, 0x41, 0x33, 0xfa, 0x6b, 0x80, 0x79, 0x1a, 0x9d, 0x4f, 0x08, 0x1e, 0x55, 0x8f, 0x83, + 0x0d, 0xa3, 0x78, 0x0f, 0xdd, 0xca, 0x3a, 0xd1, 0x4a, 0x12, 0xf9, 0xaa, 0x8f, 0x20, 0x59, 0xd9, + 0x40, 0x82, 0x44, 0xb6, 0xc3, 0x23, 0x48, 0x56, 0x96, 0x96, 0x86, 0x63, 0x68, 0x97, 0xff, 0xbe, + 0x07, 0x6e, 0xa7, 0xde, 0x08, 0xcb, 0x3f, 0x4b, 0x5f, 0xc3, 0xcf, 0xd5, 0xce, 0xd9, 0x69, 0xf8, + 0xcf, 0x28, 0xa2, 0xdd, 0x26, 0x73, 0xc5, 0x74, 0x6e, 0x89, 0x7f, 0xf5, 0xeb, 0xff, 0x01, 0x00, + 0x00, 0xff, 0xff, 0xe2, 0xe9, 0xe2, 0x3b, 0xd7, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/router/proto/router.proto b/router/proto/router.proto index 3e18d456..543fdd97 100644 --- a/router/proto/router.proto +++ b/router/proto/router.proto @@ -117,10 +117,12 @@ message Route { string gateway = 3; // the network for this destination string network = 4; + // router if the router id + string router = 5; // the network link - string link = 5; + string link = 6; // the metric / score of this route - int64 metric = 6; + int64 metric = 7; } message Status {