diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-21 18:44:06 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-21 18:44:06 -0800 |
commit | 73d7ec4471158abd320c056dc28ed76708f6ba65 (patch) | |
tree | 4b6c916b26e97fa72e200f592a375b98b6b58c82 /server/fsm.go | |
parent | 704135410381e69e2f39fea84cd029b65148da01 (diff) |
server: conver PEER_MSG_PATH to bgp update
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/fsm.go')
-rw-r--r-- | server/fsm.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/server/fsm.go b/server/fsm.go index 9b81d1f4..e0e26ce9 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -308,12 +308,24 @@ func (h *FSMHandler) sendMessageloop() error { case <-h.t.Dying(): return nil case m := <-fsm.outgoing: - b, _ := m.Serialize() - _, err := conn.Write(b) - if err != nil { - return nil + isSend := func(state int, Type uint8) bool { + switch Type { + case bgp.BGP_MSG_UPDATE: + if state == bgp.BGP_FSM_ESTABLISHED { + return true + } + } + return false + }(fsm.state, m.Header.Type) + + if isSend { + b, _ := m.Serialize() + _, err := conn.Write(b) + if err != nil { + return nil + } + fsm.bgpMessageStateUpdate(m.Header.Type, false) } - fsm.bgpMessageStateUpdate(m.Header.Type, false) case <-fsm.keepaliveTicker.C: m := bgp.NewBGPKeepAliveMessage() b, _ := m.Serialize() |