diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-07-26 08:06:08 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-07-26 08:09:02 +0900 |
commit | b53944902472a3442f4a0c073458e773da019723 (patch) | |
tree | ecbac6c54dd5fee73591c45467dcee6145b84991 /table/destination.go | |
parent | d712de0dc604aafd609a6bfecdef867f7d43e46e (diff) |
table: assign local identifier to path
The local identifier for path is sent to remote peers.
To simplify the implementation,
1) the local identifier is unique per prefix not peer.
2) always assign the local identifier even without addpath-rx-capable peer.
In the future, we might need to improve 2) to avoid the unnecessary
overhead.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/destination.go')
-rw-r--r-- | table/destination.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/table/destination.go b/table/destination.go index cef2086f..78e0ac6b 100644 --- a/table/destination.go +++ b/table/destination.go @@ -147,6 +147,7 @@ type Destination struct { newPathList paths oldKnownPathList paths RadixKey string + localIdMap Bitmap } func NewDestination(nlri bgp.AddrPrefixInterface, known ...*Path) *Destination { @@ -318,11 +319,23 @@ func (dd *Destination) validatePath(path *Path) { func (dest *Destination) Calculate() *Destination { oldKnownPathList := dest.knownPathList // First remove the withdrawn paths. - dest.explicitWithdraw() + withdrawn := dest.explicitWithdraw() // Do implicit withdrawal dest.implicitWithdraw() + + for _, path := range withdrawn { + if id := path.GetNlri().PathLocalIdentifier(); id != 0 { + dest.localIdMap.Unflag(uint(id)) + } + } // Collect all new paths into known paths. dest.knownPathList = append(dest.knownPathList, dest.newPathList...) + + for _, path := range dest.knownPathList { + if path.GetNlri().PathLocalIdentifier() == 0 { + path.GetNlri().SetPathLocalIdentifier(uint32(dest.localIdMap.FindandSetZeroBit())) + } + } // Clear new paths as we copied them. dest.newPathList = make([]*Path, 0) // Compute new best path @@ -438,6 +451,7 @@ func (dest *Destination) implicitWithdraw() paths { }).Debug("Implicit withdrawal of old path, since we have learned new path from the same peer") found = true + newPath.GetNlri().SetPathLocalIdentifier(path.GetNlri().PathLocalIdentifier()) break } } |