summaryrefslogtreecommitdiffhomepage
path: root/table/policy.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-10-18 14:10:46 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-10-20 10:33:10 +0900
commit7cb50ce1cfdf959a74dad516ef65a6c6c34aaec8 (patch)
tree188236c04337a475078ec2e57932c3e47c8c6154 /table/policy.go
parent29f9682ecbe0e5bf0a44fdcc2e9f8cec3f6ea31c (diff)
api/cli: add api to retrieve statements and support showing them via cli
$ gobgp policy statement $ gobgp policy statement st0 Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/policy.go')
-rw-r--r--table/policy.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/table/policy.go b/table/policy.go
index 97277f6f..8375faab 100644
--- a/table/policy.go
+++ b/table/policy.go
@@ -2053,6 +2053,7 @@ func NewPolicy(c config.PolicyDefinition, dmap DefinedSetMap) (*Policy, error) {
type RoutingPolicy struct {
DefinedSetMap DefinedSetMap
PolicyMap map[string]*Policy
+ StatementMap map[string]*Statement
}
func (r *RoutingPolicy) InUse(d DefinedSet) bool {
@@ -2122,16 +2123,25 @@ func NewRoutingPolicy(c config.RoutingPolicy) (*RoutingPolicy, error) {
dmap[DEFINED_TYPE_EXT_COMMUNITY][y.Name()] = y
}
pmap := make(map[string]*Policy)
+ smap := make(map[string]*Statement)
for _, x := range c.PolicyDefinitions.PolicyDefinitionList {
y, err := NewPolicy(x, dmap)
if err != nil {
return nil, err
}
pmap[y.Name()] = y
+ for _, s := range y.Statements {
+ _, ok := smap[s.Name]
+ if ok {
+ return nil, fmt.Errorf("duplicated statement name. statement name must be unique.")
+ }
+ smap[s.Name] = s
+ }
}
return &RoutingPolicy{
DefinedSetMap: dmap,
PolicyMap: pmap,
+ StatementMap: smap,
}, nil
}