Reject log message; bgp_community comparaison
Hello the bird community, I’ve two small questions, I've put them in the same mail even if they are not related : 1/ I currently use this code in my config to reject “martians” if ( is_martian() ) then { reject "prefix rejected by is_martian"; } Which prints in logs : <INFO> prefix rejected by is_martian Do you know if there is a way to add some variables in the log (like bgp_path.first, from or net) ? 2/ I’ve notice a “strange” behaviour when comparing communities, is this voluntary? Pair set have to be compared on the right : bird> show route where bgp_community ~ [ (51706,51706) ] count 2467 of 2467 routes for 2426 networks bird> show route where [ (51706,51706) ] ~ bgp_community count 0 of 2467 routes for 2426 networks Pair have to be compared on the left : bird> show route where (51706,51706) ~ bgp_community count 2467 of 2467 routes for 2426 networks bird> show route where bgp_community ~ (51706,51706) count 0 of 2467 routes for 2426 networks Thanks -- Arnaud Fenioux Network Engineer - FranceIX
Arnaud Fenioux wrote, 28.01.2015 17:20:
Hello the bird community,
I’ve two small questions, I've put them in the same mail even if they are not related :
1/ I currently use this code in my config to reject “martians”
if ( is_martian() ) then { reject "prefix rejected by is_martian"; }
Which prints in logs : <INFO> prefix rejected by is_martian Do you know if there is a way to add some variables in the log (like bgp_path.first, from or net) ?
2/ I’ve notice a “strange” behaviour when comparing communities, is this voluntary?
Hi, <Ondrej Zajicek wrote to me some times ago> -------- Match (~) is not a symmetric operator, its general syntax is "instance ~ set/list/pattern", therefore pair ~ pair_set is OK, also pair ~ pair_list (bgp_community) is OK. Matching pair_list against pair_set is a generalization interpreted as "For each pair X in pair_list try X ~ pair_set, return true if any X matches" -------- Wbr, Mikhail, MSK-IX
Pair set have to be compared on the right : bird> show route where bgp_community ~ [ (51706,51706) ] count 2467 of 2467 routes for 2426 networks
bird> show route where [ (51706,51706) ] ~ bgp_community count 0 of 2467 routes for 2426 networks
Pair have to be compared on the left : bird> show route where (51706,51706) ~ bgp_community count 2467 of 2467 routes for 2426 networks
bird> show route where bgp_community ~ (51706,51706) count 0 of 2467 routes for 2426 networks
Thanks
-- Arnaud Fenioux Network Engineer - FranceIX
-- Best regards, Mikhail A. Grishin <m.grishin@msk-ix.ru>
On Wed, 28 Jan 2015, Arnaud Fenioux wrote:
Hello the bird community,
I've two small questions, I've put them in the same mail even if they are not related :
1/ I currently use this code in my config to reject “martians”
if ( is_martian() ) then { reject "prefix rejected by is_martian"; }
Which prints in logs : <INFO> prefix rejected by is_martian Do you know if there is a way to add some variables in the log (like bgp_path.first, from or net) ?
Yes, for example in a function called rt_import_all, I use: if net_martian() then { print "rt_import_all: ", net, " from ", from, ": net_martian() returned true!"; return false; } so I imagine you could do: if ( is_martian() ) then { reject "prefix rejected by is_martian: ", net, " from ", from, " bgp_path.first ", bgp_path.first; } Chris
Thank you Chris and Mikhail for your answers It’s working fine :) Arnaud
On 28 Jan 2015, at 19:25, Chris Caputo <ccaputo@alt.net> wrote:
On Wed, 28 Jan 2015, Arnaud Fenioux wrote:
Hello the bird community,
I've two small questions, I've put them in the same mail even if they are not related :
1/ I currently use this code in my config to reject “martians”
if ( is_martian() ) then { reject "prefix rejected by is_martian"; }
Which prints in logs : <INFO> prefix rejected by is_martian Do you know if there is a way to add some variables in the log (like bgp_path.first, from or net) ?
Yes, for example in a function called rt_import_all, I use:
if net_martian() then { print "rt_import_all: ", net, " from ", from, ": net_martian() returned true!"; return false; }
so I imagine you could do:
if ( is_martian() ) then { reject "prefix rejected by is_martian: ", net, " from ", from, " bgp_path.first ", bgp_path.first; }
Chris
participants (3)
-
Arnaud Fenioux -
Chris Caputo -
Mikhail A. Grishin