]> git.proxmox.com Git - mirror_frr.git/commit - bgpd/bgp_clist.c
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>
Sun, 13 May 2018 17:37:51 +0000 (19:37 +0200)
commit8d9b8ed99de997a4ade10b98aac4ea43add2f9c8
tree109db36e85e78c402790f37d15de6096fd2877c4
parent05859298a3979eaa1a802174128b3342be47c7b1
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>
bgpd/bgp_clist.c
bgpd/bgp_lcommunity.c
bgpd/bgp_lcommunity.h
bgpd/bgp_route.c
bgpd/bgp_vty.c