Skip to content
Snippets Groups Projects
Commit 12bb31c8 authored by Oliver Herms's avatar Oliver Herms
Browse files

Cleanup

parent 95203374
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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
}
......@@ -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
......
......@@ -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)
......
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