Parameterization is a route policy capability that
-
lets you define a policy that accepts one or more parameters
-
uses parameters that start with $ and contain only alphanumeric characters, and
-
allows you to substitute parameters into any attribute that accepts a parameter.
Policy parameterization
In addition to reusing policies through the apply statement, you can define policies to accept parameters. Substitute these parameters into attributes within the policy as needed.
Example 1:
route-policy param-example ($mytag)
set community (1234:$mytag) additive
end-policy
In this example, the policy param-example takes one parameter, $mytag , which is used as part of a 16-bit community tag.
Example 2:
In this example, the policy takes two parameters, $mymed and $prefixset .
route-policy param-example ($mymed, $prefixset)
if destination in $prefixset then
set med $mymed
endif
end-policy
In this case, a MED value and a prefix-set name are passed as parameters and substituted into the policy statements.
Reuse using apply with parameters
You can reuse a parameterized policy with different values by supplying arguments in the apply statement.
Example:
route-policy origin-10
if as-path originates-from '10.5' then
apply param-example(10.5)
else
pass
endif
end-policy
route-policy origin-20
if as-path originates-from '20.5' then
apply param-example(20.5)
else
pass
endif
end-policy
When you provide values in the apply statement, the policy param-example uses those values. If you change the definition of param-example , origin-10 and origin-20 automatically change their behavior.
The origin-10 policy adds the community 1234:10 to routes that originate from autonomous system 10. Similarly, origin-20 adds the community 1234:20 to routes originating from autonomous system 20.
Parameterization at attach points
The system also supports parameterization at attach points. You can supply parameters at attach points when you bind the policy to a protocol configuration.
Example:
router bgp 2
neighbor 192.0.2.1
remote-as 3
address-family ipv4 unicast
route-policy param-example(10, prefix_set1)
route-policy param-example(20, prefix_set2)
In this case, the parameterized policy param-example is expanded using the values provided in the route-policy configuration at the attach point.
Global parameterization
RPL supports systemwide global parameters that you can reference in policy definitions.
To define global parameters, use this format:
policy-global
glbpathtype 'ebgp'
glbtag '100'
end-global
Use these values in a policy definition the same way you use local parameters.
Example:
route-policy globalparam
if path-type is $glbpathtype then
set tag $glbtag
endif
end-policy
Local and global parameter precedence
-
If you define a parameter in your policy with the same name as a global parameter, the local parameter takes precedence and hides the global parameter.
-
You cannot delete a global parameter that any policy references.