[RFC PATCH 00/20] Context typed filters

Ondrej Zajicek santiago at crfreenet.org
Mon Jan 6 04:16:41 CET 2020


On Mon, Dec 30, 2019 at 04:56:26PM +0000, Asbjørn Sloth Tønnesen wrote:
> This RFC patch series is a first stab, at adding some syntactic sugar
> making it more plessant to implement non-trivial dual-stack configurations,
> like https://bgpfilterguide.nlnog.net/
> 
> I'm not completely happy with the naming at this stage, but I want to
> get this series out before 36C3 ends.
> 
> Looking forward to your feedback.

Hi

Thanks for the patchset, sorry for not giving feedback sooner, was on
vacation.

If i understand it correctly, the main point of this patchset is to
introduce 'typed symbols', which have multiple values based of network
type of processed route.

I must say that i do not like the approach taken in the patch, seems to
me that for intended purpose it is too intrusive change and the feature
is too idiosyncratic - i don't recall any language where a constant may
represent multiple unrelated values based on context. It is also
over-specific (dispatch hardcoded for net_type, while there are other,
context-specific properties, like protocol type). One way to make it less
intrusive would be to keep symbol table the same (just symbol->value
mapping) and do the change just in 'value' part.

You have this example:

define default_route:ipv4 = 0.0.0.0/0;
define default_route:ipv6 = ::/0;

This could be done by using function instead of constant:

function default_route()
{
  case net.type
  {
    NET_IP4: return 0.0.0.0/0;
    NET_IP6: return ::/0;
  }
}

I agree that it is more cumbersome than your version.


Seems to me that your intended objective could be achieved, while keeping
it universal and reasonable, by several independent changes:

1) Allow 'lazy-evaluated constants', that could depend on context. These
are essentially zero-argument functions in disguise.

2) Allow something like if/case expressions (instead of just statements).

3) (optional) partially-evaluate/adapt filters based on context.

So one could wrote something like:

define default_route = case net.type {
  NET_IP4: 0.0.0.0/0;
  NET_IP6: ::/0;
}

(The remaining wart is a current style of enum constants, like 'NET_IP4'.)

-- 
Elen sila lumenn' omentielvo

Ondrej 'Santiago' Zajicek (email: santiago at 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."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20200106/50a8bc34/attachment.sig>


More information about the Bird-users mailing list