summaryrefslogtreecommitdiffhomepage
path: root/server/fsm.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-16 09:27:07 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-16 09:27:07 +0900
commit03bf3795ef880537d37349ea7a772daafcddd0de (patch)
tree2600a7e91b5f65b62d56cea0c53a2b23bd3d25be /server/fsm.go
parent7743748a1559c722f4a1c7870978fa7d07cfe6cb (diff)
api: add reset and shutdown support
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/fsm.go')
-rw-r--r--server/fsm.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/server/fsm.go b/server/fsm.go
index d57a6f42..81050b31 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -122,7 +122,7 @@ type FSMHandler struct {
func NewFSMHandler(fsm *FSM) *FSMHandler {
f := &FSMHandler{
fsm: fsm,
- errorCh: make(chan bool),
+ errorCh: make(chan bool, 2),
}
f.t.Go(f.loop)
return f
@@ -281,7 +281,11 @@ func (h *FSMHandler) opensent() bgp.FSMState {
case *bgp.MessageError:
err := e.MsgData.(*bgp.MessageError)
m := bgp.NewBGPNotificationMessage(err.TypeCode, err.SubTypeCode, err.Data)
- h.fsm.outgoing <- m
+ b, _ := m.Serialize()
+ fsm.passiveConn.Write(b)
+ fsm.bgpMessageStateUpdate(m.Header.Type, false)
+ h.conn.Close()
+ nextState = bgp.BGP_FSM_IDLE
default:
log.WithFields(log.Fields{
"Topic": "Peer",
@@ -330,10 +334,11 @@ func (h *FSMHandler) openconfirm() bgp.FSMState {
case *bgp.MessageError:
err := e.MsgData.(*bgp.MessageError)
m := bgp.NewBGPNotificationMessage(err.TypeCode, err.SubTypeCode, err.Data)
- h.fsm.outgoing <- m
- // tx goroutine will close the tcp
- // connection and state will be
- // changed. so no need to change here.
+ b, _ := m.Serialize()
+ fsm.passiveConn.Write(b)
+ fsm.bgpMessageStateUpdate(m.Header.Type, false)
+ h.conn.Close()
+ return bgp.BGP_FSM_IDLE
default:
log.WithFields(log.Fields{
"Topic": "Peer",