FRR supports using regex patterns to specify large communities. At the moment this is implemented in src/validators/bgp-large-community-list; However, the code has several issues:
- It assumes GLOB matching (regex "12345:*:23"), even though FRR uses regex substring match, i.e., this setting would actually match 12345:23.* (and technically 12345::23.*; but that won't happen). This was introduced in https://github.com/vyos/vyos-1x/pull/1025
- The code only allows for '*' in the second field, i.e., to match 12345:.*:.*, one has to set 12345:*:.* (thereby matching 12345:.* effectively)
- The code strictly enforces three seperating ":", which are not strictly needed for a regex (even though that leap _could_ be made if documented)
In general, the current matching code severely restricts the capabilities of this feature in FRR.
The problem with validation is that _technically_ one would want to make sure that the supplied regex matches something resembling a large community; However, in absence of that, technically anything looking like a bgp-regex should be fine (see: https://docs.frrouting.org/en/latest/bgp.html?highlight=large-community#bgp-regular-expressions ; Still, _technically_ this seems to be more limited than POSIX 1003.2)
I took a quick shot at how i'd make this look assuming pure POSIX 1003.2; If someone finds a nice lib in python that implements proper BGP regex, that would be a drop-in replacement for re.compile, i guess.