summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bgpd.go5
-rw-r--r--server/fsm.go5
-rw-r--r--server/peer.go8
-rw-r--r--server/server.go16
4 files changed, 16 insertions, 18 deletions
diff --git a/bgpd.go b/bgpd.go
index 08edb960..38e5c849 100644
--- a/bgpd.go
+++ b/bgpd.go
@@ -16,7 +16,6 @@
package main
import (
- "fmt"
log "github.com/Sirupsen/logrus"
"github.com/jessevdk/go-flags"
"github.com/osrg/gobgp/api"
@@ -88,15 +87,17 @@ func main() {
}
for _, p := range added {
+ log.Infof("Peer %v is added", p.NeighborAddress)
bgpServer.PeerAdd(p)
}
for _, p := range deleted {
+ log.Infof("Peer %v is deleted", p.NeighborAddress)
bgpServer.PeerDelete(p)
}
case sig := <-sigCh:
switch sig {
case syscall.SIGHUP:
- fmt.Println("relaod the config file")
+ log.Info("relaod the config file")
reloadCh <- true
}
}
diff --git a/server/fsm.go b/server/fsm.go
index e0e26ce9..9dab59e2 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -16,7 +16,7 @@
package server
import (
- "fmt"
+ log "github.com/Sirupsen/logrus"
"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/packet"
"github.com/osrg/gobgp/table"
@@ -96,7 +96,7 @@ func (fsm *FSM) StateChanged() chan int {
}
func (fsm *FSM) StateChange(nextState int) {
- fmt.Println("state changed", nextState, fsm.state)
+ log.Debugf("Peer (%v) state changed from %v to %v", fsm.peerConfig.NeighborAddress, nextState, fsm.state)
fsm.state = nextState
}
@@ -393,7 +393,6 @@ func (h *FSMHandler) loop() error {
}
if nextState == bgp.BGP_FSM_ESTABLISHED {
- fmt.Println("new peerinfo")
// everytime we go into BGP_FSM_ESTABLISHED, we create
// a PeerInfo because sourceNum could be incremented
fsm.createPeerInfo()
diff --git a/server/peer.go b/server/peer.go
index 3c852ccf..a28e94b6 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -17,7 +17,7 @@ package server
import (
"encoding/json"
- "fmt"
+ log "github.com/Sirupsen/logrus"
"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/packet"
"github.com/osrg/gobgp/table"
@@ -62,7 +62,7 @@ func NewPeer(g config.GlobalType, peer config.NeighborType, outEventCh chan *mes
func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) {
j, _ := json.Marshal(m)
- fmt.Println(string(j))
+ log.Info(string(j))
// TODO: update state here
if m.Header.Type != bgp.BGP_MSG_UPDATE {
@@ -136,8 +136,8 @@ func (peer *Peer) loop() error {
case nextState := <-peer.fsm.StateChanged():
// waits for all goroutines created for the current state
h.Wait()
- oldState := peer.fsm.state
- peer.fsm.state = nextState
+ oldState := peer.state
+ peer.state = nextState
peer.fsm.StateChange(nextState)
sameState = false
// TODO: check peer's rf
diff --git a/server/server.go b/server/server.go
index bca36afa..01daa23a 100644
--- a/server/server.go
+++ b/server/server.go
@@ -17,6 +17,7 @@ package server
import (
"fmt"
+ log "github.com/Sirupsen/logrus"
"github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/config"
"net"
@@ -67,7 +68,7 @@ func (server *BgpServer) Serve() {
l, err := net.ListenTCP("tcp4", addr)
if err != nil {
- fmt.Println(err)
+ log.Fatal(err)
os.Exit(1)
}
@@ -76,7 +77,7 @@ func (server *BgpServer) Serve() {
for {
conn, err := l.Accept()
if err != nil {
- fmt.Println(err)
+ log.Info(err)
continue
}
acceptCh <- conn.(*net.TCPConn)
@@ -89,33 +90,30 @@ func (server *BgpServer) Serve() {
f, _ := l.File()
select {
case conn := <-acceptCh:
- fmt.Println(conn)
remoteAddr := strings.Split(conn.RemoteAddr().String(), ":")[0]
peer, found := server.peerMap[remoteAddr]
if found {
- fmt.Println("found neighbor", remoteAddr)
+ log.Info("accepted a new passive connection for", remoteAddr)
peer.PassConn(conn)
} else {
- fmt.Println("can't found neighbor", remoteAddr)
+ log.Info("can't find configuration for a new passive connection", remoteAddr)
conn.Close()
}
case peer := <-server.addedPeerCh:
- fmt.Println(peer)
addr := peer.NeighborAddress.String()
SetTcpMD5SigSockopts(int(f.Fd()), addr, peer.AuthPassword)
p := NewPeer(server.bgpConfig.Global, peer, broadcastCh)
server.peerMap[peer.NeighborAddress.String()] = p
case peer := <-server.deletedPeerCh:
- fmt.Println(peer)
addr := peer.NeighborAddress.String()
SetTcpMD5SigSockopts(int(f.Fd()), addr, "")
p, found := server.peerMap[addr]
if found {
- fmt.Println("found neighbor", addr)
+ log.Info("Delete a peer configuration for", addr)
p.Stop()
delete(server.peerMap, addr)
} else {
- fmt.Println("can't found neighbor", addr)
+ log.Info("Can't delete a peer configuration for", addr)
}
case restReq := <-server.RestReqCh:
server.handleRest(restReq)