diff options
| author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-04-21 22:34:12 +0300 | 
|---|---|---|
| committer | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-05-05 16:37:00 +0300 | 
| commit | ed0e57e3f079352714c3a3a8a5b0dddf4aadfe1d (patch) | |
| tree | 8c9cc817cb849107898633eb5d1d3201135fba10 /bgpd/bgp_lcommunity.c | |
| parent | 6038682d465e9ec6e1f62a53bfd53f6ebadf6e7a (diff) | |
bgpd: Create BGP alias names for community/large-community
Show alias name instead of numerical value in `show bgp <prefix>. E.g.:
```
root@exit1-debian-9:~/frr# vtysh -c 'sh run' | grep 'bgp community alias'
bgp community alias 65001:123 community-1
bgp community alias 65001:123:1 lcommunity-1
root@exit1-debian-9:~/frr#
```
```
exit1-debian-9# sh ip bgp 172.16.16.1/32
BGP routing table entry for 172.16.16.1/32, version 21
Paths: (2 available, best #2, table default)
  Advertised to non peer-group peers:
  65030
    192.168.0.2 from home-spine1.donatas.net(192.168.0.2) (172.16.16.1)
      Origin incomplete, metric 0, valid, external, best (Neighbor IP)
      Community: 65001:12 65001:13 community-1 65001:65534
      Large Community: lcommunity-1 65001:123:2
      Last update: Fri Apr 16 12:51:27 2021
exit1-debian-9#
```
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
Diffstat (limited to 'bgpd/bgp_lcommunity.c')
| -rw-r--r-- | bgpd/bgp_lcommunity.c | 5 | 
1 files changed, 3 insertions, 2 deletions
diff --git a/bgpd/bgp_lcommunity.c b/bgpd/bgp_lcommunity.c index 88a85c979e..ff34937efc 100644 --- a/bgpd/bgp_lcommunity.c +++ b/bgpd/bgp_lcommunity.c @@ -30,6 +30,7 @@  #include "bgpd/bgpd.h"  #include "bgpd/bgp_lcommunity.h" +#include "bgpd/bgp_community_alias.h"  #include "bgpd/bgp_aspath.h"  /* Hash of community attribute. */ @@ -213,7 +214,7 @@ static void set_lcommunity_string(struct lcommunity *lcom, bool make_json)  	}  	/* 1 space + lcom->size lcom strings + null terminator */ -	size_t str_buf_sz = (LCOMMUNITY_STRLEN * lcom->size) + 2; +	size_t str_buf_sz = BUFSIZ;  	str_buf = XCALLOC(MTYPE_LCOMMUNITY_STR, str_buf_sz);  	for (i = 0; i < lcom->size; i++) { @@ -231,7 +232,7 @@ static void set_lcommunity_string(struct lcommunity *lcom, bool make_json)  		snprintf(lcsb, sizeof(lcsb), "%u:%u:%u", global, local1,  			 local2); -		len = strlcat(str_buf, lcsb, str_buf_sz); +		len = strlcat(str_buf, bgp_community2alias(lcsb), str_buf_sz);  		assert((unsigned int)len < str_buf_sz);  		if (make_json) {  | 
