diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-10-15 21:12:40 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-20 10:33:10 +0900 |
commit | 7937d8ddb6f8f82c593fb3b019d1fc618dc89f48 (patch) | |
tree | 853aa4860dd2a392cb7692c4b13741e2db1a0e26 /server/peer.go | |
parent | 473f5b6ff32be2829dac2a19bd63df19a7efd4ec (diff) |
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 <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/peer.go')
-rw-r--r-- | server/peer.go | 9 |
1 files changed, 5 insertions, 4 deletions
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 { |