diff --git a/protocols/bgp/packet/decoder.go b/protocols/bgp/packet/decoder.go index a0179812e437ecfa9b5080b4814a90a1b8c8c3ff..961789b3cfdd43b0aae606e2a693ceef88a315b9 100644 --- a/protocols/bgp/packet/decoder.go +++ b/protocols/bgp/packet/decoder.go @@ -182,7 +182,6 @@ func decodeOptParams(buf *bytes.Buffer, optParmLen uint8) ([]OptParam, error) { read += 2 - fmt.Printf("Type: %d\n", o.Type) switch o.Type { case CapabilitiesParamType: caps, err := decodeCapabilities(buf, o.Length) diff --git a/protocols/bgp/server/update_sender.go b/protocols/bgp/server/update_sender.go index 07af48dde7e69aa3be2e7e61583df08a665007de..95dded6f74ce1c095301026a7b00c2b48f99beb9 100644 --- a/protocols/bgp/server/update_sender.go +++ b/protocols/bgp/server/update_sender.go @@ -11,6 +11,7 @@ import ( "github.com/bio-routing/bio-rd/routingtable" ) +// UpdateSender converts table changes into BGP update messages type UpdateSender struct { routingtable.ClientManager fsm *FSM @@ -22,8 +23,8 @@ 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 { - fmt.Printf("SENDING AN BGP UPDATE\n") asPathPA, err := packet.ParseASPathStr(fmt.Sprintf("%d %s", u.fsm.localASN, p.BGPPath.ASPath)) if err != nil { return fmt.Errorf("Unable to parse AS path: %v", err) @@ -53,7 +54,7 @@ func (u *UpdateSender) AddPath(pfx net.Prefix, p *route.Path) error { log.Errorf("Unable to serialize BGP Update: %v", err) return nil } - fmt.Printf("Sending Update: %v\n", updateBytes) + _, err = u.fsm.con.Write(updateBytes) if err != nil { return fmt.Errorf("Failed sending Update: %v", err) @@ -61,12 +62,14 @@ func (u *UpdateSender) AddPath(pfx net.Prefix, p *route.Path) error { return nil } +// RemovePath withdraws prefix `pfx` from a peer func (u *UpdateSender) RemovePath(pfx net.Prefix, p *route.Path) bool { log.Warningf("BGP Update Sender: RemovePath not implemented") return false } +// UpdateNewClient does nothing func (u *UpdateSender) UpdateNewClient(client routingtable.RouteTableClient) error { - log.Warningf("BGP Update Sender: RemovePath not implemented") + log.Warningf("BGP Update Sender: UpdateNewClient() not supported") return nil } diff --git a/protocols/bgp/server/update_sender_add_path.go b/protocols/bgp/server/update_sender_add_path.go index fc7fd0a716b3a6ad734ea98718a07c1924eb13ac..c4fe7de5f145a256eedab2c980e3ee82418b1898 100644 --- a/protocols/bgp/server/update_sender_add_path.go +++ b/protocols/bgp/server/update_sender_add_path.go @@ -11,6 +11,7 @@ import ( "github.com/bio-routing/bio-rd/routingtable" ) +// UpdateSenderAddPath converts table changes into BGP update messages with add path type UpdateSenderAddPath struct { routingtable.ClientManager fsm *FSM @@ -22,8 +23,8 @@ 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 { - fmt.Printf("SENDING AN BGP UPDATE WITH ADD PATH TO %s\n", u.fsm.remote.String()) asPathPA, err := packet.ParseASPathStr(fmt.Sprintf("%d %s", u.fsm.localASN, p.BGPPath.ASPath)) if err != nil { return fmt.Errorf("Unable to parse AS path: %v", err) @@ -54,7 +55,7 @@ func (u *UpdateSenderAddPath) AddPath(pfx net.Prefix, p *route.Path) error { log.Errorf("Unable to serialize BGP Update: %v", err) return nil } - fmt.Printf("Sending Update: %v\n", updateBytes) + _, err = u.fsm.con.Write(updateBytes) if err != nil { return fmt.Errorf("Failed sending Update: %v", err) @@ -62,11 +63,13 @@ func (u *UpdateSenderAddPath) AddPath(pfx net.Prefix, p *route.Path) error { return nil } +// RemovePath withdraws prefix `pfx` from a peer func (u *UpdateSenderAddPath) RemovePath(pfx net.Prefix, p *route.Path) bool { log.Warningf("BGP Update Sender: RemovePath not implemented") return false } +// UpdateNewClient does nothing func (u *UpdateSenderAddPath) UpdateNewClient(client routingtable.RouteTableClient) error { log.Warningf("BGP Update Sender: RemovePath not implemented") return nil diff --git a/routingtable/locRIB/loc_rib.go b/routingtable/locRIB/loc_rib.go index 8d8632c084784ef07dffdd00c1d38e60605dfc48..dd06e10069108809feb7da2118188a0fbe1bb4a9 100644 --- a/routingtable/locRIB/loc_rib.go +++ b/routingtable/locRIB/loc_rib.go @@ -59,12 +59,8 @@ func (a *LocRIB) AddPath(pfx net.Prefix, p *route.Path) error { } r.PathSelection() - newRoute := r.Copy() - fmt.Printf("NEW: %v\n", newRoute.Paths()) - fmt.Printf("OLD: %v\n", oldRoute.Paths()) - a.propagateChanges(oldRoute, newRoute) return nil } @@ -86,9 +82,6 @@ func (a *LocRIB) RemovePath(pfx net.Prefix, p *route.Path) bool { r = a.rt.Get(pfx) newRoute := r.Copy() - fmt.Printf("NEW: %v\n", newRoute.Paths()) - fmt.Printf("OLD: %v\n", oldRoute.Paths()) - a.propagateChanges(oldRoute, newRoute) return true } @@ -99,7 +92,6 @@ func (a *LocRIB) propagateChanges(oldRoute *route.Route, newRoute *route.Route) } func (a *LocRIB) addPathsToClients(oldRoute *route.Route, newRoute *route.Route) { - fmt.Printf("LocRIB: Updating %d clients\n", len(a.ClientManager.Clients())) for _, client := range a.ClientManager.Clients() { opts := a.ClientManager.GetOptions(client) oldMaxPaths := opts.GetMaxPaths(oldRoute.ECMPPathCount()) @@ -108,11 +100,7 @@ func (a *LocRIB) addPathsToClients(oldRoute *route.Route, newRoute *route.Route) oldPathsLimit := int(math.Min(float64(oldMaxPaths), float64(len(oldRoute.Paths())))) newPathsLimit := int(math.Min(float64(newMaxPaths), float64(len(newRoute.Paths())))) - fmt.Printf("oldPathsLimit: %v\n", oldPathsLimit) - fmt.Printf("newPathsLimit: %v\n", newPathsLimit) - advertise := route.PathsDiff(newRoute.Paths()[0:newPathsLimit], oldRoute.Paths()[0:oldPathsLimit]) - fmt.Printf("ADVERTISING PATHS %v TO CLIENTS\n", advertise) for _, p := range advertise { client.AddPath(newRoute.Prefix(), p)