summaryrefslogtreecommitdiffhomepage
path: root/pkg/server/fsm.go
diff options
context:
space:
mode:
authorSergey Elantsev <elantsev.s@yandex.ru>2020-03-09 15:19:17 +0300
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2020-03-11 06:21:16 +0900
commit136c8222c493a9a5a44a89db153571f7ae5d75a5 (patch)
treefaf88fdeabfd8c9a466159c18c09e29992a8f41d /pkg/server/fsm.go
parent077e3aa5ca05f4d9341f20d19c3bf6c6d8fedb69 (diff)
fixed style: unnecessary type cast after type switch and some minor issues.
Diffstat (limited to 'pkg/server/fsm.go')
-rw-r--r--pkg/server/fsm.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/pkg/server/fsm.go b/pkg/server/fsm.go
index 35172bd2..b5bcd2d8 100644
--- a/pkg/server/fsm.go
+++ b/pkg/server/fsm.go
@@ -1254,9 +1254,8 @@ func (h *fsmHandler) opensent(ctx context.Context) (bgp.FSMState, *fsmStateReaso
continue
}
e := i.(*fsmMsg)
- switch e.MsgData.(type) {
+ switch m := e.MsgData.(type) {
case *bgp.BGPMessage:
- m := e.MsgData.(*bgp.BGPMessage)
if m.Header.Type == bgp.BGP_MSG_OPEN {
fsm.lock.Lock()
fsm.recvOpen = m
@@ -1408,8 +1407,8 @@ func (h *fsmHandler) opensent(ctx context.Context) (bgp.FSMState, *fsmStateReaso
return bgp.BGP_FSM_IDLE, newfsmStateReason(fsmInvalidMsg, nil, nil)
}
case *bgp.MessageError:
- m, _ := fsm.sendNotificationFromErrorMsg(e.MsgData.(*bgp.MessageError))
- return bgp.BGP_FSM_IDLE, newfsmStateReason(fsmInvalidMsg, m, nil)
+ msg, _ := fsm.sendNotificationFromErrorMsg(m)
+ return bgp.BGP_FSM_IDLE, newfsmStateReason(fsmInvalidMsg, msg, nil)
default:
log.WithFields(log.Fields{
"Topic": "Peer",
@@ -1524,9 +1523,8 @@ func (h *fsmHandler) openconfirm(ctx context.Context) (bgp.FSMState, *fsmStateRe
continue
}
e := i.(*fsmMsg)
- switch e.MsgData.(type) {
+ switch m := e.MsgData.(type) {
case *bgp.BGPMessage:
- m := e.MsgData.(*bgp.BGPMessage)
if m.Header.Type == bgp.BGP_MSG_KEEPALIVE {
return bgp.BGP_FSM_ESTABLISHED, newfsmStateReason(fsmOpenMsgNegotiated, nil, nil)
}
@@ -1534,8 +1532,8 @@ func (h *fsmHandler) openconfirm(ctx context.Context) (bgp.FSMState, *fsmStateRe
h.conn.Close()
return bgp.BGP_FSM_IDLE, newfsmStateReason(fsmInvalidMsg, nil, nil)
case *bgp.MessageError:
- m, _ := fsm.sendNotificationFromErrorMsg(e.MsgData.(*bgp.MessageError))
- return bgp.BGP_FSM_IDLE, newfsmStateReason(fsmInvalidMsg, m, nil)
+ msg, _ := fsm.sendNotificationFromErrorMsg(m)
+ return bgp.BGP_FSM_IDLE, newfsmStateReason(fsmInvalidMsg, msg, nil)
default:
log.WithFields(log.Fields{
"Topic": "Peer",