diff --git a/protocols/bgp/server/update_sender.go b/protocols/bgp/server/update_sender.go index 95dded6f74ce1c095301026a7b00c2b48f99beb9..0f2096aa9d5c5d89b14dc3da9fb33b9480c49113 100644 --- a/protocols/bgp/server/update_sender.go +++ b/protocols/bgp/server/update_sender.go @@ -2,6 +2,7 @@ package server import ( "fmt" + "strings" log "github.com/sirupsen/logrus" @@ -25,7 +26,7 @@ func newUpdateSender(fsm *FSM) *UpdateSender { // AddPath serializes a new path and sends out a BGP update message func (u *UpdateSender) AddPath(pfx net.Prefix, p *route.Path) error { - asPathPA, err := packet.ParseASPathStr(fmt.Sprintf("%d %s", u.fsm.localASN, p.BGPPath.ASPath)) + asPathPA, err := packet.ParseASPathStr(strings.TrimRight(fmt.Sprintf("%d %s", u.fsm.localASN, p.BGPPath.ASPath), " ")) if err != nil { return fmt.Errorf("Unable to parse AS path: %v", err) } diff --git a/protocols/bgp/server/update_sender_add_path.go b/protocols/bgp/server/update_sender_add_path.go index c4fe7de5f145a256eedab2c980e3ee82418b1898..f63f485e738f0540666bea9e624163ca422e72f8 100644 --- a/protocols/bgp/server/update_sender_add_path.go +++ b/protocols/bgp/server/update_sender_add_path.go @@ -2,6 +2,7 @@ package server import ( "fmt" + "strings" log "github.com/sirupsen/logrus" @@ -25,7 +26,7 @@ func newUpdateSenderAddPath(fsm *FSM) *UpdateSenderAddPath { // AddPath serializes a new path and sends out a BGP update message func (u *UpdateSenderAddPath) AddPath(pfx net.Prefix, p *route.Path) error { - asPathPA, err := packet.ParseASPathStr(fmt.Sprintf("%d %s", u.fsm.localASN, p.BGPPath.ASPath)) + asPathPA, err := packet.ParseASPathStr(strings.TrimRight(fmt.Sprintf("%d %s", u.fsm.localASN, p.BGPPath.ASPath), " ")) if err != nil { return fmt.Errorf("Unable to parse AS path: %v", err) }