]> git.proxmox.com Git - mirror_frr.git/commit - bgpd/bgp_clist.h
bgpd: separate lcommunity validation from tokenizer
authorWesley Coakley <wcoakley@nvidia.com>
Tue, 5 Jan 2021 09:22:57 +0000 (04:22 -0500)
committerWesley Coakley <wcoakley@nvidia.com>
Wed, 6 Jan 2021 12:18:20 +0000 (07:18 -0500)
commitc850908b9d036a80f25b4ee7331cffa5e3504874
treec09f580449ed82fbe70dc2914422e0de57991913
parenta7f52fb0f7e0cdbb274ef447196da84f1bcf5a80
bgpd: separate lcommunity validation from tokenizer

`lcommunity_gettoken` expects a space-delimeted list of 0 or more large
communities. `lcommunity_list_valid` can perform this check.
`lcommunity_list_valid` now validates large community lists more
accurately based on the following condition: Each quantity in a standard bgp
large community must:

1. Contain at least one digit
2. Fit within 4 octets
3. Contain only digits unless the lcommunity is "expanded"
4. Contain a valid regex if the lcommunity is "expanded"

Moreover we validate that each large community list contains exactly 3
such values separated by a single colon each.

One quirk of our validation which is worth documenting is:

```
bgp large-community-list standard test2 permit 1:c:3
bgp large-community-list expanded test1 permit 1:c:3
```

The first line will throw an error complaining about a "malformed community-list
value". The second line will be accepted because the each value is each treated as
a regex when matching large communities, it simply will never match anything so
it's rather useless.

Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
bgpd/bgp_clist.c
bgpd/bgp_clist.h
bgpd/bgp_lcommunity.c
bgpd/bgp_lcommunity.h
tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py