diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-03-08 22:05:35 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-03-08 22:05:35 +0900 |
commit | 856fcbd7bdbb25c5fd7cbe6bfa23246323aa5511 (patch) | |
tree | 71fd697ac5dd904f201e81d025f87ecada7c91f1 | |
parent | 1c982d8336c9d89732e8a481a8c90b3e7e283f6f (diff) |
server: adj-in/out supports route families rather than v4/v6
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | server/peer.go | 2 | ||||
-rw-r--r-- | server/peer_test.go | 5 | ||||
-rw-r--r-- | table/table_manager.go | 10 | ||||
-rw-r--r-- | table/table_manager_test.go | 2 |
4 files changed, 10 insertions, 9 deletions
diff --git a/server/peer.go b/server/peer.go index 5bf990de..09c991e6 100644 --- a/server/peer.go +++ b/server/peer.go @@ -92,7 +92,7 @@ func NewPeer(g config.Global, peer config.Neighbor, serverMsgCh chan *serverMsg, LocalID: g.RouterId, Address: peer.NeighborAddress, } - p.adjRib = table.NewAdjRib() + p.adjRib = table.NewAdjRib(rfList) p.rib = table.NewTableManager(p.peerConfig.NeighborAddress.String(), rfList) p.t.Go(p.loop) return p diff --git a/server/peer_test.go b/server/peer_test.go index a4c60de7..cceb6992 100644 --- a/server/peer_test.go +++ b/server/peer_test.go @@ -524,8 +524,9 @@ func makePeer(globalConfig config.Global, peerConfig config.Neighbor) *Peer { LocalID: globalConfig.RouterId, Address: peerConfig.NeighborAddress, } - p.adjRib = table.NewAdjRib() - p.rib = table.NewTableManager(p.peerConfig.NeighborAddress.String(), []bgp.RouteFamily{bgp.RF_IPv4_UC, bgp.RF_IPv6_UC}) + rfList := []bgp.RouteFamily{bgp.RF_IPv4_UC, bgp.RF_IPv6_UC} + p.adjRib = table.NewAdjRib(rfList) + p.rib = table.NewTableManager(p.peerConfig.NeighborAddress.String(), rfList) return p } diff --git a/table/table_manager.go b/table/table_manager.go index e135f58e..d14fec5b 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -287,15 +287,15 @@ type AdjRib struct { adjRibOut map[bgp.RouteFamily]map[string]*ReceivedRoute } -func NewAdjRib() *AdjRib { +func NewAdjRib(rfList []bgp.RouteFamily) *AdjRib { r := &AdjRib{ adjRibIn: make(map[bgp.RouteFamily]map[string]*ReceivedRoute), adjRibOut: make(map[bgp.RouteFamily]map[string]*ReceivedRoute), } - r.adjRibIn[bgp.RF_IPv4_UC] = make(map[string]*ReceivedRoute) - r.adjRibIn[bgp.RF_IPv6_UC] = make(map[string]*ReceivedRoute) - r.adjRibOut[bgp.RF_IPv4_UC] = make(map[string]*ReceivedRoute) - r.adjRibOut[bgp.RF_IPv6_UC] = make(map[string]*ReceivedRoute) + for _, rf := range rfList { + r.adjRibIn[rf] = make(map[string]*ReceivedRoute) + r.adjRibOut[rf] = make(map[string]*ReceivedRoute) + } return r } diff --git a/table/table_manager_test.go b/table/table_manager_test.go index 601a292a..fecee20a 100644 --- a/table/table_manager_test.go +++ b/table/table_manager_test.go @@ -2209,7 +2209,7 @@ func TestProcessBGPUpdate_Timestamp(t *testing.T) { nlri := []bgp.NLRInfo{*bgp.NewNLRInfo(24, "10.10.10.0")} withdrawnRoutes := []bgp.WithdrawnRoute{} - adjRib := NewAdjRib() + adjRib := NewAdjRib([]bgp.RouteFamily{bgp.RF_IPv4_UC, bgp.RF_IPv6_UC}) m1 := bgp.NewBGPUpdateMessage(withdrawnRoutes, pathAttributes, nlri) peer := peerR1() msg1 := NewProcessMessage(m1, peer) |