Extended communities and quagga AS4

The core part of defining extended communities in the quagga CLI before the AS4 patch were:
(rt|soo) (<asnumber>|<ip-address>)':'<value>

Examples: rt 33:1000

This core part is to be found in extended community lists, 'set extcommunity' inside a route-map, and other places.

It gets translated on the wire as ECOMMUNITY_ENCODE_AS or ECOMMUNITY_ENCODE_IP, whichever is appropriate, and is of type ROUTE_TARGET or SITE_ORIGN, dependend on the first word. The differenciation between asnumber and ip-address is done by looking whether a dot ('.') appears in the word on the left hand side of the colon (':').

Whats new with AS4?

Because all as number formats are now recognized by quagga on input, this procdedure has to be changed lightly, because <asnumber> may now contain one dot.

With draft-rekhter-as4octet-ext-community-01.txt there is a new encoding, ECOMMUNITY_ENCODE_AS4, which encompasses a 4 byte as number and 2 bytes of a value (ECOMMUNITY_ENCODE_AS is 2 bytes AS number and 4 bytes of value).

My first solution to allow as numbers with one dot and do everything else automagically failed miserably: as long as no procedure how to deal with extended communities on the border between the 2 and 4 byte as worlds exist, the user will have to specify which encoding is to be used. And for as numbers smaller than 65536 you can use either ECOMMUNITY_ENCODE_AS or ECOMMUNITY_ENCODE_AS4 - and that can not be detected out of the <asnumber> because the as number input format may not have any effect on semantics. It is very important that nothing depends on whether you enter '45' or '0.45' as an asnumber because these are both textual representations of the same thing and tagging some meta-meaning onto this leads to nothing but confusion.

Patch versions before v05 violated that rule, so please use v05 or later, otherwise you'll get confused!

Withput having an implementation to copy the syntax from, I had to invent my own one:
Patch v05 introduces the following syntax for the above-mentioned core part:

(rt|soo) (('+'|)<asnumber>|<ip-address>)':'<value>

Examples: rt 33:1000 +33:1000 0.9:30 +0.9:30 65536:20

Beside interpreting the part before the colon as an asnumber if there are less than 2 dots in it, this puts an optional plus ('+') in front of the as number.

If the plus is given, the encoding is ECOMMUNITY_ENCODE_AS4. If the plus is not given, the encoding is ECOMMUNITY_ENCODE_AS. A plus in front of an ip address is a syntax error.

If the encoding is ECOMMUNITY_ENCODE_AS (i.e. no plus is given) and the as number is larger than 65535, the as number is changed to AS_TRANS (23456), because "4 byte only" as numbers can not be encoded in 2 bytes, and AS_TRANS is the value to be used in that case.

Be aware that if you used AS4 extcommunity values with quagga AS4 patches before v05 you will have to re-input the configuration lines with '+'es. Upgrading to v05 will change all as numbers greater 65535 to AS_TRANS(23456) and ignore the ENCODE_AS4 semantics of an as number smaller 65536 supplied in asdot+. Thus you are stuck with ENCODE_AS if you do nothing!

Sorry for the inconvenience, but sometimes you have to try something before you realize that you are barking up the wrong tree...