summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-06-09 21:20:07 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-06-09 23:20:15 +0900
commitca832f94bbb1c8e0cecfd7118366a48159512e23 (patch)
tree7197e7bfb41d612be3549ddfa8bd2f3f2c71f2db /table
parenta97129f1400f2be76942124f535fb9831063aa5a (diff)
server: kill peerMsg
Peers send and receive messages via channels, which could lead to a deadlock. With this patch, multiple goroutines are used for network I/Os per peer but one goroutine handle all ribs (including the global rib). So there is no messages via channels between peers. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/destination.go12
-rw-r--r--table/destination_test.go4
-rw-r--r--table/path_test.go4
-rw-r--r--table/table_manager.go15
4 files changed, 20 insertions, 15 deletions
diff --git a/table/destination.go b/table/destination.go
index 16795a89..a58ffbf1 100644
--- a/table/destination.go
+++ b/table/destination.go
@@ -56,7 +56,7 @@ type Destination interface {
setNlri(nlri bgp.AddrPrefixInterface)
getBestPathReason() string
setBestPathReason(string)
- getBestPath() Path
+ GetBestPath() Path
setBestPath(path Path)
getKnownPathList() []Path
setKnownPathList([]Path)
@@ -102,7 +102,7 @@ func (dd *DestinationDefault) ToApiStruct() *api.Destination {
idx := func() int {
for i, p := range dd.knownPathList {
- if p == dd.getBestPath() {
+ if p == dd.GetBestPath() {
return i
}
}
@@ -152,7 +152,7 @@ func (dd *DestinationDefault) setBestPathReason(reason string) {
dd.bestPathReason = reason
}
-func (dd *DestinationDefault) getBestPath() Path {
+func (dd *DestinationDefault) GetBestPath() Path {
return dd.bestPath
}
@@ -906,7 +906,7 @@ func (ipv6d *IPv6Destination) MarshalJSON() ([]byte, error) {
prefix := ipv6d.getNlri().(*bgp.IPv6AddrPrefix).Prefix
idx := func() int {
for i, p := range ipv6d.DestinationDefault.knownPathList {
- if p == ipv6d.DestinationDefault.getBestPath() {
+ if p == ipv6d.DestinationDefault.GetBestPath() {
return i
}
}
@@ -962,7 +962,7 @@ func (ipv4vpnd *IPv4VPNDestination) MarshalJSON() ([]byte, error) {
prefix := ipv4vpnd.getNlri().(*bgp.LabelledVPNIPAddrPrefix).Prefix
idx := func() int {
for i, p := range ipv4vpnd.DestinationDefault.knownPathList {
- if p == ipv4vpnd.DestinationDefault.getBestPath() {
+ if p == ipv4vpnd.DestinationDefault.GetBestPath() {
return i
}
}
@@ -1000,7 +1000,7 @@ func (evpnd *EVPNDestination) MarshalJSON() ([]byte, error) {
nlri := evpnd.getNlri().(*bgp.EVPNNLRI)
idx := func() int {
for i, p := range evpnd.DestinationDefault.knownPathList {
- if p == evpnd.DestinationDefault.getBestPath() {
+ if p == evpnd.DestinationDefault.GetBestPath() {
return i
}
}
diff --git a/table/destination_test.go b/table/destination_test.go
index f6005588..7c30764a 100644
--- a/table/destination_test.go
+++ b/table/destination_test.go
@@ -82,7 +82,7 @@ func TestDestinationSetBestPath(t *testing.T) {
pathD := DestCreatePath(peerD)
ipv4d := NewIPv4Destination(pathD[0].GetNlri())
ipv4d.setBestPath(pathD[0])
- r_pathD := ipv4d.getBestPath()
+ r_pathD := ipv4d.GetBestPath()
assert.Equal(t, r_pathD, pathD[0])
}
func TestDestinationGetBestPath(t *testing.T) {
@@ -90,7 +90,7 @@ func TestDestinationGetBestPath(t *testing.T) {
pathD := DestCreatePath(peerD)
ipv4d := NewIPv4Destination(pathD[0].GetNlri())
ipv4d.setBestPath(pathD[0])
- r_pathD := ipv4d.getBestPath()
+ r_pathD := ipv4d.GetBestPath()
assert.Equal(t, r_pathD, pathD[0])
}
func TestDestinationCalculate(t *testing.T) {
diff --git a/table/path_test.go b/table/path_test.go
index 05aa423d..230a2628 100644
--- a/table/path_test.go
+++ b/table/path_test.go
@@ -152,7 +152,7 @@ func TestASPathLen(t *testing.T) {
bgp.NewAsPathParam(bgp.BGP_ASPATH_ATTR_TYPE_SEQ, []uint16{65001, 65002, 65003, 65004, 65004, 65004, 65004, 65004, 65005}),
bgp.NewAsPathParam(bgp.BGP_ASPATH_ATTR_TYPE_SET, []uint16{65001, 65002, 65003, 65004, 65005}),
bgp.NewAsPathParam(bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SEQ, []uint16{65100, 65101, 65102}),
- bgp.NewAsPathParam(bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET, []uint16{65100, 65101}),}
+ bgp.NewAsPathParam(bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET, []uint16{65100, 65101})}
aspath := bgp.NewPathAttributeAsPath(aspathParam)
nexthop := bgp.NewPathAttributeNextHop("192.168.50.1")
med := bgp.NewPathAttributeMultiExitDisc(0)
@@ -170,7 +170,7 @@ func TestASPathLen(t *testing.T) {
update := bgpmsg.Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(update)
peer := PathCreatePeer()
- p, _:= CreatePath(peer[0], &update.NLRI[0], update.PathAttributes, false, time.Now())
+ p, _ := CreatePath(peer[0], &update.NLRI[0], update.PathAttributes, false, time.Now())
assert.Equal(10, p.GetAsPathLen())
}
diff --git a/table/table_manager.go b/table/table_manager.go
index 3d52fce7..eb4a20bf 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -139,6 +139,10 @@ func NewTableManager(owner string, rfList []bgp.RouteFamily) *TableManager {
return t
}
+func (manager *TableManager) OwnerName() string {
+ return manager.owner
+}
+
func (manager *TableManager) calculate(destinationList []Destination) ([]Path, error) {
newPaths := make([]Path, 0)
@@ -159,7 +163,7 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, e
}
destination.setBestPathReason(reason)
- currentBestPath := destination.getBestPath()
+ currentBestPath := destination.GetBestPath()
if newBestPath != nil && currentBestPath == newBestPath {
// best path is not changed
@@ -192,7 +196,7 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, e
"next_hop": currentBestPath.GetNexthop().String(),
}).Debug("best path is lost")
- p := destination.getBestPath()
+ p := destination.GetBestPath()
newPaths = append(newPaths, p.Clone(true))
}
destination.setBestPath(nil)
@@ -218,7 +222,7 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, e
destination.setBestPath(newBestPath)
}
- if len(destination.getKnownPathList()) == 0 && destination.getBestPath() == nil {
+ if len(destination.getKnownPathList()) == 0 && destination.GetBestPath() == nil {
rf := destination.getRouteFamily()
t := manager.Tables[rf]
deleteDest(t, destination)
@@ -259,7 +263,7 @@ func (manager *TableManager) GetPathList(rf bgp.RouteFamily) []Path {
}
var paths []Path
for _, dest := range manager.Tables[rf].GetDestinations() {
- paths = append(paths, dest.getBestPath())
+ paths = append(paths, dest.GetBestPath())
}
return paths
}
@@ -360,10 +364,11 @@ func (adj *AdjRib) GetOutCount(rf bgp.RouteFamily) int {
return len(adj.adjRibOut[rf])
}
-func (adj *AdjRib) DropAllIn(rf bgp.RouteFamily) {
+func (adj *AdjRib) DropAll(rf bgp.RouteFamily) {
if _, ok := adj.adjRibIn[rf]; ok {
// replace old one
adj.adjRibIn[rf] = make(map[string]*ReceivedRoute)
+ adj.adjRibOut[rf] = make(map[string]*ReceivedRoute)
}
}