summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorWataru Ishida <ishida.wataru@lab.ntt.co.jp>2016-12-02 02:15:22 -0500
committerWataru Ishida <ishida.wataru@lab.ntt.co.jp>2016-12-02 02:18:09 -0500
commite4a4b3e382f120e672c27ca08abafcb1bc464825 (patch)
treee27baabf5621646f2f3c0b660546d10d34cdb9e6 /server/server.go
parent33ff2fff1f1e4aa693c2ce010d516934d189e538 (diff)
server: fix bug of deleteNeighbor()
cleaning outgoing channel while fsm handler is running may cause crash Dec 2 06:14:36 g2 gobgpd[6955]: {"Topic":"Peer","level":"info","msg":"Delete a peer configuration for:10.173.176.211","time":"2016-12-02T06:14:36Z"} Dec 2 06:14:36 g2 gobgpd[6955]: {"Data":"","Key":"10.173.176.211","Topic":"Peer","level":"warning","msg":"sent notification","time":"2016-12-02T06:14:36Z"} Dec 2 06:14:36 g2 gobgpd[6955]: {"Key":"10.173.176.211","Reason":"notification-sent code 6(cease) subcode 3(peer deconfigured)","State":"BGP_FSM_ESTABLISHED","Topic":"Peer","level":"info","msg":"Peer Down","time":"2016-12-02T06:14:36Z"} Dec 2 06:14:36 g2 gobgpd[6955]: panic: interface conversion: interface {} is nil, not *server.FsmOutgoingMsg Dec 2 06:14:36 g2 gobgpd[6955]: goroutine 69 [running]: Dec 2 06:14:36 g2 gobgpd[6955]: panic(0xd26200, 0xc82030c4c0) Dec 2 06:14:36 g2 gobgpd[6955]: /usr/local/go/src/runtime/panic.go:481 +0x3e6 Dec 2 06:14:36 g2 gobgpd[6955]: github.com/osrg/gobgp/server.(*FSMHandler).sendMessageloop(0xc8201a66e0, 0x0, 0x0) Dec 2 06:14:36 g2 gobgpd[6955]: /usr/local/opt/gopath/src/github.com/osrg/gobgp/server/fsm.go:1136 +0x3c3 Dec 2 06:14:36 g2 gobgpd[6955]: github.com/osrg/gobgp/server.(*FSMHandler).(github.com/osrg/gobgp/server.sendMessageloop)-fm(0x0, 0x0) Dec 2 06:14:36 g2 gobgpd[6955]: /usr/local/opt/gopath/src/github.com/osrg/gobgp/server/fsm.go:1175 +0x2e Dec 2 06:14:36 g2 gobgpd[6955]: gopkg.in/tomb%2ev2.(*Tomb).run(0xc8201a66e0, 0xc820278140) Dec 2 06:14:36 g2 gobgpd[6955]: /usr/local/opt/gopath/src/gopkg.in/tomb.v2/tomb.go:163 +0x21 Dec 2 06:14:36 g2 gobgpd[6955]: created by gopkg.in/tomb%2ev2.(*Tomb).Go Dec 2 06:14:36 g2 gobgpd[6955]: /usr/local/opt/gopath/src/gopkg.in/tomb.v2/tomb.go:159 +0x131 Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/server/server.go b/server/server.go
index d83a4001..743c755e 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1740,25 +1740,41 @@ func (server *BgpServer) deleteNeighbor(c *config.Neighbor, code, subcode uint8)
n.fsm.sendNotification(code, subcode, nil, "")
n.stopPeerRestarting()
- cleanInfiniteChannel(n.outgoing)
go func(addr string) {
+ failed := false
t1 := time.AfterFunc(time.Minute*5, func() {
log.WithFields(log.Fields{
"Topic": "Peer",
}).Warnf("Failed to free the fsm.h.t for %s", addr)
+ failed = true
})
n.fsm.h.t.Kill(nil)
n.fsm.h.t.Wait()
t1.Stop()
+ if !failed {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": addr,
+ }).Debug("freed fsm.h.t")
+ cleanInfiniteChannel(n.outgoing)
+ }
+ failed = false
t2 := time.AfterFunc(time.Minute*5, func() {
log.WithFields(log.Fields{
"Topic": "Peer",
}).Warnf("Failed to free the fsm.t for %s", addr)
+ failed = true
})
n.fsm.t.Kill(nil)
n.fsm.t.Wait()
t2.Stop()
+ if !failed {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": addr,
+ }).Debug("freed fsm.t")
+ }
}(addr)
delete(server.neighborMap, addr)
server.dropPeerAllRoutes(n, n.configuredRFlist())