The following examples show how to use the logical operators to create policy expressions:
- export (policy1 && policy2)
- export (policy1 || policy2)
- export [(policy1 || policy2) && policy3]
- export (!policy1 && policy2)
The sequential list [policy1 policy2 policy3] is not the same as the policy expression (policy1 && policy2 && policy3).
The sequential list is evaluated on the basis of a route matching a routing policy. For example, if policy1 matches and the action is accept or reject, policy2 and policy3 are not evaluated. If policy1 does not match, policy2 is evaluated and so on until a match occurs and the action is accept or reject.
The policy expressions are evaluated on the basis of the action in a routing policy that is converted to the value of TRUE or FALSE and the logic of the specified logical operator. (For complete information about policy expression evaluation, see How a Policy Expression Is Evaluated.) For example, if policy1 returns a value of FALSE, policy2 and policy3 are not evaluated. If policy1 returns a value of TRUE, policy2 is evaluated. If policy2 returns a value of FALSE, policy3 is not evaluated. If policy2 returns a value of TRUE, policy3 is evaluated.
You can also combine policy expressions and sequential lists. In the following example, if policy1 returns a value of FALSE, policy2 is evaluated. If policy2 returns a value of TRUE and contains a next policy action, policy3 is evaluated. If policy2 returns a value of TRUE but does not contain an action, including a next policy action, policy3 is still evaluated (because if you do not specify an action, next term or next policy are the default actions). If policy2 returns a value of TRUE and contains an accept action, policy3 is not evaluated.
- export [(policy1 || policy2) policy3]