summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-11-09 05:46:36 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-11-09 05:46:36 -0800
commit431ce6b171a05cd17784a86ea2da1dfbf2f37ea0 (patch)
treed7b7a2adadf0c8ce248a371a8ae27b38beae97db
parentefcbc131df3aaee82eecc659cdf3428b9f5fe81b (diff)
server: move ProcessMessage to fsm from peer
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--server/fsm.go5
-rw-r--r--server/peer.go9
-rw-r--r--server/server.go2
3 files changed, 10 insertions, 6 deletions
diff --git a/server/fsm.go b/server/fsm.go
index 2de4787e..66762ca3 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -40,6 +40,7 @@ type fsmMsg struct {
MsgType fsmMsgType
MsgSrc string
MsgData interface{}
+ PathList []*table.Path
}
const (
@@ -503,6 +504,10 @@ func (h *FSMHandler) recvMessageWithError() error {
"error": err,
}).Warn("malformed BGP update message")
fmsg.MsgData = err
+ } else {
+ // FIXME: we should use the original message for bmp/mrt
+ table.UpdatePathAttrs4ByteAs(body)
+ fmsg.PathList = table.ProcessMessage(m, h.fsm.peerInfo)
}
fallthrough
case bgp.BGP_MSG_KEEPALIVE:
diff --git a/server/peer.go b/server/peer.go
index 82c61ae9..3009c73e 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -133,7 +133,8 @@ func open2Cap(open *bgp.BGPOpen, n *config.Neighbor) (map[bgp.BGPCapabilityCode]
return capMap, rfMap
}
-func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) ([]*table.Path, bool, []*bgp.BGPMessage) {
+func (peer *Peer) handleBGPmessage(e *fsmMsg) ([]*table.Path, bool, []*bgp.BGPMessage) {
+ m := e.MsgData.(*bgp.BGPMessage)
bgpMsgList := []*bgp.BGPMessage{}
pathList := []*table.Path{}
log.WithFields(log.Fields{
@@ -193,10 +194,8 @@ func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) ([]*table.Path, bool, []*b
case bgp.BGP_MSG_UPDATE:
update = true
peer.conf.Timers.TimersState.UpdateRecvTime = time.Now().Unix()
- body := m.Body.(*bgp.BGPUpdate)
- table.UpdatePathAttrs4ByteAs(body)
- pathList = table.ProcessMessage(m, peer.fsm.peerInfo)
- if len(pathList) > 0 {
+ if len(e.PathList) > 0 {
+ pathList = e.PathList
peer.staleAccepted = true
peer.ApplyPolicy(table.POLICY_DIRECTION_IN, pathList)
peer.adjRib.UpdateIn(pathList)
diff --git a/server/server.go b/server/server.go
index 80c6059a..9c160e8b 100644
--- a/server/server.go
+++ b/server/server.go
@@ -779,7 +779,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *fsmMsg, incoming chan *
case *bgp.MessageError:
msgs = append(msgs, newSenderMsg(peer, []*bgp.BGPMessage{bgp.NewBGPNotificationMessage(m.TypeCode, m.SubTypeCode, m.Data)}))
case *bgp.BGPMessage:
- pathList, update, msgList := peer.handleBGPmessage(m)
+ pathList, update, msgList := peer.handleBGPmessage(e)
if len(msgList) > 0 {
msgs = append(msgs, newSenderMsg(peer, msgList))
break