From 7937d8ddb6f8f82c593fb3b019d1fc618dc89f48 Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Thu, 15 Oct 2015 21:12:40 +0900 Subject: policy: clean up remove redundant api structures and shorten valiable names re-implement *ToApiStruct functions as a method of each structures Signed-off-by: ISHIDA Wataru --- server/peer.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'server/peer.go') diff --git a/server/peer.go b/server/peer.go index dde83b6c..71d07c25 100644 --- a/server/peer.go +++ b/server/peer.go @@ -381,7 +381,7 @@ func (peer *Peer) ToApiStruct() *api.Peer { } } -func (peer *Peer) setPolicy(policyMap map[string]*table.Policy) { +func (peer *Peer) setPolicy(policy map[string]*table.Policy) { policyConf := peer.conf.ApplyPolicy inPolicies := make([]*table.Policy, 0) for _, policyName := range policyConf.ApplyPolicyConfig.InPolicy { @@ -390,15 +390,16 @@ func (peer *Peer) setPolicy(policyMap map[string]*table.Policy) { "Key": peer.conf.NeighborConfig.NeighborAddress, "PolicyName": policyName, }).Info("in-policy installed") - if pol, ok := policyMap[policyName]; ok { + if pol, ok := policy[policyName]; ok { log.Debug("in policy : ", pol) inPolicies = append(inPolicies, pol) } } peer.inPolicies = inPolicies peer.defaultInPolicy = policyConf.ApplyPolicyConfig.DefaultInPolicy - - peer.localRib.SetPolicy(policyConf, policyMap) + if peer.localRib != nil { + peer.localRib.SetPolicy(policyConf, policy) + } } func (peer *Peer) GetPolicy(d table.PolicyDirection) []*table.Policy { -- cgit v1.2.3