From eaa7810893c10d2768e61306e38859e80da01111 Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Wed, 30 Sep 2015 14:56:42 +0900 Subject: server: kill LocalRib Signed-off-by: ISHIDA Wataru --- policy/policy.go | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'policy/policy.go') diff --git a/policy/policy.go b/policy/policy.go index 988b70ca..62a667af 100644 --- a/policy/policy.go +++ b/policy/policy.go @@ -996,18 +996,16 @@ type RoutingAction struct { } func NewRoutingAction(action config.Actions) *RoutingAction { - r := &RoutingAction{ + return &RoutingAction{ AcceptRoute: action.RouteDisposition.AcceptRoute, } - return r } func (r *RoutingAction) apply(path *table.Path) *table.Path { if r.AcceptRoute { return path - } else { - return nil } + return nil } type CommunityAction struct { @@ -1346,7 +1344,7 @@ func NewPrefix(prefixStr string, maskRange string) (Prefix, error) { // Compare path with a policy's condition in stored order in the policy. // If a condition match, then this function stops evaluation and // subsequent conditions are skipped. -func (p *Policy) Apply(path *table.Path) (bool, RouteType, *table.Path) { +func (p *Policy) Apply(path *table.Path) (RouteType, *table.Path) { for _, statement := range p.Statements { result := statement.evaluate(path) @@ -1356,23 +1354,24 @@ func (p *Policy) Apply(path *table.Path) (bool, RouteType, *table.Path) { "PolicyName": p.Name, }).Debug("statement evaluate : ", result) - var p *table.Path if result { //Routing action - p = statement.routingAction.apply(path) - if p != nil { - // apply all modification actions - cloned := path.Clone(p.IsWithdraw) - for _, action := range statement.modificationActions { - cloned = action.apply(cloned) - } - return true, ROUTE_TYPE_ACCEPT, cloned - } else { - return true, ROUTE_TYPE_REJECT, nil + p := statement.routingAction.apply(path) + if p == nil { + return ROUTE_TYPE_REJECT, path + } + if len(statement.modificationActions) == 0 { + return ROUTE_TYPE_ACCEPT, path + } + // apply all modification actions + cloned := path.Clone(p.IsWithdraw) + for _, action := range statement.modificationActions { + cloned = action.apply(cloned) } + return ROUTE_TYPE_ACCEPT, cloned } } - return false, ROUTE_TYPE_NONE, nil + return ROUTE_TYPE_NONE, path } func ipPrefixCalculate(path *table.Path, cPrefix Prefix) bool { -- cgit v1.2.3