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

Removed fmt.Printf

parent 1337ccc9
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ import ( ...@@ -15,7 +15,7 @@ import (
) )
func main() { func main() {
fmt.Printf("This is a BGP speaker\n") logrus.Printf("This is a BGP speaker\n")
rib := locRIB.New() rib := locRIB.New()
b := server.NewBgpServer() b := server.NewBgpServer()
......
...@@ -647,7 +647,7 @@ func (fsm *FSM) openConfirm() int { ...@@ -647,7 +647,7 @@ func (fsm *FSM) openConfirm() int {
case recvMsg := <-fsm.msgRecvCh: case recvMsg := <-fsm.msgRecvCh:
msg, err := packet.Decode(bytes.NewBuffer(recvMsg.msg)) msg, err := packet.Decode(bytes.NewBuffer(recvMsg.msg))
if err != nil { if err != nil {
fmt.Printf("Failed to decode message: %v\n", recvMsg.msg) log.WithError(err).Errorf("Failed to decode BGP message %v\n", recvMsg.msg)
switch bgperr := err.(type) { switch bgperr := err.(type) {
case packet.BGPError: case packet.BGPError:
sendNotification(fsm.con, bgperr.ErrorCode, bgperr.ErrorSubCode) sendNotification(fsm.con, bgperr.ErrorCode, bgperr.ErrorSubCode)
...@@ -790,7 +790,8 @@ func (fsm *FSM) established() int { ...@@ -790,7 +790,8 @@ func (fsm *FSM) established() int {
case recvMsg := <-fsm.msgRecvCh: case recvMsg := <-fsm.msgRecvCh:
msg, err := packet.Decode(bytes.NewBuffer(recvMsg.msg)) msg, err := packet.Decode(bytes.NewBuffer(recvMsg.msg))
if err != nil { if err != nil {
fmt.Printf("Failed to decode BGP message: %v\n", recvMsg.msg) log.WithError(err).Errorf("Failed to decode BGP message %v\n", recvMsg.msg)
switch bgperr := err.(type) { switch bgperr := err.(type) {
case packet.BGPError: case packet.BGPError:
sendNotification(fsm.con, bgperr.ErrorCode, bgperr.ErrorSubCode) sendNotification(fsm.con, bgperr.ErrorCode, bgperr.ErrorSubCode)
...@@ -815,14 +816,13 @@ func (fsm *FSM) established() int { ...@@ -815,14 +816,13 @@ func (fsm *FSM) established() int {
for r := u.WithdrawnRoutes; r != nil; r = r.Next { for r := u.WithdrawnRoutes; r != nil; r = r.Next {
pfx := tnet.NewPfx(r.IP, r.Pfxlen) pfx := tnet.NewPfx(r.IP, r.Pfxlen)
fmt.Printf("LPM: Removing prefix %s\n", pfx.String()) log.WithField("Prefix", pfx.String()).Debug("LPM: Removing prefix")
fsm.adjRIBIn.RemovePath(pfx, nil) fsm.adjRIBIn.RemovePath(pfx, nil)
} }
for r := u.NLRI; r != nil; r = r.Next { for r := u.NLRI; r != nil; r = r.Next {
pfx := tnet.NewPfx(r.IP, r.Pfxlen) pfx := tnet.NewPfx(r.IP, r.Pfxlen)
fmt.Printf("LPM: Adding prefix %s\n", pfx.String()) log.WithField("Prefix", pfx.String()).Debug("LPM: Adding prefix")
path := &route.Path{ path := &route.Path{
Type: route.BGPPathType, Type: route.BGPPathType,
BGPPath: &route.BGPPath{ BGPPath: &route.BGPPath{
...@@ -831,7 +831,6 @@ func (fsm *FSM) established() int { ...@@ -831,7 +831,6 @@ func (fsm *FSM) established() int {
} }
for pa := u.PathAttributes; pa != nil; pa = pa.Next { for pa := u.PathAttributes; pa != nil; pa = pa.Next {
fmt.Printf("TypeCode: %d\n", pa.TypeCode)
switch pa.TypeCode { switch pa.TypeCode {
case packet.OriginAttr: case packet.OriginAttr:
path.BGPPath.Origin = pa.Value.(uint8) path.BGPPath.Origin = pa.Value.(uint8)
...@@ -840,7 +839,7 @@ func (fsm *FSM) established() int { ...@@ -840,7 +839,7 @@ func (fsm *FSM) established() int {
case packet.MEDAttr: case packet.MEDAttr:
path.BGPPath.MED = pa.Value.(uint32) path.BGPPath.MED = pa.Value.(uint32)
case packet.NextHopAttr: case packet.NextHopAttr:
fmt.Printf("RECEIVED NEXT_HOP: %d\n", pa.Value.(uint32)) log.WithField("NextHop", pa.Value.(uint32)).Debug("RECEIVED NEXT_HOP")
path.BGPPath.NextHop = pa.Value.(uint32) path.BGPPath.NextHop = pa.Value.(uint32)
case packet.ASPathAttr: case packet.ASPathAttr:
path.BGPPath.ASPath = pa.ASPathString() path.BGPPath.ASPath = pa.ASPathString()
......
...@@ -39,7 +39,7 @@ func (b *BGPServer) Start(c *config.Global) error { ...@@ -39,7 +39,7 @@ func (b *BGPServer) Start(c *config.Global) error {
return fmt.Errorf("Failed to load defaults: %v", err) return fmt.Errorf("Failed to load defaults: %v", err)
} }
fmt.Printf("ROUTER ID: %d\n", c.RouterID) log.Infof("ROUTER ID: %d\n", c.RouterID)
b.routerID = c.RouterID b.routerID = c.RouterID
if c.Listen { if c.Listen {
...@@ -62,8 +62,6 @@ func (b *BGPServer) Start(c *config.Global) error { ...@@ -62,8 +62,6 @@ func (b *BGPServer) Start(c *config.Global) error {
func (b *BGPServer) incomingConnectionWorker() { func (b *BGPServer) incomingConnectionWorker() {
for { for {
c := <-b.acceptCh c := <-b.acceptCh
fmt.Printf("Incoming connection!\n")
fmt.Printf("Connection from: %v\n", c.RemoteAddr())
peerAddr := strings.Split(c.RemoteAddr().String(), ":")[0] peerAddr := strings.Split(c.RemoteAddr().String(), ":")[0]
if _, ok := b.peers[peerAddr]; !ok { if _, ok := b.peers[peerAddr]; !ok {
...@@ -78,9 +76,9 @@ func (b *BGPServer) incomingConnectionWorker() { ...@@ -78,9 +76,9 @@ func (b *BGPServer) incomingConnectionWorker() {
"source": c.RemoteAddr(), "source": c.RemoteAddr(),
}).Info("Incoming TCP connection") }).Info("Incoming TCP connection")
fmt.Printf("DEBUG: Sending incoming TCP connection to fsm for peer %s\n", peerAddr) log.WithField("Peer", peerAddr).Debug("Sending incoming TCP connection to fsm for peer")
b.peers[peerAddr].fsm.conCh <- c b.peers[peerAddr].fsm.conCh <- c
fmt.Printf("DEBUG: Sending done\n") log.Debug("Sending done")
} }
} }
......
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