show route filter & static routes
Hello, I've found confused behaviour "show route filter". I have basic test setup with some filters, see attachment. With this setup, i've got this result: bird> show route export test 1.0.0.0/20 blackhole [static_bgp 18:22] * (1200) bird> show route filter upstream_out bird> and error log shows: 12-05-2013 18:23:24 <ERR> filters, line 28: Prefix or path expected When i commented out line "if bgp_path.len > 64 then return false;" in "function rt_export_ebgp()", i've got expected result: bird> show route export test 1.0.0.0/20 blackhole [static_bgp 18:22] * (1200) bird> bird> show route filter upstream_out 1.0.0.0/20 blackhole [static_bgp 18:22] * (1200) Unexpected behaviour (for me) arrive when filter contain whatever with BGP PATH and exported routes are static, without bgp path. For example, if i add "bgp_path.prepend(65001);" to "filter usptream_out", i've got same bad result again: bird> show route export test 1.0.0.0/20 blackhole [static_bgp 18:22] * (1200) bird> show route filter upstream_out bird> Is this correct behaviour? Thank you, Regards, Daniel
On 12.5.2013 18:39, Dan Rimal wrote:
Hello,
Is this correct behaviour?
Good question indeed. I would say yes. You are trying to make tests/modifications on a route that has no such capability. That is probably something you did not intend to do. It is hard to decide whether AS path is longer than some threshold if there is no AS path at all. So in your case, you should exclude all non-bgp routes from that filter. Ondrej
Thank you,
Regards,
Daniel
On Sun, May 12, 2013 at 06:39:55PM +0200, Dan Rimal wrote:
Hello,
I've found confused behaviour "show route filter". I have basic test setup with some filters, see attachment. ... When i commented out line "if bgp_path.len > 64 then return false;" in "function rt_export_ebgp()", i've got expected result: ... Unexpected behaviour (for me) arrive when filter contain whatever with BGP PATH and exported routes are static, without bgp path. For example, if i add "bgp_path.prepend(65001);" to "filter usptream_out", i've got same bad result again: ... Is this correct behaviour?
Yes, it is correct (but maybe somewhat confusing) behavior. If the route does not have the requested attribute, then its value is undefined and most operations (like .len) fail with an error message. You could use defined(ATTR) to test whether the attribute ATTR is defined for the current route, like: if defined(bgp_path) && (bgp_path.len > 64) then return false; Or you could test whether protocol source is RTS_BGP and check bgp_path just on them. Perhaps it would be less confusing if just the attempt to read undefined attribute would result in an explicit error message ('XXX attribute is not defined'). Note that there are two special cases: First, if the filter is executed during export to a BGP protocol, then an empty bpg_path was already attached and thus it worked. Second, bgp_community (and ext. comm.) attribute is automatically handed as empty if undefined. -- 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."
participants (3)
-
Dan Rimal -
Ondrej Filip -
Ondrej Zajicek