summaryrefslogtreecommitdiffhomepage
path: root/pkg
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
parent077e3aa5ca05f4d9341f20d19c3bf6c6d8fedb69 (diff)
fixed style: unnecessary type cast after type switch and some minor issues.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/server/bmp.go6
-rw-r--r--pkg/server/fsm.go14
-rw-r--r--pkg/server/rpki.go6
3 files changed, 11 insertions, 15 deletions
diff --git a/pkg/server/bmp.go b/pkg/server/bmp.go
index f96143c7..22be03ae 100644
--- a/pkg/server/bmp.go
+++ b/pkg/server/bmp.go
@@ -192,10 +192,8 @@ func (b *bmpClient) loop() {
}
}
}
- } else {
- if err := write(bmpPeerRoute(bmp.BMP_PEER_TYPE_GLOBAL, msg.PostPolicy, 0, msg.FourBytesAs, info, msg.Timestamp.Unix(), msg.Payload)); err != nil {
- return false
- }
+ } else if err := write(bmpPeerRoute(bmp.BMP_PEER_TYPE_GLOBAL, msg.PostPolicy, 0, msg.FourBytesAs, info, msg.Timestamp.Unix(), msg.Payload)); err != nil {
+ return false
}
case *watchEventBestPath:
info := &table.PeerInfo{
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",
diff --git a/pkg/server/rpki.go b/pkg/server/rpki.go
index 9eb3d2b7..00fbfcfa 100644
--- a/pkg/server/rpki.go
+++ b/pkg/server/rpki.go
@@ -64,10 +64,10 @@ type roaManager struct {
func newROAManager(table *table.ROATable) *roaManager {
m := &roaManager{
- table: table,
+ eventCh: make(chan *roaEvent),
+ clientMap: make(map[string]*roaClient),
+ table: table,
}
- m.eventCh = make(chan *roaEvent)
- m.clientMap = make(map[string]*roaClient)
return m
}