diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-04-05 13:32:58 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-04-10 00:04:48 +0900 |
commit | 7cec3f5e8984890b9cccc4a9911f821b891b9dfe (patch) | |
tree | e357a1c47b68e6b168cf6fcf2b0925c99935b15b /server | |
parent | 310be31d8832ec630ca87f448ad22e192c9c4e26 (diff) |
fsm: delegate 2byte as handling to fsm send goroutine
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/fsm.go | 9 | ||||
-rw-r--r-- | server/server.go | 11 |
2 files changed, 9 insertions, 11 deletions
diff --git a/server/fsm.go b/server/fsm.go index b5530f52..68e27074 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -992,6 +992,15 @@ func (h *FSMHandler) sendMessageloop() error { fsm := h.fsm ticker := keepaliveTicker(fsm) send := func(m *bgp.BGPMessage) error { + if _, y := fsm.capMap[bgp.BGP_CAP_FOUR_OCTET_AS_NUMBER]; !y && m.Header.Type == bgp.BGP_MSG_UPDATE { + log.WithFields(log.Fields{ + "Topic": "Peer", + "Key": fsm.pConf.Config.NeighborAddress, + "State": fsm.state, + "Data": m, + }).Debug("update for 2byte AS peer") + table.UpdatePathAttrs2ByteAs(m.Body.(*bgp.BGPUpdate)) + } b, err := m.Serialize() if err != nil { log.WithFields(log.Fields{ diff --git a/server/server.go b/server/server.go index 41d2a718..5797e09e 100644 --- a/server/server.go +++ b/server/server.go @@ -41,7 +41,6 @@ type SenderMsg struct { messages []*bgp.BGPMessage sendCh chan *bgp.BGPMessage destination string - twoBytesAs bool } type broadcastMsg interface { @@ -216,14 +215,6 @@ func (server *BgpServer) Serve() { } for _, b := range m.messages { - if m.twoBytesAs == false && b.Header.Type == bgp.BGP_MSG_UPDATE { - log.WithFields(log.Fields{ - "Topic": "Peer", - "Key": m.destination, - "Data": b, - }).Debug("update for 2byte AS peer") - table.UpdatePathAttrs2ByteAs(b.Body.(*bgp.BGPUpdate)) - } w(m.sendCh, b) } } @@ -365,12 +356,10 @@ func (server *BgpServer) Serve() { } func newSenderMsg(peer *Peer, messages []*bgp.BGPMessage) *SenderMsg { - _, y := peer.fsm.capMap[bgp.BGP_CAP_FOUR_OCTET_AS_NUMBER] return &SenderMsg{ messages: messages, sendCh: peer.outgoing, destination: peer.conf.Config.NeighborAddress, - twoBytesAs: y, } } |