diff options
Diffstat (limited to 'pkg/server')
-rw-r--r-- | pkg/server/bmp.go | 2 | ||||
-rw-r--r-- | pkg/server/fsm.go | 230 | ||||
-rw-r--r-- | pkg/server/fsm_test.go | 8 | ||||
-rw-r--r-- | pkg/server/peer.go | 12 | ||||
-rw-r--r-- | pkg/server/server.go | 58 | ||||
-rw-r--r-- | pkg/server/server_test.go | 2 |
6 files changed, 156 insertions, 156 deletions
diff --git a/pkg/server/bmp.go b/pkg/server/bmp.go index 32daa677..b9821b58 100644 --- a/pkg/server/bmp.go +++ b/pkg/server/bmp.go @@ -274,7 +274,7 @@ func bmpPeerDown(ev *WatchEventPeerState, t uint8, policy bool, pd uint64) *bmp. flags |= bmp.BMP_PEER_FLAG_POST_POLICY } ph := bmp.NewBMPPeerHeader(t, flags, pd, ev.PeerAddress.String(), ev.PeerAS, ev.PeerID.String(), float64(ev.Timestamp.Unix())) - return bmp.NewBMPPeerDownNotification(*ph, uint8(ev.StateReason.PeerDownReason), ev.StateReason.BGPNotification, ev.StateReason.Data) + return bmp.NewBMPPeerDownNotification(*ph, uint8(ev.StateReason.peerDownReason), ev.StateReason.BGPNotification, ev.StateReason.Data) } func bmpPeerRoute(t uint8, policy bool, pd uint64, fourBytesAs bool, peeri *table.PeerInfo, timestamp int64, payload []byte) *bmp.BMPMessage { diff --git a/pkg/server/fsm.go b/pkg/server/fsm.go index 6a8fd942..6fee45f6 100644 --- a/pkg/server/fsm.go +++ b/pkg/server/fsm.go @@ -34,10 +34,10 @@ import ( "gopkg.in/tomb.v2" ) -type PeerDownReason int +type peerDownReason int const ( - PEER_DOWN_REASON_UNKNOWN PeerDownReason = iota + PEER_DOWN_REASON_UNKNOWN peerDownReason = iota PEER_DOWN_BY_LOCAL PEER_DOWN_BY_LOCAL_WITHOUT_NOTIFICATION PEER_DOWN_BY_REMOTE @@ -45,10 +45,10 @@ const ( PEER_DOWN_BY_BMP_CONFIGURATION ) -type FsmStateReasonType uint8 +type fsmStateReasonType uint8 const ( - FSM_DYING FsmStateReasonType = iota + FSM_DYING fsmStateReasonType = iota FSM_ADMIN_DOWN FSM_READ_FAILED FSM_WRITE_FAILED @@ -65,15 +65,15 @@ const ( FSM_HARD_RESET ) -type FsmStateReason struct { - Type FsmStateReasonType - PeerDownReason PeerDownReason +type fsmStateReason struct { + Type fsmStateReasonType + peerDownReason peerDownReason BGPNotification *bgp.BGPMessage Data []byte } -func NewFsmStateReason(typ FsmStateReasonType, notif *bgp.BGPMessage, data []byte) *FsmStateReason { - var reasonCode PeerDownReason +func newfsmStateReason(typ fsmStateReasonType, notif *bgp.BGPMessage, data []byte) *fsmStateReason { + var reasonCode peerDownReason switch typ { case FSM_DYING, FSM_INVALID_MSG, FSM_NOTIFICATION_SENT, FSM_HOLD_TIMER_EXPIRED, FSM_IDLE_HOLD_TIMER_EXPIRED, FSM_RESTART_TIMER_EXPIRED: reasonCode = PEER_DOWN_BY_LOCAL @@ -84,15 +84,15 @@ func NewFsmStateReason(typ FsmStateReasonType, notif *bgp.BGPMessage, data []byt case FSM_READ_FAILED, FSM_WRITE_FAILED: reasonCode = PEER_DOWN_BY_REMOTE_WITHOUT_NOTIFICATION } - return &FsmStateReason{ + return &fsmStateReason{ Type: typ, - PeerDownReason: reasonCode, + peerDownReason: reasonCode, BGPNotification: notif, Data: data, } } -func (r FsmStateReason) String() string { +func (r fsmStateReason) String() string { switch r.Type { case FSM_DYING: return "dying" @@ -131,46 +131,46 @@ func (r FsmStateReason) String() string { } } -type FsmMsgType int +type fsmMsgType int const ( - _ FsmMsgType = iota + _ fsmMsgType = iota FSM_MSG_STATE_CHANGE FSM_MSG_BGP_MESSAGE FSM_MSG_ROUTE_REFRESH ) -type FsmMsg struct { - MsgType FsmMsgType +type fsmMsg struct { + MsgType fsmMsgType MsgSrc string MsgData interface{} - StateReason *FsmStateReason + StateReason *fsmStateReason PathList []*table.Path timestamp time.Time payload []byte Version uint } -type FsmOutgoingMsg struct { +type fsmOutgoingMsg struct { Paths []*table.Path Notification *bgp.BGPMessage StayIdle bool } const ( - HOLDTIME_OPENSENT = 240 - HOLDTIME_IDLE = 5 + holdtimeOpensent = 240 + holdtimeIdle = 5 ) -type AdminState int +type adminState int const ( - ADMIN_STATE_UP AdminState = iota + ADMIN_STATE_UP adminState = iota ADMIN_STATE_DOWN ADMIN_STATE_PFX_CT ) -func (s AdminState) String() string { +func (s adminState) String() string { switch s { case ADMIN_STATE_UP: return "ADMIN_STATE_UP" @@ -183,28 +183,28 @@ func (s AdminState) String() string { } } -type AdminStateOperation struct { - State AdminState +type adminStateOperation struct { + State adminState Communication []byte } var fsmVersion uint -type FSM struct { +type fsm struct { t tomb.Tomb gConf *config.Global pConf *config.Neighbor lock sync.RWMutex state bgp.FSMState - reason *FsmStateReason + reason *fsmStateReason conn net.Conn connCh chan net.Conn idleHoldTime float64 opensentHoldTime float64 - adminState AdminState - adminStateCh chan AdminStateOperation + adminState adminState + adminStateCh chan adminStateOperation getActiveCh chan struct{} - h *FSMHandler + h *fsmHandler rfMap map[bgp.RouteFamily]bgp.BGPAddPathMode capMap map[bgp.BGPCapabilityCode][]bgp.ParameterCapabilityInterface recvOpen *bgp.BGPMessage @@ -216,7 +216,7 @@ type FSM struct { marshallingOptions *bgp.MarshallingOption } -func (fsm *FSM) bgpMessageStateUpdate(MessageType uint8, isIn bool) { +func (fsm *fsm) bgpMessageStateUpdate(MessageType uint8, isIn bool) { fsm.lock.Lock() defer fsm.lock.Unlock() state := &fsm.pConf.State.Messages @@ -267,7 +267,7 @@ func (fsm *FSM) bgpMessageStateUpdate(MessageType uint8, isIn bool) { } } -func (fsm *FSM) bmpStatsUpdate(statType uint16, increment int) { +func (fsm *fsm) bmpStatsUpdate(statType uint16, increment int) { fsm.lock.Lock() defer fsm.lock.Unlock() stats := &fsm.pConf.State.Messages.Received @@ -281,7 +281,7 @@ func (fsm *FSM) bmpStatsUpdate(statType uint16, increment int) { } } -func NewFSM(gConf *config.Global, pConf *config.Neighbor, policy *table.RoutingPolicy) *FSM { +func newFSM(gConf *config.Global, pConf *config.Neighbor, policy *table.RoutingPolicy) *fsm { adminState := ADMIN_STATE_UP if pConf.Config.AdminDown { adminState = ADMIN_STATE_DOWN @@ -289,14 +289,14 @@ func NewFSM(gConf *config.Global, pConf *config.Neighbor, policy *table.RoutingP pConf.State.SessionState = config.IntToSessionStateMap[int(bgp.BGP_FSM_IDLE)] pConf.Timers.State.Downtime = time.Now().Unix() fsmVersion++ - fsm := &FSM{ + fsm := &fsm{ gConf: gConf, pConf: pConf, state: bgp.BGP_FSM_IDLE, connCh: make(chan net.Conn, 1), - opensentHoldTime: float64(HOLDTIME_OPENSENT), + opensentHoldTime: float64(holdtimeOpensent), adminState: adminState, - adminStateCh: make(chan AdminStateOperation, 1), + adminStateCh: make(chan adminStateOperation, 1), getActiveCh: make(chan struct{}), rfMap: make(map[bgp.RouteFamily]bgp.BGPAddPathMode), capMap: make(map[bgp.BGPCapabilityCode][]bgp.ParameterCapabilityInterface), @@ -310,7 +310,7 @@ func NewFSM(gConf *config.Global, pConf *config.Neighbor, policy *table.RoutingP return fsm } -func (fsm *FSM) StateChange(nextState bgp.FSMState) { +func (fsm *fsm) StateChange(nextState bgp.FSMState) { fsm.lock.Lock() defer fsm.lock.Unlock() @@ -366,16 +366,16 @@ func hostport(addr net.Addr) (string, uint16) { return "", 0 } -func (fsm *FSM) RemoteHostPort() (string, uint16) { +func (fsm *fsm) RemoteHostPort() (string, uint16) { return hostport(fsm.conn.RemoteAddr()) } -func (fsm *FSM) LocalHostPort() (string, uint16) { +func (fsm *fsm) LocalHostPort() (string, uint16) { return hostport(fsm.conn.LocalAddr()) } -func (fsm *FSM) sendNotificationFromErrorMsg(e *bgp.MessageError) (*bgp.BGPMessage, error) { +func (fsm *fsm) sendNotificationFromErrorMsg(e *bgp.MessageError) (*bgp.BGPMessage, error) { fsm.lock.RLock() established := fsm.h != nil && fsm.h.conn != nil fsm.lock.RUnlock() @@ -399,12 +399,12 @@ func (fsm *FSM) sendNotificationFromErrorMsg(e *bgp.MessageError) (*bgp.BGPMessa return nil, fmt.Errorf("can't send notification to %s since TCP connection is not established", fsm.pConf.State.NeighborAddress) } -func (fsm *FSM) sendNotification(code, subType uint8, data []byte, msg string) (*bgp.BGPMessage, error) { +func (fsm *fsm) sendNotification(code, subType uint8, data []byte, msg string) (*bgp.BGPMessage, error) { e := bgp.NewMessageError(code, subType, data, msg) return fsm.sendNotificationFromErrorMsg(e.(*bgp.MessageError)) } -func (fsm *FSM) connectLoop() error { +func (fsm *fsm) connectLoop() error { fsm.lock.RLock() tick := int(fsm.pConf.Timers.Config.ConnectRetry) fsm.lock.RUnlock() @@ -498,23 +498,23 @@ func (fsm *FSM) connectLoop() error { } } -type FSMHandler struct { +type fsmHandler struct { t tomb.Tomb - fsm *FSM + fsm *fsm conn net.Conn msgCh *channels.InfiniteChannel - stateReasonCh chan FsmStateReason + stateReasonCh chan fsmStateReason incoming *channels.InfiniteChannel - stateCh chan *FsmMsg + stateCh chan *fsmMsg outgoing *channels.InfiniteChannel holdTimerResetCh chan bool sentNotification *bgp.BGPMessage } -func NewFSMHandler(fsm *FSM, incoming *channels.InfiniteChannel, stateCh chan *FsmMsg, outgoing *channels.InfiniteChannel) *FSMHandler { - h := &FSMHandler{ +func newFSMHandler(fsm *fsm, incoming *channels.InfiniteChannel, stateCh chan *fsmMsg, outgoing *channels.InfiniteChannel) *fsmHandler { + h := &fsmHandler{ fsm: fsm, - stateReasonCh: make(chan FsmStateReason, 2), + stateReasonCh: make(chan fsmStateReason, 2), incoming: incoming, stateCh: stateCh, outgoing: outgoing, @@ -524,7 +524,7 @@ func NewFSMHandler(fsm *FSM, incoming *channels.InfiniteChannel, stateCh chan *F return h } -func (h *FSMHandler) idle() (bgp.FSMState, *FsmStateReason) { +func (h *fsmHandler) idle() (bgp.FSMState, *fsmStateReason) { fsm := h.fsm fsm.lock.RLock() @@ -534,7 +534,7 @@ func (h *FSMHandler) idle() (bgp.FSMState, *FsmStateReason) { for { select { case <-h.t.Dying(): - return -1, NewFsmStateReason(FSM_DYING, nil, nil) + return -1, newfsmStateReason(FSM_DYING, nil, nil) case <-fsm.gracefulRestartTimer.C: fsm.lock.RLock() restarting := fsm.pConf.GracefulRestart.State.PeerRestarting @@ -548,7 +548,7 @@ func (h *FSMHandler) idle() (bgp.FSMState, *FsmStateReason) { "State": fsm.state.String(), }).Warn("graceful restart timer expired") fsm.lock.RUnlock() - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_RESTART_TIMER_EXPIRED, nil, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_RESTART_TIMER_EXPIRED, nil, nil) } case conn, ok := <-fsm.connCh: if !ok { @@ -575,16 +575,16 @@ func (h *FSMHandler) idle() (bgp.FSMState, *FsmStateReason) { "Key": fsm.pConf.State.NeighborAddress, "Duration": fsm.idleHoldTime, }).Debug("IdleHoldTimer expired") - fsm.idleHoldTime = HOLDTIME_IDLE + fsm.idleHoldTime = holdtimeIdle fsm.lock.Unlock() - return bgp.BGP_FSM_ACTIVE, NewFsmStateReason(FSM_IDLE_HOLD_TIMER_EXPIRED, nil, nil) + return bgp.BGP_FSM_ACTIVE, newfsmStateReason(FSM_IDLE_HOLD_TIMER_EXPIRED, nil, nil) } else { log.WithFields(log.Fields{"Topic": "Peer"}).Debug("IdleHoldTimer expired, but stay at idle because the admin state is DOWN") } case stateOp := <-fsm.adminStateCh: - err := h.changeAdminState(stateOp.State) + err := h.changeadminState(stateOp.State) if err == nil { switch stateOp.State { case ADMIN_STATE_DOWN: @@ -602,12 +602,12 @@ func (h *FSMHandler) idle() (bgp.FSMState, *FsmStateReason) { } } -func (h *FSMHandler) active() (bgp.FSMState, *FsmStateReason) { +func (h *fsmHandler) active() (bgp.FSMState, *fsmStateReason) { fsm := h.fsm for { select { case <-h.t.Dying(): - return -1, NewFsmStateReason(FSM_DYING, nil, nil) + return -1, newfsmStateReason(FSM_DYING, nil, nil) case conn, ok := <-fsm.connCh: if !ok { break @@ -654,7 +654,7 @@ func (h *FSMHandler) active() (bgp.FSMState, *FsmStateReason) { fsm.lock.RUnlock() // we don't implement delayed open timer so move to opensent right // away. - return bgp.BGP_FSM_OPENSENT, NewFsmStateReason(FSM_NEW_CONNECTION, nil, nil) + return bgp.BGP_FSM_OPENSENT, newfsmStateReason(FSM_NEW_CONNECTION, nil, nil) case <-fsm.gracefulRestartTimer.C: fsm.lock.RLock() restarting := fsm.pConf.GracefulRestart.State.PeerRestarting @@ -667,22 +667,22 @@ func (h *FSMHandler) active() (bgp.FSMState, *FsmStateReason) { "State": fsm.state.String(), }).Warn("graceful restart timer expired") fsm.lock.RUnlock() - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_RESTART_TIMER_EXPIRED, nil, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_RESTART_TIMER_EXPIRED, nil, nil) } case err := <-h.stateReasonCh: return bgp.BGP_FSM_IDLE, &err case stateOp := <-fsm.adminStateCh: - err := h.changeAdminState(stateOp.State) + err := h.changeadminState(stateOp.State) if err == nil { switch stateOp.State { case ADMIN_STATE_DOWN: - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_ADMIN_DOWN, nil, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_ADMIN_DOWN, nil, nil) case ADMIN_STATE_UP: log.WithFields(log.Fields{ "Topic": "Peer", "Key": fsm.pConf.State.NeighborAddress, "State": fsm.state.String(), - "AdminState": stateOp.State.String(), + "adminState": stateOp.State.String(), }).Panic("code logic bug") } } @@ -842,7 +842,7 @@ func extractRouteFamily(p *bgp.PathAttributeInterface) *bgp.RouteFamily { return &rf } -func (h *FSMHandler) afiSafiDisable(rf bgp.RouteFamily) string { +func (h *fsmHandler) afiSafiDisable(rf bgp.RouteFamily) string { h.fsm.lock.Lock() defer h.fsm.lock.Unlock() @@ -865,7 +865,7 @@ func (h *FSMHandler) afiSafiDisable(rf bgp.RouteFamily) string { return n } -func (h *FSMHandler) handlingError(m *bgp.BGPMessage, e error, useRevisedError bool) bgp.ErrorHandling { +func (h *fsmHandler) handlingError(m *bgp.BGPMessage, e error, useRevisedError bool) bgp.ErrorHandling { handling := bgp.ERROR_HANDLING_NONE if m.Header.Type == bgp.BGP_MSG_UPDATE && useRevisedError { factor := e.(*bgp.MessageError) @@ -918,11 +918,11 @@ func (h *FSMHandler) handlingError(m *bgp.BGPMessage, e error, useRevisedError b return handling } -func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) { - sendToStateReasonCh := func(typ FsmStateReasonType, notif *bgp.BGPMessage) { +func (h *fsmHandler) recvMessageWithError() (*fsmMsg, error) { + sendToStateReasonCh := func(typ fsmStateReasonType, notif *bgp.BGPMessage) { // probably doesn't happen but be cautious select { - case h.stateReasonCh <- *NewFsmStateReason(typ, notif, nil): + case h.stateReasonCh <- *newfsmStateReason(typ, notif, nil): default: } } @@ -944,7 +944,7 @@ func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) { "State": h.fsm.state.String(), "error": err, }).Warn("Session will be reset due to malformed BGP Header") - fmsg := &FsmMsg{ + fmsg := &fsmMsg{ MsgType: FSM_MSG_BGP_MESSAGE, MsgSrc: h.fsm.pConf.State.NeighborAddress, MsgData: err, @@ -977,7 +977,7 @@ func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) { err = bgp.ValidateBGPMessage(m) } h.fsm.lock.RLock() - fmsg := &FsmMsg{ + fmsg := &fsmMsg{ MsgType: FSM_MSG_BGP_MESSAGE, MsgSrc: h.fsm.pConf.State.NeighborAddress, timestamp: now, @@ -1115,7 +1115,7 @@ func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) { return fmsg, nil } -func (h *FSMHandler) recvMessage() error { +func (h *fsmHandler) recvMessage() error { defer h.msgCh.Close() fmsg, _ := h.recvMessageWithError() if fmsg != nil { @@ -1181,7 +1181,7 @@ func open2Cap(open *bgp.BGPOpen, n *config.Neighbor) (map[bgp.BGPCapabilityCode] return capMap, negotiated } -func (h *FSMHandler) opensent() (bgp.FSMState, *FsmStateReason) { +func (h *fsmHandler) opensent() (bgp.FSMState, *fsmStateReason) { fsm := h.fsm fsm.lock.RLock() @@ -1212,7 +1212,7 @@ func (h *FSMHandler) opensent() (bgp.FSMState, *FsmStateReason) { select { case <-h.t.Dying(): h.conn.Close() - return -1, NewFsmStateReason(FSM_DYING, nil, nil) + return -1, newfsmStateReason(FSM_DYING, nil, nil) case conn, ok := <-fsm.connCh: if !ok { break @@ -1238,13 +1238,13 @@ func (h *FSMHandler) opensent() (bgp.FSMState, *FsmStateReason) { }).Warn("graceful restart timer expired") fsm.lock.RUnlock() h.conn.Close() - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_RESTART_TIMER_EXPIRED, nil, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_RESTART_TIMER_EXPIRED, nil, nil) } case i, ok := <-h.msgCh.Out(): if !ok { continue } - e := i.(*FsmMsg) + e := i.(*fsmMsg) switch e.MsgData.(type) { case *bgp.BGPMessage: m := e.MsgData.(*bgp.BGPMessage) @@ -1261,7 +1261,7 @@ func (h *FSMHandler) opensent() (bgp.FSMState, *FsmStateReason) { peerAs, err := bgp.ValidateOpenMsg(body, fsmPeerAS) if err != nil { m, _ := fsm.sendNotificationFromErrorMsg(err.(*bgp.MessageError)) - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_INVALID_MSG, m, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_INVALID_MSG, m, nil) } // ASN negotiation was skipped @@ -1350,7 +1350,7 @@ func (h *FSMHandler) opensent() (bgp.FSMState, *FsmStateReason) { // send notification? h.conn.Close() fsm.lock.Unlock() - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_INVALID_MSG, nil, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_INVALID_MSG, nil, nil) } // RFC 4724 3 @@ -1395,15 +1395,15 @@ func (h *FSMHandler) opensent() (bgp.FSMState, *FsmStateReason) { b, _ := msg.Serialize() fsm.conn.Write(b) fsm.bgpMessageStateUpdate(msg.Header.Type, false) - return bgp.BGP_FSM_OPENCONFIRM, NewFsmStateReason(FSM_OPEN_MSG_RECEIVED, nil, nil) + return bgp.BGP_FSM_OPENCONFIRM, newfsmStateReason(FSM_OPEN_MSG_RECEIVED, nil, nil) } else { // send notification? h.conn.Close() - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_INVALID_MSG, nil, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_INVALID_MSG, nil, nil) } case *bgp.MessageError: m, _ := fsm.sendNotificationFromErrorMsg(e.MsgData.(*bgp.MessageError)) - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_INVALID_MSG, m, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_INVALID_MSG, m, nil) default: log.WithFields(log.Fields{ "Topic": "Peer", @@ -1418,20 +1418,20 @@ func (h *FSMHandler) opensent() (bgp.FSMState, *FsmStateReason) { case <-holdTimer.C: m, _ := fsm.sendNotification(bgp.BGP_ERROR_HOLD_TIMER_EXPIRED, 0, nil, "hold timer expired") h.t.Kill(nil) - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_HOLD_TIMER_EXPIRED, m, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_HOLD_TIMER_EXPIRED, m, nil) case stateOp := <-fsm.adminStateCh: - err := h.changeAdminState(stateOp.State) + err := h.changeadminState(stateOp.State) if err == nil { switch stateOp.State { case ADMIN_STATE_DOWN: h.conn.Close() - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_ADMIN_DOWN, m, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_ADMIN_DOWN, m, nil) case ADMIN_STATE_UP: log.WithFields(log.Fields{ "Topic": "Peer", "Key": fsm.pConf.State.NeighborAddress, "State": fsm.state.String(), - "AdminState": stateOp.State.String(), + "adminState": stateOp.State.String(), }).Panic("code logic bug") } } @@ -1439,7 +1439,7 @@ func (h *FSMHandler) opensent() (bgp.FSMState, *FsmStateReason) { } } -func keepaliveTicker(fsm *FSM) *time.Ticker { +func keepaliveTicker(fsm *fsm) *time.Ticker { fsm.lock.RLock() defer fsm.lock.RUnlock() @@ -1454,7 +1454,7 @@ func keepaliveTicker(fsm *FSM) *time.Ticker { return time.NewTicker(sec) } -func (h *FSMHandler) openconfirm() (bgp.FSMState, *FsmStateReason) { +func (h *fsmHandler) openconfirm() (bgp.FSMState, *fsmStateReason) { fsm := h.fsm ticker := keepaliveTicker(fsm) h.msgCh = channels.NewInfiniteChannel() @@ -1477,7 +1477,7 @@ func (h *FSMHandler) openconfirm() (bgp.FSMState, *FsmStateReason) { select { case <-h.t.Dying(): h.conn.Close() - return -1, NewFsmStateReason(FSM_DYING, nil, nil) + return -1, newfsmStateReason(FSM_DYING, nil, nil) case conn, ok := <-fsm.connCh: if !ok { break @@ -1503,7 +1503,7 @@ func (h *FSMHandler) openconfirm() (bgp.FSMState, *FsmStateReason) { }).Warn("graceful restart timer expired") fsm.lock.RUnlock() h.conn.Close() - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_RESTART_TIMER_EXPIRED, nil, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_RESTART_TIMER_EXPIRED, nil, nil) } case <-ticker.C: m := bgp.NewBGPKeepAliveMessage() @@ -1515,19 +1515,19 @@ func (h *FSMHandler) openconfirm() (bgp.FSMState, *FsmStateReason) { if !ok { continue } - e := i.(*FsmMsg) + e := i.(*fsmMsg) switch 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(FSM_OPEN_MSG_NEGOTIATED, nil, nil) + return bgp.BGP_FSM_ESTABLISHED, newfsmStateReason(FSM_OPEN_MSG_NEGOTIATED, nil, nil) } // send notification ? h.conn.Close() - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_INVALID_MSG, nil, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_INVALID_MSG, nil, nil) case *bgp.MessageError: m, _ := fsm.sendNotificationFromErrorMsg(e.MsgData.(*bgp.MessageError)) - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_INVALID_MSG, m, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_INVALID_MSG, m, nil) default: log.WithFields(log.Fields{ "Topic": "Peer", @@ -1542,20 +1542,20 @@ func (h *FSMHandler) openconfirm() (bgp.FSMState, *FsmStateReason) { case <-holdTimer.C: m, _ := fsm.sendNotification(bgp.BGP_ERROR_HOLD_TIMER_EXPIRED, 0, nil, "hold timer expired") h.t.Kill(nil) - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_HOLD_TIMER_EXPIRED, m, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_HOLD_TIMER_EXPIRED, m, nil) case stateOp := <-fsm.adminStateCh: - err := h.changeAdminState(stateOp.State) + err := h.changeadminState(stateOp.State) if err == nil { switch stateOp.State { case ADMIN_STATE_DOWN: h.conn.Close() - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_ADMIN_DOWN, nil, nil) + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_ADMIN_DOWN, nil, nil) case ADMIN_STATE_UP: log.WithFields(log.Fields{ "Topic": "Peer", "Key": fsm.pConf.State.NeighborAddress, "State": fsm.state.String(), - "AdminState": stateOp.State.String(), + "adminState": stateOp.State.String(), }).Panic("code logic bug") } } @@ -1563,7 +1563,7 @@ func (h *FSMHandler) openconfirm() (bgp.FSMState, *FsmStateReason) { } } -func (h *FSMHandler) sendMessageloop() error { +func (h *fsmHandler) sendMessageloop() error { conn := h.conn fsm := h.fsm ticker := keepaliveTicker(fsm) @@ -1597,7 +1597,7 @@ func (h *FSMHandler) sendMessageloop() error { err = conn.SetWriteDeadline(time.Now().Add(time.Second * time.Duration(fsm.pConf.Timers.State.NegotiatedHoldTime))) fsm.lock.RUnlock() if err != nil { - h.stateReasonCh <- *NewFsmStateReason(FSM_WRITE_FAILED, nil, nil) + h.stateReasonCh <- *newfsmStateReason(FSM_WRITE_FAILED, nil, nil) conn.Close() return fmt.Errorf("failed to set write deadline") } @@ -1611,7 +1611,7 @@ func (h *FSMHandler) sendMessageloop() error { "Data": err, }).Warn("failed to send") fsm.lock.RUnlock() - h.stateReasonCh <- *NewFsmStateReason(FSM_WRITE_FAILED, nil, nil) + h.stateReasonCh <- *newfsmStateReason(FSM_WRITE_FAILED, nil, nil) conn.Close() return fmt.Errorf("closed") } @@ -1645,7 +1645,7 @@ func (h *FSMHandler) sendMessageloop() error { }).Warn("sent notification") fsm.lock.RUnlock() } - h.stateReasonCh <- *NewFsmStateReason(FSM_NOTIFICATION_SENT, m, nil) + h.stateReasonCh <- *newfsmStateReason(FSM_NOTIFICATION_SENT, m, nil) conn.Close() return fmt.Errorf("closed") case bgp.BGP_MSG_UPDATE: @@ -1678,7 +1678,7 @@ func (h *FSMHandler) sendMessageloop() error { case <-h.t.Dying(): return nil case o := <-h.outgoing.Out(): - m := o.(*FsmOutgoingMsg) + m := o.(*fsmOutgoingMsg) h.fsm.lock.RLock() options := h.fsm.marshallingOptions h.fsm.lock.RUnlock() @@ -1691,7 +1691,7 @@ func (h *FSMHandler) sendMessageloop() error { if m.StayIdle { // current user is only prefix-limit // fix me if this is not the case - h.changeAdminState(ADMIN_STATE_PFX_CT) + h.changeadminState(ADMIN_STATE_PFX_CT) } if err := send(m.Notification); err != nil { return nil @@ -1705,7 +1705,7 @@ func (h *FSMHandler) sendMessageloop() error { } } -func (h *FSMHandler) recvMessageloop() error { +func (h *fsmHandler) recvMessageloop() error { for { fmsg, err := h.recvMessageWithError() if fmsg != nil { @@ -1717,7 +1717,7 @@ func (h *FSMHandler) recvMessageloop() error { } } -func (h *FSMHandler) established() (bgp.FSMState, *FsmStateReason) { +func (h *fsmHandler) established() (bgp.FSMState, *fsmStateReason) { fsm := h.fsm fsm.lock.Lock() h.conn = fsm.conn @@ -1740,7 +1740,7 @@ func (h *FSMHandler) established() (bgp.FSMState, *FsmStateReason) { for { select { case <-h.t.Dying(): - return -1, NewFsmStateReason(FSM_DYING, nil, nil) + return -1, newfsmStateReason(FSM_DYING, nil, nil) case conn, ok := <-fsm.connCh: if !ok { break @@ -1761,7 +1761,7 @@ func (h *FSMHandler) established() (bgp.FSMState, *FsmStateReason) { (s.NotificationEnabled && err.Type == FSM_NOTIFICATION_RECV || err.Type == FSM_READ_FAILED || err.Type == FSM_WRITE_FAILED) { - err = *NewFsmStateReason(FSM_GRACEFUL_RESTART, nil, nil) + err = *newfsmStateReason(FSM_GRACEFUL_RESTART, nil, nil) log.WithFields(log.Fields{ "Topic": "Peer", "Key": fsm.pConf.State.NeighborAddress, @@ -1780,8 +1780,8 @@ func (h *FSMHandler) established() (bgp.FSMState, *FsmStateReason) { }).Warn("hold timer expired") fsm.lock.RUnlock() m := bgp.NewBGPNotificationMessage(bgp.BGP_ERROR_HOLD_TIMER_EXPIRED, 0, nil) - h.outgoing.In() <- &FsmOutgoingMsg{Notification: m} - return bgp.BGP_FSM_IDLE, NewFsmStateReason(FSM_HOLD_TIMER_EXPIRED, m, nil) + h.outgoing.In() <- &fsmOutgoingMsg{Notification: m} + return bgp.BGP_FSM_IDLE, newfsmStateReason(FSM_HOLD_TIMER_EXPIRED, m, nil) case <-h.holdTimerResetCh: fsm.lock.RLock() if fsm.pConf.Timers.State.NegotiatedHoldTime != 0 { @@ -1789,26 +1789,26 @@ func (h *FSMHandler) established() (bgp.FSMState, *FsmStateReason) { } fsm.lock.RUnlock() case stateOp := <-fsm.adminStateCh: - err := h.changeAdminState(stateOp.State) + err := h.changeadminState(stateOp.State) if err == nil { switch stateOp.State { case ADMIN_STATE_DOWN: m := bgp.NewBGPNotificationMessage(bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_ADMINISTRATIVE_SHUTDOWN, stateOp.Communication) - h.outgoing.In() <- &FsmOutgoingMsg{Notification: m} + h.outgoing.In() <- &fsmOutgoingMsg{Notification: m} } } } } } -func (h *FSMHandler) loop() error { +func (h *fsmHandler) loop() error { fsm := h.fsm ch := make(chan bgp.FSMState) fsm.lock.RLock() oldState := fsm.state fsm.lock.RUnlock() - var reason *FsmStateReason + var reason *fsmStateReason f := func() error { nextState := bgp.FSMState(-1) fsm.lock.RLock() @@ -1852,7 +1852,7 @@ func (h *FSMHandler) loop() error { reason := fsm.reason if fsm.h.sentNotification != nil { reason.Type = FSM_NOTIFICATION_SENT - reason.PeerDownReason = PEER_DOWN_BY_LOCAL + reason.peerDownReason = PEER_DOWN_BY_LOCAL reason.BGPNotification = fsm.h.sentNotification } log.WithFields(log.Fields{ @@ -1873,7 +1873,7 @@ func (h *FSMHandler) loop() error { // under zero means that tomb.Dying() if nextState >= bgp.BGP_FSM_IDLE { fsm.lock.RLock() - h.stateCh <- &FsmMsg{ + h.stateCh <- &fsmMsg{ MsgType: FSM_MSG_STATE_CHANGE, MsgSrc: fsm.pConf.State.NeighborAddress, MsgData: nextState, @@ -1885,7 +1885,7 @@ func (h *FSMHandler) loop() error { return nil } -func (h *FSMHandler) changeAdminState(s AdminState) error { +func (h *fsmHandler) changeadminState(s adminState) error { h.fsm.lock.Lock() defer h.fsm.lock.Unlock() @@ -1895,7 +1895,7 @@ func (h *FSMHandler) changeAdminState(s AdminState) error { "Topic": "Peer", "Key": fsm.pConf.State.NeighborAddress, "State": fsm.state.String(), - "AdminState": s.String(), + "adminState": s.String(), }).Debug("admin state changed") fsm.adminState = s diff --git a/pkg/server/fsm_test.go b/pkg/server/fsm_test.go index e7daa9b6..1e245a7e 100644 --- a/pkg/server/fsm_test.go +++ b/pkg/server/fsm_test.go @@ -308,15 +308,15 @@ func TestCheckOwnASLoop(t *testing.T) { assert.False(hasOwnASLoop(65200, 0, aspath)) } -func makePeerAndHandler() (*peer, *FSMHandler) { +func makePeerAndHandler() (*peer, *fsmHandler) { p := &peer{ - fsm: NewFSM(&config.Global{}, &config.Neighbor{}, table.NewRoutingPolicy()), + fsm: newFSM(&config.Global{}, &config.Neighbor{}, table.NewRoutingPolicy()), outgoing: channels.NewInfiniteChannel(), } - h := &FSMHandler{ + h := &fsmHandler{ fsm: p.fsm, - stateReasonCh: make(chan FsmStateReason, 2), + stateReasonCh: make(chan fsmStateReason, 2), incoming: channels.NewInfiniteChannel(), outgoing: p.outgoing, } diff --git a/pkg/server/peer.go b/pkg/server/peer.go index 28bf0fee..a33287b7 100644 --- a/pkg/server/peer.go +++ b/pkg/server/peer.go @@ -96,7 +96,7 @@ func newDynamicPeer(g *config.Global, neighborAddress string, pg *config.PeerGro type peer struct { tableId string - fsm *FSM + fsm *fsm adjRibIn *table.AdjRib outgoing *channels.InfiniteChannel policy *table.RoutingPolicy @@ -110,7 +110,7 @@ func newPeer(g *config.Global, conf *config.Neighbor, loc *table.TableManager, p outgoing: channels.NewInfiniteChannel(), localRib: loc, policy: policy, - fsm: NewFSM(g, conf, policy), + fsm: newFSM(g, conf, policy), prefixLimitWarned: make(map[bgp.RouteFamily]bool), } if peer.isRouteServerClient() { @@ -441,7 +441,7 @@ func (peer *peer) updatePrefixLimitConfig(c []config.AfiSafi) error { }).Warnf("update prefix limit configuration") peer.prefixLimitWarned[e.State.Family] = false if msg := peer.doPrefixLimit(e.State.Family, &e.PrefixLimit.Config); msg != nil { - sendFsmOutgoingMsg(peer, nil, msg, true) + sendfsmOutgoingMsg(peer, nil, msg, true) } } } @@ -451,7 +451,7 @@ func (peer *peer) updatePrefixLimitConfig(c []config.AfiSafi) error { return nil } -func (peer *peer) handleUpdate(e *FsmMsg) ([]*table.Path, []bgp.RouteFamily, *bgp.BGPMessage) { +func (peer *peer) handleUpdate(e *fsmMsg) ([]*table.Path, []bgp.RouteFamily, *bgp.BGPMessage) { m := e.MsgData.(*bgp.BGPMessage) update := m.Body.(*bgp.BGPUpdate) log.WithFields(log.Fields{ @@ -526,8 +526,8 @@ func (peer *peer) handleUpdate(e *FsmMsg) ([]*table.Path, []bgp.RouteFamily, *bg return nil, nil, nil } -func (peer *peer) startFSMHandler(incoming *channels.InfiniteChannel, stateCh chan *FsmMsg) { - handler := NewFSMHandler(peer.fsm, incoming, stateCh, peer.outgoing) +func (peer *peer) startFSMHandler(incoming *channels.InfiniteChannel, stateCh chan *fsmMsg) { + handler := newFSMHandler(peer.fsm, incoming, stateCh, peer.outgoing) peer.fsm.lock.Lock() peer.fsm.h = handler peer.fsm.lock.Unlock() diff --git a/pkg/server/server.go b/pkg/server/server.go index f9b1007c..6ebe9b76 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -99,7 +99,7 @@ func newTCPListener(address string, port uint32, ch chan *net.TCPConn) (*tcpList type BgpServer struct { bgpConfig config.Bgp fsmincomingCh *channels.InfiniteChannel - fsmStateCh chan *FsmMsg + fsmStateCh chan *fsmMsg acceptCh chan *net.TCPConn mgmtCh chan *mgmtOp @@ -184,9 +184,9 @@ func (s *BgpServer) mgmtOperation(f func() error, checkActive bool) (err error) func (server *BgpServer) Serve() { server.listeners = make([]*tcpListener, 0, 2) server.fsmincomingCh = channels.NewInfiniteChannel() - server.fsmStateCh = make(chan *FsmMsg, 4096) + server.fsmStateCh = make(chan *fsmMsg, 4096) - handleFsmMsg := func(e *FsmMsg) { + handlefsmMsg := func(e *fsmMsg) { peer, found := server.neighborMap[e.MsgSrc] if !found { log.WithFields(log.Fields{ @@ -306,7 +306,7 @@ func (server *BgpServer) Serve() { for { select { case e := <-server.fsmStateCh: - handleFsmMsg(e) + handlefsmMsg(e) default: goto CONT } @@ -324,9 +324,9 @@ func (server *BgpServer) Serve() { if !ok { continue } - handleFsmMsg(e.(*FsmMsg)) + handlefsmMsg(e.(*fsmMsg)) case e := <-server.fsmStateCh: - handleFsmMsg(e) + handlefsmMsg(e) } } } @@ -349,8 +349,8 @@ func (server *BgpServer) matchLongestDynamicNeighborPrefix(a string) *peerGroup return longestPG } -func sendFsmOutgoingMsg(peer *peer, paths []*table.Path, notification *bgp.BGPMessage, stayIdle bool) { - peer.outgoing.In() <- &FsmOutgoingMsg{ +func sendfsmOutgoingMsg(peer *peer, paths []*table.Path, notification *bgp.BGPMessage, stayIdle bool) { + peer.outgoing.In() <- &fsmOutgoingMsg{ Paths: paths, Notification: notification, StayIdle: stayIdle, @@ -751,7 +751,7 @@ func (server *BgpServer) notifyPostPolicyUpdateWatcher(peer *peer, pathList []*t server.notifyWatcher(WATCH_EVENT_TYPE_POST_UPDATE, ev) } -func newWatchEventPeerState(peer *peer, m *FsmMsg) *WatchEventPeerState { +func newWatchEventPeerState(peer *peer, m *fsmMsg) *WatchEventPeerState { _, rport := peer.fsm.RemoteHostPort() laddr, lport := peer.fsm.LocalHostPort() sentOpen := buildopen(peer.fsm.gConf, peer.fsm.pConf) @@ -780,7 +780,7 @@ func newWatchEventPeerState(peer *peer, m *FsmMsg) *WatchEventPeerState { return e } -func (server *BgpServer) broadcastPeerState(peer *peer, oldState bgp.FSMState, e *FsmMsg) { +func (server *BgpServer) broadcastPeerState(peer *peer, oldState bgp.FSMState, e *fsmMsg) { peer.fsm.lock.RLock() newState := peer.fsm.state peer.fsm.lock.RUnlock() @@ -876,7 +876,7 @@ func (s *BgpServer) processOutgoingPaths(peer *peer, paths, olds []*table.Path) return outgoing } -func (s *BgpServer) handleRouteRefresh(peer *peer, e *FsmMsg) []*table.Path { +func (s *BgpServer) handleRouteRefresh(peer *peer, e *fsmMsg) []*table.Path { m := e.MsgData.(*bgp.BGPMessage) rr := m.Body.(*bgp.BGPRouteRefresh) rf := bgp.AfiSafiToRouteFamily(rr.AFI, rr.SAFI) @@ -1013,7 +1013,7 @@ func (server *BgpServer) propagateUpdate(peer *peer, pathList []*table.Path) { } else { paths = server.processOutgoingPaths(peer, paths, nil) } - sendFsmOutgoingMsg(peer, paths, nil, false) + sendfsmOutgoingMsg(peer, paths, nil, false) } } @@ -1120,12 +1120,12 @@ func (server *BgpServer) propagateUpdateToNeighbors(source *peer, newPath *table oldList = nil } if paths := server.processOutgoingPaths(targetPeer, bestList, oldList); len(paths) > 0 { - sendFsmOutgoingMsg(targetPeer, paths, nil, false) + sendfsmOutgoingMsg(targetPeer, paths, nil, false) } } } -func (server *BgpServer) handleFSMMessage(peer *peer, e *FsmMsg) { +func (server *BgpServer) handleFSMMessage(peer *peer, e *fsmMsg) { switch e.MsgType { case FSM_MSG_STATE_CHANGE: nextState := e.MsgData.(bgp.FSMState) @@ -1305,7 +1305,7 @@ func (server *BgpServer) handleFSMMessage(peer *peer, e *FsmMsg) { } if len(pathList) > 0 { - sendFsmOutgoingMsg(peer, pathList, nil, false) + sendfsmOutgoingMsg(peer, pathList, nil, false) } } else { // RFC 4724 4.1 @@ -1334,7 +1334,7 @@ func (server *BgpServer) handleFSMMessage(peer *peer, e *FsmMsg) { } paths, _ := server.getBestFromLocal(p, p.configuredRFlist()) if len(paths) > 0 { - sendFsmOutgoingMsg(p, paths, nil, false) + sendfsmOutgoingMsg(p, paths, nil, false) } } log.WithFields(log.Fields{ @@ -1394,13 +1394,13 @@ func (server *BgpServer) handleFSMMessage(peer *peer, e *FsmMsg) { return } if paths := server.handleRouteRefresh(peer, e); len(paths) > 0 { - sendFsmOutgoingMsg(peer, paths, nil, false) + sendfsmOutgoingMsg(peer, paths, nil, false) return } case FSM_MSG_BGP_MESSAGE: switch m := e.MsgData.(type) { case *bgp.MessageError: - sendFsmOutgoingMsg(peer, nil, bgp.NewBGPNotificationMessage(m.TypeCode, m.SubTypeCode, m.Data), false) + sendfsmOutgoingMsg(peer, nil, bgp.NewBGPNotificationMessage(m.TypeCode, m.SubTypeCode, m.Data), false) return case *bgp.BGPMessage: server.notifyRecvMessageWatcher(peer, e.timestamp, m) @@ -1413,7 +1413,7 @@ func (server *BgpServer) handleFSMMessage(peer *peer, e *FsmMsg) { } pathList, eor, notification := peer.handleUpdate(e) if notification != nil { - sendFsmOutgoingMsg(peer, nil, notification, true) + sendfsmOutgoingMsg(peer, nil, notification, true) return } if m.Header.Type == bgp.BGP_MSG_UPDATE { @@ -1472,7 +1472,7 @@ func (server *BgpServer) handleFSMMessage(peer *peer, e *FsmMsg) { } paths, _ := server.getBestFromLocal(p, p.negotiatedRFList()) if len(paths) > 0 { - sendFsmOutgoingMsg(p, paths, nil, false) + sendfsmOutgoingMsg(p, paths, nil, false) } } log.WithFields(log.Fields{ @@ -1521,7 +1521,7 @@ func (server *BgpServer) handleFSMMessage(peer *peer, e *FsmMsg) { } } if paths, _ := server.getBestFromLocal(peer, families); len(paths) > 0 { - sendFsmOutgoingMsg(peer, paths, nil, false) + sendfsmOutgoingMsg(peer, paths, nil, false) } } } @@ -2149,14 +2149,14 @@ func (s *BgpServer) softResetOut(addr string, family bgp.RouteFamily, deferral b pathList, filtered := s.getBestFromLocal(peer, families) if len(pathList) > 0 { - sendFsmOutgoingMsg(peer, pathList, nil, false) + sendfsmOutgoingMsg(peer, pathList, nil, false) } if !deferral && len(filtered) > 0 { withdrawnList := make([]*table.Path, 0, len(filtered)) for _, p := range filtered { withdrawnList = append(withdrawnList, p.Clone(true)) } - sendFsmOutgoingMsg(peer, withdrawnList, nil, false) + sendfsmOutgoingMsg(peer, withdrawnList, nil, false) } } return nil @@ -2852,7 +2852,7 @@ func (s *BgpServer) sendNotification(op, addr string, subcode uint8, data []byte if err == nil { m := bgp.NewBGPNotificationMessage(bgp.BGP_ERROR_CEASE, subcode, data) for _, peer := range peers { - sendFsmOutgoingMsg(peer, nil, m, false) + sendfsmOutgoingMsg(peer, nil, m, false) } } return err @@ -2907,7 +2907,7 @@ func (s *BgpServer) setAdminState(addr, communication string, enable bool) error return err } for _, peer := range peers { - f := func(stateOp *AdminStateOperation, message string) { + f := func(stateOp *adminStateOperation, message string) { select { case peer.fsm.adminStateCh <- *stateOp: peer.fsm.lock.RLock() @@ -2923,9 +2923,9 @@ func (s *BgpServer) setAdminState(addr, communication string, enable bool) error } } if enable { - f(&AdminStateOperation{ADMIN_STATE_UP, nil}, "ADMIN_STATE_UP requested") + f(&adminStateOperation{ADMIN_STATE_UP, nil}, "ADMIN_STATE_UP requested") } else { - f(&AdminStateOperation{ADMIN_STATE_DOWN, newAdministrativeCommunication(communication)}, "ADMIN_STATE_DOWN requested") + f(&adminStateOperation{ADMIN_STATE_DOWN, newAdministrativeCommunication(communication)}, "ADMIN_STATE_DOWN requested") } } return nil @@ -3381,8 +3381,8 @@ type WatchEventPeerState struct { SentOpen *bgp.BGPMessage RecvOpen *bgp.BGPMessage State bgp.FSMState - StateReason *FsmStateReason - AdminState AdminState + StateReason *fsmStateReason + AdminState adminState Timestamp time.Time PeerInterface string } diff --git a/pkg/server/server_test.go b/pkg/server/server_test.go index a5141e76..164247f1 100644 --- a/pkg/server/server_test.go +++ b/pkg/server/server_test.go @@ -805,7 +805,7 @@ func TestFamiliesForSoftreset(t *testing.T) { } } peer := &peer{ - fsm: &FSM{ + fsm: &fsm{ pConf: &config.Neighbor{ AfiSafis: []config.AfiSafi{f(bgp.RF_RTC_UC), f(bgp.RF_IPv4_UC), f(bgp.RF_IPv6_UC)}, }, |