diff options
author | Naoto Hanaue <hanaue.naoto@po.ntts.co.jp> | 2015-05-14 16:51:18 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-05-19 16:33:16 +0900 |
commit | 749df65ac97da627e8f35d91ea4e2fe585b88d5d (patch) | |
tree | c9fcbf9684985349e77d68488b79578ee2b0e61d /server/peer.go | |
parent | 0349e0d69926a6cb16467fcd88edf69cbd0f524e (diff) |
cli: support the AsPathLength to display in routing policy
% gobgp -u 10.0.255.1 policy routepolicy policy0
PolicyName policy0:
StatementName st0:
Conditions:
PrefixSet: ps0 192.168.0.0/16 16..24
NeighborSet: ns0 10.0.0.2
AsPathLength: 10 eq
MatchOption: ALL
Actions:
REJECT
Diffstat (limited to 'server/peer.go')
-rw-r--r-- | server/peer.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/server/peer.go b/server/peer.go index a89fb303..f83bbc3e 100644 --- a/server/peer.go +++ b/server/peer.go @@ -596,26 +596,32 @@ func (peer *Peer) handleGrpc(grpcReq *GrpcRequest) { // However, peer haven't target importpolicy when add PolicyDefinition of name only to the list. conInPolicyNames := peer.peerConfig.ApplyPolicy.ImportPolicies for _, conInPolicyName := range conInPolicyNames { + match := false for _, inPolicy := range peer.importPolicies { if conInPolicyName == inPolicy.Name { + match = true resInPolicies = append(resInPolicies, inPolicy.ToApiStruct()) - } else { - resInPolicies = append(resInPolicies, &api.PolicyDefinition{PolicyDefinitionName: conInPolicyName}) + break } - + } + if !match { + resInPolicies = append(resInPolicies, &api.PolicyDefinition{PolicyDefinitionName: conInPolicyName}) } } // Add importpolies that has been set in the configuration file to the list. // However, peer haven't target importpolicy when add PolicyDefinition of name only to the list. conOutPolicyNames := peer.peerConfig.ApplyPolicy.ExportPolicies for _, conOutPolicyName := range conOutPolicyNames { + match := false for _, outPolicy := range peer.exportPolicies { if conOutPolicyName == outPolicy.Name { + match = true resOutPolicies = append(resOutPolicies, outPolicy.ToApiStruct()) - } else { - resOutPolicies = append(resOutPolicies, &api.PolicyDefinition{PolicyDefinitionName: conOutPolicyName}) + break } - + } + if !match { + resOutPolicies = append(resOutPolicies, &api.PolicyDefinition{PolicyDefinitionName: conOutPolicyName}) } } result.Data = &api.ApplyPolicy{ |