diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-06-03 11:20:50 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-06-03 11:20:50 +0900 |
commit | b13c09baa66eaab822eb42bbf0a02fdbbf532932 (patch) | |
tree | 6842c796bd4384c6a1aef208b09b5d1a62b80170 /table/destination.go | |
parent | a3237877e024f44f96f02c83237cf614baf8bcd0 (diff) |
table: fix leftmostAS() in compareByMED
Needs the first AS in the AS_SEQUENCE is the same for multiple
paths. Any preceding AS_CONFED_SEQUENCE is ignored.
Also rename the function name to 'firstAS'.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/destination.go')
-rw-r--r-- | table/destination.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/table/destination.go b/table/destination.go index d192f53d..f695f6be 100644 --- a/table/destination.go +++ b/table/destination.go @@ -679,10 +679,10 @@ func compareByMED(path1, path2 *Path) *Path { isInternal := func() bool { return path1.GetAsPathLen() == 0 && path2.GetAsPathLen() == 0 }() isSameAS := func() bool { - leftmostAS := func(path *Path) uint32 { + firstAS := func(path *Path) uint32 { if aspath := path.GetAsPath(); aspath != nil { asPathParam := aspath.Value - for i := len(asPathParam) - 1; i >= 0; i-- { + for i := 0; i < len(asPathParam); i++ { asPath := asPathParam[i].(*bgp.As4PathParam) if asPath.Num == 0 { continue @@ -690,12 +690,12 @@ func compareByMED(path1, path2 *Path) *Path { if asPath.Type == bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET || asPath.Type == bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SEQ { continue } - return asPath.AS[asPath.Num-1] + return asPath.AS[0] } } return 0 } - return leftmostAS(path1) == leftmostAS(path2) + return firstAS(path1) != 0 && firstAS(path1) == firstAS(path2) }() if SelectionOptions.AlwaysCompareMed || isInternal || isSameAS { |