summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-03-03 12:23:43 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-03-03 12:23:43 +0900
commitf0ae221b894fdd02f697f4fb6994623082e2175e (patch)
treea75e87baad198d843e5201099563713886edfb28 /server
parentd387fd92e71a42e243cedef32f0812c72474c418 (diff)
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 <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/fsm.go8
-rw-r--r--server/fsm_test.go4
-rw-r--r--server/peer.go10
-rw-r--r--server/peer_test.go37
-rw-r--r--server/server.go20
5 files changed, 39 insertions, 40 deletions
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
}