02-03-2021 07:57 AM
As per documentation , the "pass" definition is the route is assigned a ticket to pass the default drop , processing continues through additional RPL statement .
I have configured below RPL :-
route-policy test
if destination in (10.0.0.0/8) then
pass
else
if destination in (10.0.0.0/8) then
drop
else
pass
endif
endif
end-policy
As per definition ,10.0.0.0/8 must be dropped as per second if statement but it is not being dropped .If I use endif statement in between 1st and 2nd if statement 10.0.0.0/8 is being dropped.
I would like to know that how does endif and else statement behaves ?
Thanks in advance
Solved! Go to Solution.
02-03-2021 05:56 PM
Here is how your statement reads:
if destination in 10.0.0.0/8:
pass
else:
if destination in 10.0.0.0/8:
drop
else:
pass
So since your route matches the first if statement we will not process any conditions under the else.
The reason why using an endif between if statements works is because you are closing the if conditions of the first if statement and starting a new if statement, not an else statement. We will process each if statement at the highest level, typically this is used for different route manipulations such as pass, local-preference, or any other attributes we want to set based on different conditions of the route. Here because you have the same if statement twice at the same level the first if statement says pass but then the second if statement says drop and overrides the first if statements action.
Sam
02-03-2021 05:56 PM
Here is how your statement reads:
if destination in 10.0.0.0/8:
pass
else:
if destination in 10.0.0.0/8:
drop
else:
pass
So since your route matches the first if statement we will not process any conditions under the else.
The reason why using an endif between if statements works is because you are closing the if conditions of the first if statement and starting a new if statement, not an else statement. We will process each if statement at the highest level, typically this is used for different route manipulations such as pass, local-preference, or any other attributes we want to set based on different conditions of the route. Here because you have the same if statement twice at the same level the first if statement says pass but then the second if statement says drop and overrides the first if statements action.
Sam
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide