summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-11-09 14:14:16 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-11-09 14:14:16 -0800
commit84d73c1b45006c40764c1587207b5ad67598e893 (patch)
treede2bb447da0d11aef0c589d8fe5fc3e06be71f44 /server/server.go
parent431ce6b171a05cd17784a86ea2da1dfbf2f37ea0 (diff)
server: move POLICY_DIRECTION_IN processing from peer to fsm
For parallel processing. Each peer's rx goroutine can process IN policy. Note that RWLock() should be called in looking at policies via grpc too but such operaitons are done in the main goroutine so not called. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/server/server.go b/server/server.go
index 9c160e8b..d6aad66c 100644
--- a/server/server.go
+++ b/server/server.go
@@ -30,6 +30,7 @@ import (
"os"
"strconv"
"strings"
+ "sync"
"time"
)
@@ -37,6 +38,8 @@ const (
GLOBAL_RIB_NAME = "global"
)
+var policyMutex sync.RWMutex
+
type SenderMsg struct {
messages []*bgp.BGPMessage
sendCh chan *bgp.BGPMessage
@@ -2000,6 +2003,8 @@ func (server *BgpServer) policyInUse(x *table.Policy) bool {
}
func (server *BgpServer) handleGrpcModPolicy(grpcReq *GrpcRequest) error {
+ policyMutex.Lock()
+ defer policyMutex.Unlock()
arg := grpcReq.Data.(*api.ModPolicyArguments)
x, err := table.NewPolicyFromApiStruct(arg.Policy, server.policy.DefinedSetMap)
if err != nil {
@@ -2121,6 +2126,8 @@ func (server *BgpServer) handleGrpcModPolicyAssignment(grpcReq *GrpcRequest) err
var err error
var dir table.PolicyDirection
var i policyPoint
+ policyMutex.Lock()
+ defer policyMutex.Unlock()
arg := grpcReq.Data.(*api.ModPolicyAssignmentArguments)
assignment := arg.Assignment
i, dir, err = server.getPolicyInfo(assignment)