Skip to content
Snippets Groups Projects
Commit e12b31e4 authored by Christoph Petrausch's avatar Christoph Petrausch
Browse files

Don't announce own ASN in ASPath if iBGP

parent 1337ccc9
No related branches found
No related tags found
No related merge requests found
......@@ -15,18 +15,20 @@ import (
// UpdateSender converts table changes into BGP update messages
type UpdateSender struct {
routingtable.ClientManager
fsm *FSM
fsm *FSM
iBGP bool
}
func newUpdateSender(fsm *FSM) *UpdateSender {
return &UpdateSender{
fsm: fsm,
fsm: fsm,
iBGP: fsm.localASN == fsm.remoteASN,
}
}
// 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(strings.TrimRight(fmt.Sprintf("%d %s", u.fsm.localASN, p.BGPPath.ASPath), " "))
asPathPA, err := packet.ParseASPathStr(asPathString(u.iBGP, u.fsm.localASN, p.BGPPath.ASPath))
if err != nil {
return fmt.Errorf("Unable to parse AS path: %v", err)
}
......@@ -74,3 +76,12 @@ func (u *UpdateSender) UpdateNewClient(client routingtable.RouteTableClient) err
log.Warningf("BGP Update Sender: UpdateNewClient() not supported")
return nil
}
func asPathString(iBGP bool, localASN uint16, asPath string) string {
ret := ""
if iBGP {
ret = ret + fmt.Sprintf("%d ", localASN)
}
ret = ret + asPath
return strings.TrimRight(ret, " ")
}
......@@ -2,7 +2,6 @@ package server
import (
"fmt"
"strings"
log "github.com/sirupsen/logrus"
......@@ -15,18 +14,20 @@ import (
// UpdateSenderAddPath converts table changes into BGP update messages with add path
type UpdateSenderAddPath struct {
routingtable.ClientManager
fsm *FSM
fsm *FSM
iBGP bool
}
func newUpdateSenderAddPath(fsm *FSM) *UpdateSenderAddPath {
return &UpdateSenderAddPath{
fsm: fsm,
fsm: fsm,
iBGP: fsm.localASN == fsm.remoteASN,
}
}
// 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(strings.TrimRight(fmt.Sprintf("%d %s", u.fsm.localASN, p.BGPPath.ASPath), " "))
asPathPA, err := packet.ParseASPathStr(asPathString(u.iBGP, u.fsm.localASN, p.BGPPath.ASPath))
if err != nil {
return fmt.Errorf("Unable to parse AS path: %v", err)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment