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
Branches
Tags
No related merge requests found
......@@ -16,17 +16,19 @@ import (
type UpdateSender struct {
routingtable.ClientManager
fsm *FSM
iBGP bool
}
func newUpdateSender(fsm *FSM) *UpdateSender {
return &UpdateSender{
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"
......@@ -16,17 +15,19 @@ import (
type UpdateSenderAddPath struct {
routingtable.ClientManager
fsm *FSM
iBGP bool
}
func newUpdateSenderAddPath(fsm *FSM) *UpdateSenderAddPath {
return &UpdateSenderAddPath{
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 to comment