diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-14 10:47:32 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-14 10:47:32 +0900 |
commit | db0e46824ad9523a7cea43e7e847a29f72df71ec (patch) | |
tree | 44c2ae970b03b086006eeda2dfe4196ff5f4510d /server/fsm.go | |
parent | cc7ff372950afdcc1c9dbf39dcd13a15830410e2 (diff) |
server: close the connection after sending notification
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/fsm.go')
-rw-r--r-- | server/fsm.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/server/fsm.go b/server/fsm.go index 06870f1b..5846410e 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -217,6 +217,11 @@ func (h *FSMHandler) recvMessageWithError() error { m, err := bgp.ParseBGPBody(hd, bodyBuf) if err != nil { + log.WithFields(log.Fields{ + "Topic": "Peer", + "Key": h.fsm.peerConfig.NeighborAddress, + "error": err, + }).Warn("malformed BGP message") h.errorCh <- true return err } @@ -249,7 +254,7 @@ func (h *FSMHandler) opensent() bgp.FSMState { nextState := bgp.BGP_FSM_IDLE select { case <-h.t.Dying(): - fsm.passiveConn.Close() + h.conn.Close() return 0 case e := <-h.msgCh: m := e.MsgData.(*bgp.BGPMessage) @@ -268,6 +273,7 @@ func (h *FSMHandler) opensent() bgp.FSMState { // send error } case <-h.errorCh: + h.conn.Close() } return nextState } @@ -285,7 +291,7 @@ func (h *FSMHandler) openconfirm() bgp.FSMState { for { select { case <-h.t.Dying(): - fsm.passiveConn.Close() + h.conn.Close() return 0 case <-fsm.keepaliveTicker.C: m := bgp.NewBGPKeepAliveMessage() @@ -303,6 +309,7 @@ func (h *FSMHandler) openconfirm() bgp.FSMState { } return nextState case <-h.errorCh: + h.conn.Close() return bgp.BGP_FSM_IDLE } } @@ -330,6 +337,10 @@ func (h *FSMHandler) sendMessageloop() error { "data": m, }).Debug("sent") fsm.bgpMessageStateUpdate(m.Header.Type, false) + if m.Header.Type == bgp.BGP_MSG_NOTIFICATION { + conn.Close() + return nil + } case <-fsm.keepaliveTicker.C: m := bgp.NewBGPKeepAliveMessage() b, _ := m.Serialize() |