diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-10-20 12:06:32 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-20 16:57:13 +0900 |
commit | a4f2e5902860ca1fa70c76e0ffd5289293c5ca57 (patch) | |
tree | 3d39db27b86868c4e4852fc8d3375c19d1247042 /table | |
parent | e0a0fd792d98ce1d092531fc20fcc2b8fa5cffba (diff) |
policy: fix how to apply policy to follow openconfig description
OpenConfig model says for Route policy evaluation:
Evaluation of each policy definition proceeds by evaluating its
corresponding individual policy statements in order. When a
condition statement in a policy statement is satisfied, the
corresponding action statement is executed. If the action
statement has either accept-route or reject-route actions, policy
evaluation of the current policy definition stops, and no further
policy definitions in the chain are evaluated.
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r-- | table/policy.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/table/policy.go b/table/policy.go index 809bb984..7698bad6 100644 --- a/table/policy.go +++ b/table/policy.go @@ -1893,6 +1893,13 @@ func (s *Statement) Apply(path *Path) (RouteType, *Path) { "PolicyName": s.Name, }).Debug("statement evaluate : ", result) if result { + if len(s.ModActions) != 0 { + // apply all modification actions + path = path.Clone(path.Owner, path.IsWithdraw) + for _, action := range s.ModActions { + path = action.Apply(path) + } + } //Routing action if s.RouteAction == nil { log.WithFields(log.Fields{ @@ -1900,21 +1907,13 @@ func (s *Statement) Apply(path *Path) (RouteType, *Path) { "Path": path, "PolicyName": s.Name, }).Warn("route action is nil") - return ROUTE_TYPE_REJECT, path + return ROUTE_TYPE_NONE, path } p := s.RouteAction.Apply(path) if p == nil { return ROUTE_TYPE_REJECT, path } - if len(s.ModActions) == 0 { - return ROUTE_TYPE_ACCEPT, path - } - // apply all modification actions - cloned := path.Clone(p.Owner, p.IsWithdraw) - for _, action := range s.ModActions { - cloned = action.Apply(cloned) - } - return ROUTE_TYPE_ACCEPT, cloned + return ROUTE_TYPE_ACCEPT, path } return ROUTE_TYPE_NONE, path } @@ -2253,7 +2252,8 @@ func (p *Policy) Name() string { // subsequent conditions are skipped. func (p *Policy) Apply(path *Path) (RouteType, *Path) { for _, stmt := range p.Statements { - result, path := stmt.Apply(path) + var result RouteType + result, path = stmt.Apply(path) if result != ROUTE_TYPE_NONE { return result, path } |