changing bgp_med attributes cause route been filited
Hi all, I was doing research about selecting the best route on multiple nodes based on bgp_med attributes. function ibgp_import(int bgp_med_ping; int extra_bgp_med){ add_type("ibgp"); if is_bogon_asn() then { print "is bogon asn", net, " for ASN ", bgp_path.last; return false; } if is_bogon_prefix() then { print "is bogon prefix", net, " for ASN ", bgp_path.last; return false; } if (LOCAL_ASN, 47, NODE_ID) ~ bgp_large_community then { reject; } if bgp_large_community ~ [(LOCAL_ASN, 2, 100)] then preference = 115; additional_import_action(); bgp_med = bgp_med + bgp_med_ping + bgp_med_ping; return true; } My idea is to add bgp_med value between each node based on ping, and then bird will select the route which has the lowest bgp_med value (which is the total ping delay) But some routes will be filled, which i don't want it. I found that the code " bgp_med = bgp_med + bgp_med_ping + bgp_med_ping;" will cause some routes to be filtered. Can someone tell me why? I only want to modify bgp_med and don't want my routes to be filtered. Best, *Brandon Zhi* HUIZE LTD www.huize.asia <https://huize.asia/>| www.ixp.su | Twitter This e-mail and any attachments or any reproduction of this e-mail in whatever manner are confidential and for the use of the addressee(s) only. HUIZE LTD can’t take any liability and guarantee of the text of the email message and virus.
On Thu, Jul 20, 2023 at 08:25:24PM +0800, Brandon Zhi wrote:
Hi all,
I was doing research about selecting the best route on multiple nodes based on bgp_med attributes.
My idea is to add bgp_med value between each node based on ping, and then bird will select the route which has the lowest bgp_med value (which is the total ping delay)
But some routes will be filled, which i don't want it.
I found that the code " bgp_med = bgp_med + bgp_med_ping + bgp_med_ping;" will cause some routes to be filtered.
Can someone tell me why? I only want to modify bgp_med and don't want my routes to be filtered.
Hi Perhaps there are some error in logs about filter failures? I guess that when bgp_med is not defined, then expression 'bgp_med + X' fails. You could try something like: if (defined(bgp_med)) bgp_med = bgp_med + X; else bgp_med = X; And perhaps even better than use bgp_med for this is to use bgp_aigp attribute and associated BGP options (aigp, cost). -- Elen sila lumenn' omentielvo Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
This reminds me of a meme... https://img-comment-fun.9cache.com/media/ay9BKnV/aWlGMBgm_700w_0.jpg Em qua., 26 de jul. de 2023 às 20:54, Ondrej Zajicek <santiago@crfreenet.org> escreveu:
On Thu, Jul 20, 2023 at 08:25:24PM +0800, Brandon Zhi wrote:
Hi all,
I was doing research about selecting the best route on multiple nodes based on bgp_med attributes.
My idea is to add bgp_med value between each node based on ping, and then bird will select the route which has the lowest bgp_med value (which is the total ping delay)
But some routes will be filled, which i don't want it.
I found that the code " bgp_med = bgp_med + bgp_med_ping + bgp_med_ping;" will cause some routes to be filtered.
Can someone tell me why? I only want to modify bgp_med and don't want my routes to be filtered.
Hi
Perhaps there are some error in logs about filter failures? I guess that when bgp_med is not defined, then expression 'bgp_med + X' fails.
You could try something like:
if (defined(bgp_med)) bgp_med = bgp_med + X; else bgp_med = X;
And perhaps even better than use bgp_med for this is to use bgp_aigp attribute and associated BGP options (aigp, cost).
-- Elen sila lumenn' omentielvo
Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
-- Douglas Fernando Fischer Engº de Controle e Automação
Hi Ondrej, Thanks for the advice, I have fixed with. I always use Python, so I guess other C like Stript needs to do that. # 如果 MED 值已经存在,则将其以原值为基础增加 if defined (bgp_med) then { bgp_med = bgp_med + bgp_med_ping + bgp_med_ping; } # 否则,设置 MED 值为新值 else { bgp_med = bgp_med_ping + bgp_med_ping; } return true; AIGP is not intended to be transitive between completely distinct
autonomous systems (only across internal AS boundaries)
AIGP is always compared in paths that have the attribute, regardless of
whether they come from different neighbor AS or not AIGP is more important than MED in the BGP decision process (see the section titled BGP decision process) AIGP is automatically incremented every time there is a BGP next-hop change so that it can track the end-to-end IGP cost. All arithmetic operations on MED attributes must be done manually (for example, using route policies)
Looks like local_pref > bgp_path > aigp > bgp_med? And aigp is added when passing each ibgp session Automatically.? Best regard, *Brandon Zhi* HUIZE LTD www.huize.asia <https://huize.asia/>| www.ixp.su | Twitter This e-mail and any attachments or any reproduction of this e-mail in whatever manner are confidential and for the use of the addressee(s) only. HUIZE LTD can’t take any liability and guarantee of the text of the email message and virus. On Thu, 27 Jul 2023 at 19:32, Douglas Fischer <fischerdouglas@gmail.com> wrote:
This reminds me of a meme... https://img-comment-fun.9cache.com/media/ay9BKnV/aWlGMBgm_700w_0.jpg
Em qua., 26 de jul. de 2023 às 20:54, Ondrej Zajicek < santiago@crfreenet.org> escreveu:
On Thu, Jul 20, 2023 at 08:25:24PM +0800, Brandon Zhi wrote:
Hi all,
I was doing research about selecting the best route on multiple nodes based on bgp_med attributes.
My idea is to add bgp_med value between each node based on ping, and then bird will select the route which has the lowest bgp_med value (which is the total ping delay)
But some routes will be filled, which i don't want it.
I found that the code " bgp_med = bgp_med + bgp_med_ping + bgp_med_ping;" will cause some routes to be filtered.
Can someone tell me why? I only want to modify bgp_med and don't want my routes to be filtered.
Hi
Perhaps there are some error in logs about filter failures? I guess that when bgp_med is not defined, then expression 'bgp_med + X' fails.
You could try something like:
if (defined(bgp_med)) bgp_med = bgp_med + X; else bgp_med = X;
And perhaps even better than use bgp_med for this is to use bgp_aigp attribute and associated BGP options (aigp, cost).
-- Elen sila lumenn' omentielvo
Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
-- Douglas Fernando Fischer Engº de Controle e Automação
participants (3)
-
Brandon Zhi -
Douglas Fischer -
Ondrej Zajicek