From bb881467bcbff28a56ff0f3eb6e16d261b31d4c3 Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Sat, 24 Oct 2015 21:39:27 +0900 Subject: 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 --- table/policy.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'table/policy.go') 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 } -- cgit v1.2.3