From 15bf4adfd28f8ac4cdbc40b01ff74ca714832a7b Mon Sep 17 00:00:00 2001 From: Oliver Herms <oliver.herms@exaring.de> Date: Fri, 18 May 2018 17:46:50 +0200 Subject: [PATCH] Fixing empty AS Path bug --- protocols/bgp/server/update_sender.go | 3 ++- protocols/bgp/server/update_sender_add_path.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/protocols/bgp/server/update_sender.go b/protocols/bgp/server/update_sender.go index 95dded6f..0f2096aa 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 c4fe7de5..f63f485e 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) } -- GitLab