[j-nsp] set MED only on empty

Alexander Arseniev arseniev at btinternet.com
Sun Sep 20 14:26:29 EDT 2020


Hello,
Last time I tested it, "from metric 0" works only if MED is present and 
equals 0.
Back then (around JUNOS 17) I developed a policy to detect missing MED 
which exploits metric2 rollover (basically, subtracting 1 from missing 
MED results in MED==4294967295)
Example below:
regress at R1# show policy-statement CHECK_MED_IMPORT
term CHECK_IF_MED_EXISTS_AND_0 {
     from {
         metric 0; {## accept if MED present && 0
     }
     then accept;
}
term MED_DECREMENT {
     then {
         metric {
             expression {
                 metric multiplier 1 offset -1; ## turns absent MED into 
2^32-1
             }
         }
         next term;
}}
term CHECK_IF_MED_ROLLED_OVER {
     from metric 4294967295;
     then accept; ## sets missing MED to 4294967295 but You can set it to 
smthg else
}
term RESTORE_ORIGINAL_MED {
     then {
         metric add 1;
     }
}

Thanks
Alex

------ Original Message ------
From: "Baldur Norddahl" <baldur at gigabit.dk>
To: "Juniper List" <juniper-nsp at puck.nether.net>
Sent: 19/09/2020 22:49:07
Subject: Re: [j-nsp] set MED only on empty

>Hello
>
>Metric zero should work, I do not know why I did not think of that.
>
>Thanks,
>
>Baldur
>
>Den lør. 19. sep. 2020 kl. 21.13 skrev Eduardo Schoedler <listas at esds.com.br
>>:
>
>>  Hi Baldur,
>>
>>  Try match metric, with some tests you can define empty (maybe zero?).
>>
>>
>>https://www.juniper.net/documentation/en_US/junos/topics/usage-guidelines/policy-configuring-match-conditions-in-routing-policy-terms.html
>>
>>
>>
>>  Regards.
>>
>>
>>  Em sáb., 19 de set. de 2020 às 12:59, Baldur Norddahl <baldur at gigabit.dk>
>>  escreveu:
>>
>>>  Hello
>>>
>>>
>>>
>>>  I want to set MED (metric) only when the peer did not specify a MED value.
>>>
>>>  The idea being that peers that set MED have a reason for their choice, but
>>>
>>>  if no MED value is set, I am going to set it to MED=(latency_to_peer_in_ms
>>>
>>>  + 1000). That way we will prefer the route with lowest latency.
>>>
>>>
>>>
>>>  But I can not figure out how to match on no MED value in a policy. There
>>>
>>>  must be a way to do this?
>>>
>>>
>>>
>>>  Thanks,
>>>
>>>
>>>
>>>  Baldur
>>>
>>>  _______________________________________________
>>>
>>>  juniper-nsp mailing list juniper-nsp at puck.nether.net
>>>
>>>https://puck.nether.net/mailman/listinfo/juniper-nsp
>>>
>>>  --
>>  Eduardo Schoedler
>>
>_______________________________________________
>juniper-nsp mailing list juniper-nsp at puck.nether.net
>https://puck.nether.net/mailman/listinfo/juniper-nsp



More information about the juniper-nsp mailing list