summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go54
1 files changed, 41 insertions, 13 deletions
diff --git a/server/server.go b/server/server.go
index cfbe514f..889e677e 100644
--- a/server/server.go
+++ b/server/server.go
@@ -76,7 +76,10 @@ func NewTCPListener(address string, port uint32, ch chan *net.TCPConn) (*TCPList
conn, err := l.AcceptTCP()
if err != nil {
close(closeCh)
- log.Warn(err)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Error": err,
+ }).Warn("Failed to AcceptTCP")
return err
}
ch <- conn
@@ -148,11 +151,15 @@ func (server *BgpServer) Serve() {
handleFsmMsg := func(e *FsmMsg) {
peer, found := server.neighborMap[e.MsgSrc]
if !found {
- log.Warn("Can't find the neighbor ", e.MsgSrc)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Warnf("Cant't find the neighbor %s", e.MsgSrc)
return
}
if e.Version != peer.fsm.version {
- log.Debug("FSM Version inconsistent")
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Debug("FSM version inconsistent")
return
}
server.handleFSMMessage(peer, e)
@@ -166,7 +173,11 @@ func (server *BgpServer) Serve() {
peer, found := server.neighborMap[remoteAddr]
if found {
if peer.fsm.adminState != ADMIN_STATE_UP {
- log.Debug("new connection for non admin-state-up peer ", remoteAddr, peer.fsm.adminState)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Remote Addr": remoteAddr,
+ "Admin State": peer.fsm.adminState,
+ }).Debug("New connection for non admin-state-up peer")
conn.Close()
return
}
@@ -196,10 +207,14 @@ func (server *BgpServer) Serve() {
conn.Close()
return
}
- log.Debug("accepted a new passive connection from ", remoteAddr)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Debugf("Accepted a new passive connection from:%s", remoteAddr)
peer.PassConn(conn)
} else {
- log.Info("can't find configuration for a new passive connection from ", remoteAddr)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Infof("Can't find configuration for a new passive connection from:%s", remoteAddr)
conn.Close()
}
}
@@ -641,7 +656,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) {
log.WithFields(log.Fields{
"Topic": "Peer",
"Key": peer.ID(),
- }).Debugf("now syncing, suppress sending updates. start deferral timer(%d)", deferral)
+ }).Debugf("Now syncing, suppress sending updates. start deferral timer(%d)", deferral)
time.AfterFunc(time.Second*time.Duration(deferral), deferralExpiredFunc(bgp.RouteFamily(0)))
}
} else {
@@ -1567,10 +1582,14 @@ func (s *BgpServer) GetAdjRib(addr string, family bgp.RouteFamily, in bool, pref
var paths []*table.Path
if in {
paths = peer.adjRibIn.PathList([]bgp.RouteFamily{family}, false)
- log.Debugf("RouteFamily=%v adj-rib-in found : %d", family.String(), len(paths))
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Debugf("RouteFamily=%v adj-rib-in found : %d", family.String(), len(paths))
} else {
paths = peer.adjRibOut.PathList([]bgp.RouteFamily{family}, false)
- log.Debugf("RouteFamily=%v adj-rib-out found : %d", family.String(), len(paths))
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Debugf("RouteFamily=%v adj-rib-out found : %d", family.String(), len(paths))
}
for i, p := range paths {
@@ -1664,7 +1683,9 @@ func (server *BgpServer) addNeighbor(c *config.Neighbor) error {
SetTcpMD5SigSockopts(l, addr, c.Config.AuthPassword)
}
}
- log.Info("Add a peer configuration for ", addr)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Infof("Add a peer configuration for:%s", addr)
peer := NewPeer(&server.bgpConfig.Global, c, server.globalRib, server.policy)
server.setPolicyByConfig(peer.ID(), c.ApplyPolicy)
@@ -1716,16 +1737,23 @@ func (server *BgpServer) deleteNeighbor(c *config.Neighbor, code, subcode uint8)
for _, l := range server.Listeners(addr) {
SetTcpMD5SigSockopts(l, addr, "")
}
- log.Info("Delete a peer configuration for ", addr)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Infof("Delete a peer configuration for:%s", addr)
n.fsm.sendNotification(code, subcode, nil, "")
go func(addr string) {
- t := time.AfterFunc(time.Minute*5, func() { log.Fatal("failed to free the fsm.h.t for ", addr) })
+ logfatal := func() {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Fatalf("Failed to free the fsm.h.t for %s", addr)
+ }
+ t := time.AfterFunc(time.Minute*5, logfatal)
n.fsm.h.t.Kill(nil)
n.fsm.h.t.Wait()
t.Stop()
- t = time.AfterFunc(time.Minute*5, func() { log.Fatal("failed to free the fsm.h for ", addr) })
+ t = time.AfterFunc(time.Minute*5, logfatal)
n.fsm.t.Kill(nil)
n.fsm.t.Wait()
t.Stop()