summaryrefslogtreecommitdiffhomepage
path: root/table/destination.go
diff options
context:
space:
mode:
authorHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2015-06-02 20:25:58 +0900
committerHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2015-06-02 21:09:04 +0900
commite985f476a182f1a66084b3ed4b1c2376f9cc5018 (patch)
tree91dfbaf8f5685bac44afad834cbf4c1d32b7c8c5 /table/destination.go
parent007c0df5092df0be2e03df457dcfcb89c92080d6 (diff)
packet: return aspath length based on the segment type.
Diffstat (limited to 'table/destination.go')
-rw-r--r--table/destination.go21
1 files changed, 5 insertions, 16 deletions
diff --git a/table/destination.go b/table/destination.go
index a01c6e04..16795a89 100644
--- a/table/destination.go
+++ b/table/destination.go
@@ -622,30 +622,19 @@ func compareByASPath(path1, path2 Path) Path {
_, attribute1 := path1.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
_, attribute2 := path2.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
- asPath1 := attribute1.(*bgp.PathAttributeAsPath)
- asPath2 := attribute2.(*bgp.PathAttributeAsPath)
-
- if asPath1 == nil || asPath2 == nil {
+ if attribute1 == nil || attribute2 == nil {
log.WithFields(log.Fields{
"Topic": "Table",
"Key": "compareByASPath",
- "ASPath1": asPath1,
- "ASPath2": asPath2,
+ "ASPath1": attribute1,
+ "ASPath2": attribute2,
}).Error("can't compare ASPath because it's not present")
}
- var l1, l2 int
- for _, pathParam := range asPath1.Value {
- l1 += pathParam.ASLen()
- }
-
- for _, pathParam := range asPath2.Value {
- l2 += pathParam.ASLen()
- }
+ l1 := path1.GetAsPathLen()
+ l2 := path2.GetAsPathLen()
log.Debugf("compareByASPath -- l1: %d, l2: %d", l1, l2)
- log.Debug(reflect.TypeOf(asPath1.Value))
- log.Debug(asPath1.Value)
if l1 > l2 {
return path2
} else if l1 < l2 {