diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-12-20 13:37:48 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-12-20 13:37:48 +0900 |
commit | eaef2a30aa9720848387819fc9daf21ec1f2b8f0 (patch) | |
tree | 8da242ac3cd330686aede6023a28754827781a42 /table/message.go | |
parent | a44dd5d4116b7b42b5e97b268d30fc7904c25b77 (diff) |
table: fix converting 2bytes to 4bytes AS PATH
On some conditions, we add some ASes to As4PathParam.AS but don't
update As4PathParam.Num (the number of ASes). It breaks serialization
of AS4PathParam.
Instead of modifying the internal of As4PathParam, let's create a new
As4PathParam object.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/message.go')
-rw-r--r-- | table/message.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/table/message.go b/table/message.go index 0e4acc7d..0909d08f 100644 --- a/table/message.go +++ b/table/message.go @@ -169,8 +169,7 @@ func UpdatePathAttrs4ByteAs(msg *bgp.BGPUpdate) error { keepNum -= param.ASLen() } else { // only SEQ param reaches here - param.AS = param.AS[:keepNum] - newParams = append(newParams, param) + newParams = append(newParams, bgp.NewAs4PathParam(param.Type, param.AS[:keepNum])) keepNum = 0 } @@ -183,11 +182,10 @@ func UpdatePathAttrs4ByteAs(msg *bgp.BGPUpdate) error { lastParam := newParams[len(newParams)-1] if param.Type == lastParam.Type && param.Type == bgp.BGP_ASPATH_ATTR_TYPE_SEQ { if len(lastParam.AS)+len(param.AS) > 255 { - lastParam.AS = append(lastParam.AS, param.AS[:255-len(lastParam.AS)]...) - param.AS = param.AS[255-len(lastParam.AS):] - newParams = append(newParams, param) + newParams[len(newParams)-1] = bgp.NewAs4PathParam(param.Type, append(lastParam.AS, param.AS[:255-len(lastParam.AS)]...)) + newParams = append(newParams, bgp.NewAs4PathParam(param.Type, param.AS[255-len(lastParam.AS):])) } else { - lastParam.AS = append(lastParam.AS, param.AS...) + newParams[len(newParams)-1] = bgp.NewAs4PathParam(param.Type, append(lastParam.AS, param.AS...)) } } else { newParams = append(newParams, param) |