Merge pull request #1123 from milosgajdos83/sync-metric
Update route metric before sending the Sync message
This commit is contained in:
commit
f78e30770e
@ -1293,6 +1293,20 @@ func (n *network) getProtoRoutes() ([]*pbRtr.Route, error) {
|
||||
// encode the routes to protobuf
|
||||
pbRoutes := make([]*pbRtr.Route, 0, len(routes))
|
||||
for _, route := range routes {
|
||||
// calculate route metric and add to the advertised metric
|
||||
// we need to make sure we do not overflow math.MaxInt64
|
||||
metric := n.getRouteMetric(route.Router, route.Gateway, route.Link)
|
||||
log.Tracef("Network metric for router %s and gateway %s: %v", route.Router, route.Gateway, metric)
|
||||
|
||||
// check we don't overflow max int 64
|
||||
if d := route.Metric + metric; d <= 0 {
|
||||
// set to max int64 if we overflow
|
||||
route.Metric = math.MaxInt64
|
||||
} else {
|
||||
// set the combined value of metrics otherwise
|
||||
route.Metric = d
|
||||
}
|
||||
|
||||
// generate new route proto
|
||||
pbRoute := pbUtil.RouteToProto(route)
|
||||
// mask the route before outbounding
|
||||
|
Loading…
x
Reference in New Issue
Block a user