summaryrefslogtreecommitdiffhomepage
path: root/table/policy.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-10-24 21:39:27 +0900
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-10-24 21:51:54 +0900
commitbb881467bcbff28a56ff0f3eb6e16d261b31d4c3 (patch)
treeb4ae401e0ad295a814c16bdc832bbc2f3c463779 /table/policy.go
parent1aa345882e9feb46c0b7c2fa8c658794242e7418 (diff)
policy: modify path.GetAsSeqList() to insert 0 for non-seq-as-elems
GetAsSeqList() is used for AsPathSet matching and AsPathPrepend action. Just eliminating non-seq-as-elems from what GetAsSeqList() returns cause wrong results for these two match/action. e.g path A's as-path: {100, 200} 300 currently, action 'as-path-prepend left-most repeat 2' will alter as-path to 300 300 {100, 200} 300, which is not expected behavior. To fix this, insert 0 for non-seq-as-elems. Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/policy.go')
-rw-r--r--table/policy.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/table/policy.go b/table/policy.go
index 71793485..bc59799e 100644
--- a/table/policy.go
+++ b/table/policy.go
@@ -2021,16 +2021,23 @@ func (a *AsPathPrependAction) Apply(path *Path) *Path {
log.WithFields(log.Fields{
"Topic": "Policy",
"Type": "AsPathPrepend Action",
- }).Errorf("aspath length is zero.")
+ }).Warnf("aspath length is zero.")
return path
}
asn = aspath[0]
+ if asn == 0 {
+ log.WithFields(log.Fields{
+ "Topic": "Policy",
+ "Type": "AsPathPrepend Action",
+ }).Warnf("left-most ASN is not seq")
+ return path
+ }
log.WithFields(log.Fields{
"Topic": "Policy",
"Type": "AsPathPrepend Action",
"LastAs": asn,
"Repeat": a.repeat,
- }).Debug("use last AS.")
+ }).Debug("use left-most ASN")
} else {
asn = a.asn
}