]> git.puffer.fish Git - matthieu/frr.git/commit
bgpd: Improve JSON support for large communities
authorPascal Mathis <mail@pascalmathis.com>
Sun, 13 May 2018 00:29:40 +0000 (02:29 +0200)
committerPascal Mathis <mail@pascalmathis.com>
Tue, 29 May 2018 18:08:50 +0000 (20:08 +0200)
commit64b6806d3b1a046a4a6897d1e071ba948c87d123
treea3a5786a217a229268506d8e72455c5b4179a091
parent3c699296e08b533bce0067473636e5ad66143193
bgpd: Improve JSON support for large communities

The current implementation of building JSON output is greatly different
for large communities compared to standard communities. This is mainly
noticeable by the missing 'list' attribute, which usually offers an
array of all communities present on a BGP route.

This commit adds the missing functionality of properly returning a
'list' attribute in JSON output and also tries a similar approach like
the standard communities are using to implement this feature.

Additionally, the 'format' specifier has been completely removed from
large communities string/JSON rendering, as the official RFC8092 specifies that
there is only one canonical representation:

> The canonical representation of BGP Large Communities is three
> separate unsigned integers in decimal notation in the following
> order: Global Administrator, Local Data 1, Local Data 2. Numbers
> MUST NOT contain leading zeros; a zero value MUST be represented with
> a single zero. Each number is separated from the next by a single
> colon. For example: 64496:4294967295:2, 64496:0:0.

As the 'format' specifier has not been used/checked and only one
canonical representation exists per today, there was no reason to keep
the 'format' parameter in the function signature.

Last but not least, the struct attribute 'community_entry.config' is no
longer being used for large communities and instead 'lcommunity_str' is
being called to maintain a similar approach to standard communities.

As a side effect, this also fixed a memory leak inside 'community_entry_free'
which did not free the allocated memory for the 'config' attribute when
dealing with a large community.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
(cherry picked from commit 8d9b8ed99de997a4ade10b98aac4ea43add2f9c8)
bgpd/bgp_clist.c
bgpd/bgp_lcommunity.c
bgpd/bgp_lcommunity.h
bgpd/bgp_route.c
bgpd/bgp_vty.c