From f0ae221b894fdd02f697f4fb6994623082e2175e Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 3 Mar 2015 12:23:43 +0900 Subject: update the whole code for the latest openconfig yang files The modified openconfig yang files are available at: https://github.com/osrg/yang/tree/gobgp Signed-off-by: FUJITA Tomonori --- server/fsm.go | 8 ++++---- server/fsm_test.go | 4 ++-- server/peer.go | 10 +++++----- server/peer_test.go | 37 ++++++++++++++++++------------------- server/server.go | 20 ++++++++++---------- 5 files changed, 39 insertions(+), 40 deletions(-) (limited to 'server') diff --git a/server/fsm.go b/server/fsm.go index 547eafb6..94bfc85d 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -61,8 +61,8 @@ func (s AdminState) String() string { } type FSM struct { - globalConfig *config.GlobalType - peerConfig *config.NeighborType + globalConfig *config.Global + peerConfig *config.Neighbor keepaliveTicker *time.Ticker state bgp.FSMState passiveConn net.Conn @@ -122,7 +122,7 @@ func (fsm *FSM) bgpMessageStateUpdate(MessageType uint8, isIn bool) { } } -func NewFSM(gConfig *config.GlobalType, pConfig *config.NeighborType, connCh chan net.Conn) *FSM { +func NewFSM(gConfig *config.Global, pConfig *config.Neighbor, connCh chan net.Conn) *FSM { return &FSM{ globalConfig: gConfig, peerConfig: pConfig, @@ -287,7 +287,7 @@ func (h *FSMHandler) active() bgp.FSMState { } } -func buildopen(global *config.GlobalType, peerConf *config.NeighborType) *bgp.BGPMessage { +func buildopen(global *config.Global, peerConf *config.Neighbor) *bgp.BGPMessage { var afi int if peerConf.NeighborAddress.To4() != nil { afi = bgp.AFI_IP diff --git a/server/fsm_test.go b/server/fsm_test.go index ff3f1712..01acf6aa 100644 --- a/server/fsm_test.go +++ b/server/fsm_test.go @@ -284,8 +284,8 @@ func TestFSMHandlerEstablished_HoldtimeZero(t *testing.T) { } func makePeerAndHandler() (*Peer, *FSMHandler) { - globalConfig := config.GlobalType{} - neighborConfig := config.NeighborType{} + globalConfig := config.Global{} + neighborConfig := config.Neighbor{} p := &Peer{ globalConfig: globalConfig, diff --git a/server/peer.go b/server/peer.go index 4e8f4ae8..02956788 100644 --- a/server/peer.go +++ b/server/peer.go @@ -47,8 +47,8 @@ type peerMsg struct { type Peer struct { t tomb.Tomb - globalConfig config.GlobalType - peerConfig config.NeighborType + globalConfig config.Global + peerConfig config.Neighbor acceptedConnCh chan net.Conn serverMsgCh chan *serverMsg peerMsgCh chan *peerMsg @@ -65,7 +65,7 @@ type Peer struct { outgoing chan *bgp.BGPMessage } -func NewPeer(g config.GlobalType, peer config.NeighborType, serverMsgCh chan *serverMsg, peerMsgCh chan *peerMsg, peerList []*serverMsgDataPeer) *Peer { +func NewPeer(g config.Global, peer config.Neighbor, serverMsgCh chan *serverMsg, peerMsgCh chan *peerMsg, peerList []*serverMsgDataPeer) *Peer { p := &Peer{ globalConfig: g, peerConfig: peer, @@ -221,7 +221,7 @@ func (peer *Peer) handleREST(restReq *api.RestRequest) { case api.REQ_NEIGHBOR_SHUTDOWN: peer.outgoing <- bgp.NewBGPNotificationMessage(bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_ADMINISTRATIVE_SHUTDOWN, nil) case api.REQ_NEIGHBOR_RESET: - peer.fsm.idleHoldTime = peer.peerConfig.Timers.IdleHoldTImeAfterReset + peer.fsm.idleHoldTime = peer.peerConfig.Timers.IdleHoldTimeAfterReset peer.outgoing <- bgp.NewBGPNotificationMessage(bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_ADMINISTRATIVE_RESET, nil) case api.REQ_NEIGHBOR_SOFT_RESET, api.REQ_NEIGHBOR_SOFT_RESET_IN: // soft-reconfiguration inbound @@ -410,7 +410,7 @@ func (peer *Peer) loop() error { // clear counter if h.fsm.adminState == ADMIN_STATE_DOWN { - h.fsm.peerConfig.BgpNeighborCommonState = config.BgpNeighborCommonStateType{} + h.fsm.peerConfig.BgpNeighborCommonState = config.BgpNeighborCommonState{} } case FSM_MSG_BGP_MESSAGE: diff --git a/server/peer_test.go b/server/peer_test.go index c3612a6e..09ded7c3 100644 --- a/server/peer_test.go +++ b/server/peer_test.go @@ -103,8 +103,8 @@ func TestPeerAdminShutdownWhileEstablished(t *testing.T) { log.SetLevel(log.DebugLevel) assert := assert.New(t) m := NewMockConnection() - globalConfig := config.GlobalType{} - peerConfig := config.NeighborType{} + globalConfig := config.Global{} + peerConfig := config.Neighbor{} peerConfig.PeerAs = 100000 peerConfig.Timers.KeepaliveInterval = 5 peer := makePeer(globalConfig, peerConfig) @@ -155,8 +155,8 @@ func TestPeerAdminShutdownWhileIdle(t *testing.T) { log.SetLevel(log.DebugLevel) assert := assert.New(t) - globalConfig := config.GlobalType{} - peerConfig := config.NeighborType{} + globalConfig := config.Global{} + peerConfig := config.Neighbor{} peerConfig.PeerAs = 100000 peerConfig.Timers.KeepaliveInterval = 5 peer := makePeer(globalConfig, peerConfig) @@ -191,8 +191,8 @@ func TestPeerAdminShutdownWhileActive(t *testing.T) { log.SetLevel(log.DebugLevel) assert := assert.New(t) - globalConfig := config.GlobalType{} - peerConfig := config.NeighborType{} + globalConfig := config.Global{} + peerConfig := config.Neighbor{} peerConfig.PeerAs = 100000 peerConfig.Timers.KeepaliveInterval = 5 peer := makePeer(globalConfig, peerConfig) @@ -226,8 +226,8 @@ func TestPeerAdminShutdownWhileOpensent(t *testing.T) { log.SetLevel(log.DebugLevel) assert := assert.New(t) m := NewMockConnection() - globalConfig := config.GlobalType{} - peerConfig := config.NeighborType{} + globalConfig := config.Global{} + peerConfig := config.Neighbor{} peerConfig.PeerAs = 100000 peerConfig.Timers.KeepaliveInterval = 5 peer := makePeer(globalConfig, peerConfig) @@ -267,8 +267,8 @@ func TestPeerAdminShutdownWhileOpenconfirm(t *testing.T) { log.SetLevel(log.DebugLevel) assert := assert.New(t) m := NewMockConnection() - globalConfig := config.GlobalType{} - peerConfig := config.NeighborType{} + globalConfig := config.Global{} + peerConfig := config.Neighbor{} peerConfig.PeerAs = 100000 peerConfig.Timers.KeepaliveInterval = 5 peer := makePeer(globalConfig, peerConfig) @@ -313,8 +313,8 @@ func TestPeerAdminEnable(t *testing.T) { log.SetLevel(log.DebugLevel) assert := assert.New(t) m := NewMockConnection() - globalConfig := config.GlobalType{} - peerConfig := config.NeighborType{} + globalConfig := config.Global{} + peerConfig := config.Neighbor{} peerConfig.PeerAs = 100000 peerConfig.Timers.KeepaliveInterval = 5 peer := makePeer(globalConfig, peerConfig) @@ -385,8 +385,8 @@ func TestPeerAdminShutdownReject(t *testing.T) { m := NewMockConnection() m.wait = 500 - globalConfig := config.GlobalType{} - peerConfig := config.NeighborType{} + globalConfig := config.Global{} + peerConfig := config.Neighbor{} peerConfig.PeerAs = 100000 peerConfig.Timers.KeepaliveInterval = 5 peer := makePeer(globalConfig, peerConfig) @@ -434,8 +434,8 @@ func TestPeerSelectSmallerHoldtime(t *testing.T) { assert := assert.New(t) m := NewMockConnection() - globalConfig := config.GlobalType{} - peerConfig := config.NeighborType{} + globalConfig := config.Global{} + peerConfig := config.Neighbor{} peerConfig.PeerAs = 65001 peerConfig.Timers.KeepaliveInterval = 5 peer := makePeer(globalConfig, peerConfig) @@ -457,7 +457,7 @@ func TestPeerSelectSmallerHoldtime(t *testing.T) { assert.Equal(float64(0), peer.fsm.negotiatedHoldTime) } -func assertCounter(assert *assert.Assertions, counter config.BgpNeighborCommonStateType) { +func assertCounter(assert *assert.Assertions, counter config.BgpNeighborCommonState) { assert.Equal(uint32(0), counter.OpenIn) assert.Equal(uint32(0), counter.OpenOut) assert.Equal(uint32(0), counter.UpdateIn) @@ -474,7 +474,6 @@ func assertCounter(assert *assert.Assertions, counter config.BgpNeighborCommonSt assert.Equal(uint32(0), counter.DynamicCapIn) assert.Equal(uint32(0), counter.DynamicCapOut) assert.Equal(uint32(0), counter.EstablishedCount) - assert.Equal(uint32(0), counter.DroppedCount) assert.Equal(uint32(0), counter.Flops) } @@ -495,7 +494,7 @@ func waitUntil(assert *assert.Assertions, state bgp.FSMState, peer *Peer, timeou } } -func makePeer(globalConfig config.GlobalType, peerConfig config.NeighborType) *Peer { +func makePeer(globalConfig config.Global, peerConfig config.Neighbor) *Peer { sch := make(chan *serverMsg, 8) pch := make(chan *peerMsg, 4096) diff --git a/server/server.go b/server/server.go index 8fa743bd..39f5fe48 100644 --- a/server/server.go +++ b/server/server.go @@ -56,10 +56,10 @@ type peerMapInfo struct { } type BgpServer struct { - bgpConfig config.BgpType - globalTypeCh chan config.GlobalType - addedPeerCh chan config.NeighborType - deletedPeerCh chan config.NeighborType + bgpConfig config.Bgp + globalTypeCh chan config.Global + addedPeerCh chan config.Neighbor + deletedPeerCh chan config.Neighbor RestReqCh chan *api.RestRequest listenPort int peerMap map[string]peerMapInfo @@ -67,9 +67,9 @@ type BgpServer struct { func NewBgpServer(port int) *BgpServer { b := BgpServer{} - b.globalTypeCh = make(chan config.GlobalType) - b.addedPeerCh = make(chan config.NeighborType) - b.deletedPeerCh = make(chan config.NeighborType) + b.globalTypeCh = make(chan config.Global) + b.addedPeerCh = make(chan config.Neighbor) + b.deletedPeerCh = make(chan config.Neighbor) b.RestReqCh = make(chan *api.RestRequest, 1) b.listenPort = port return &b @@ -203,15 +203,15 @@ func sendServerMsgToAll(peerMap map[string]peerMapInfo, msg *serverMsg) { } } -func (server *BgpServer) SetGlobalType(g config.GlobalType) { +func (server *BgpServer) SetGlobalType(g config.Global) { server.globalTypeCh <- g } -func (server *BgpServer) PeerAdd(peer config.NeighborType) { +func (server *BgpServer) PeerAdd(peer config.Neighbor) { server.addedPeerCh <- peer } -func (server *BgpServer) PeerDelete(peer config.NeighborType) { +func (server *BgpServer) PeerDelete(peer config.Neighbor) { server.deletedPeerCh <- peer } -- cgit v1.2.3