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."