Skip to content
Snippets Groups Projects
Unverified Commit c9847d22 authored by Daniel Czerwonk's avatar Daniel Czerwonk Committed by GitHub
Browse files

Merge pull request #48 from bio-routing/fix/aspath

Fixing AS path change on propagation
parents 902f3cad b521f24a
No related branches found
No related tags found
No related merge requests found
...@@ -13,8 +13,15 @@ import ( ...@@ -13,8 +13,15 @@ import (
"github.com/bio-routing/bio-rd/routingtable" "github.com/bio-routing/bio-rd/routingtable"
"github.com/bio-routing/bio-rd/routingtable/filter" "github.com/bio-routing/bio-rd/routingtable/filter"
"github.com/bio-routing/bio-rd/routingtable/locRIB" "github.com/bio-routing/bio-rd/routingtable/locRIB"
bnet "github.com/bio-routing/bio-rd/net"
) )
func strAddr(s string) uint32 {
ret, _ := bnet.StrToAddr(s)
return ret
}
func main() { func main() {
logrus.Printf("This is a BGP speaker\n") logrus.Printf("This is a BGP speaker\n")
......
...@@ -58,8 +58,10 @@ func (s *establishedState) init() { ...@@ -58,8 +58,10 @@ func (s *establishedState) init() {
s.fsm.adjRIBIn.Register(s.fsm.peer.importFilter) s.fsm.adjRIBIn.Register(s.fsm.peer.importFilter)
n := &routingtable.Neighbor{ n := &routingtable.Neighbor{
Type: route.BGPPathType, Type: route.BGPPathType,
Address: tnet.IPv4ToUint32(s.fsm.peer.addr), Address: tnet.IPv4ToUint32(s.fsm.peer.addr),
IBGP: s.fsm.peer.localASN == s.fsm.peer.peerASN,
LocalASN: s.fsm.peer.localASN,
} }
clientOptions := routingtable.ClientOptions{} clientOptions := routingtable.ClientOptions{}
......
...@@ -10,8 +10,8 @@ import ( ...@@ -10,8 +10,8 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
func pathAttribues(p *route.Path, fsm *FSM) (*packet.PathAttribute, error) { func pathAttribues(p *route.Path) (*packet.PathAttribute, error) {
asPathPA, err := packet.ParseASPathStr(strings.TrimRight(fmt.Sprintf("%d %s", fsm.peer.localASN, p.BGPPath.ASPath), " ")) asPathPA, err := packet.ParseASPathStr(strings.TrimRight(p.BGPPath.ASPath, " "))
if err != nil { if err != nil {
return nil, fmt.Errorf("Unable to parse AS path: %v", err) return nil, fmt.Errorf("Unable to parse AS path: %v", err)
} }
......
...@@ -28,7 +28,7 @@ func newUpdateSender(fsm *FSM) *UpdateSender { ...@@ -28,7 +28,7 @@ func newUpdateSender(fsm *FSM) *UpdateSender {
// AddPath serializes a new path and sends out a BGP update message // AddPath serializes a new path and sends out a BGP update message
func (u *UpdateSender) AddPath(pfx net.Prefix, p *route.Path) error { func (u *UpdateSender) AddPath(pfx net.Prefix, p *route.Path) error {
pathAttrs, err := pathAttribues(p, u.fsm) pathAttrs, err := pathAttribues(p)
if err != nil { if err != nil {
log.Errorf("Unable to create BGP Update: %v", err) log.Errorf("Unable to create BGP Update: %v", err)
return nil return nil
......
...@@ -25,7 +25,7 @@ func newUpdateSenderAddPath(fsm *FSM) *UpdateSenderAddPath { ...@@ -25,7 +25,7 @@ func newUpdateSenderAddPath(fsm *FSM) *UpdateSenderAddPath {
// AddPath serializes a new path and sends out a BGP update message // AddPath serializes a new path and sends out a BGP update message
func (u *UpdateSenderAddPath) AddPath(pfx net.Prefix, p *route.Path) error { func (u *UpdateSenderAddPath) AddPath(pfx net.Prefix, p *route.Path) error {
pathAttrs, err := pathAttribues(p, u.fsm) pathAttrs, err := pathAttribues(p)
if err != nil { if err != nil {
log.Errorf("Unable to create BGP Update: %v", err) log.Errorf("Unable to create BGP Update: %v", err)
......
...@@ -39,6 +39,11 @@ func (a *AdjRIBOut) AddPath(pfx net.Prefix, p *route.Path) error { ...@@ -39,6 +39,11 @@ func (a *AdjRIBOut) AddPath(pfx net.Prefix, p *route.Path) error {
return nil return nil
} }
p = p.Copy()
if !a.neighbor.IBGP {
p.BGPPath.ASPath = fmt.Sprintf("%d %s", a.neighbor.LocalASN, p.BGPPath.ASPath)
}
a.mu.Lock() a.mu.Lock()
defer a.mu.Unlock() defer a.mu.Unlock()
......
...@@ -41,6 +41,11 @@ func (a *AdjRIBOutAddPath) AddPath(pfx net.Prefix, p *route.Path) error { ...@@ -41,6 +41,11 @@ func (a *AdjRIBOutAddPath) AddPath(pfx net.Prefix, p *route.Path) error {
return nil return nil
} }
p = p.Copy()
if !a.neighbor.IBGP {
p.BGPPath.ASPath = fmt.Sprintf("%d %s", a.neighbor.LocalASN, p.BGPPath.ASPath)
}
a.mu.Lock() a.mu.Lock()
defer a.mu.Unlock() defer a.mu.Unlock()
......
...@@ -10,4 +10,7 @@ type Neighbor struct { ...@@ -10,4 +10,7 @@ type Neighbor struct {
// IBGP returns if local ASN is equal to remote ASN // IBGP returns if local ASN is equal to remote ASN
IBGP bool IBGP bool
// Local ASN of session
LocalASN uint32
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment