diff options
author | Philippe Guibert <philippe.guibert@6wind.com> | 2022-11-22 09:57:10 +0100 |
---|---|---|
committer | Philippe Guibert <philippe.guibert@6wind.com> | 2023-02-10 10:27:23 +0100 |
commit | 4a8cd6ad7f3a9b1eabfbc1dd42b8f1b8ba9d3b97 (patch) | |
tree | 775477ae6c4d6742dca32415dbb01b1c3e72dbf5 /bgpd/bgp_debug.c | |
parent | bgpd: the neighbor as are displayed with as-notation mode (diff) | |
download | frr-4a8cd6ad7f3a9b1eabfbc1dd42b8f1b8ba9d3b97.tar.xz frr-4a8cd6ad7f3a9b1eabfbc1dd42b8f1b8ba9d3b97.zip |
bgpd: support for as notation format for route distinguisher
RD may be built based on an AS number. Like for the AS, the RD
may use the AS notation. The two below examples can illustrate:
RD 1.1:20 stands for an AS4B:NN RD with AS4B=65536 in dot format.
RD 0.1:20 stands for an AS2B:NNNN RD with AS2B=0.1 in dot+ format.
This commit adds the asnotation mode to prefix_rd2str() API so as
to pick up the relevant display.
Two new printfrr extensions are available to display the RD with
the two above display methods.
- The pRDD extension stands for dot asnotation format
- The pRDE extension stands for dot+ asnotation format.
- The pRD extension has been renamed to pRDP extension
The code is changed each time '%pRD' printf extension is called.
Possibly, the asnotation may change the output, then a macro defines
the asnotation mode to use. A side effect of forging the mode to
use is that the string could not be concatenated with other strings
in vty_out and snprintfrr. Those functions have been called multiple
times. When zlog_debug needs to display the RD with some other string,
the prefix_rd2str() old API is used instead of the printf extension.
Some code has been kept untouched:
- code related to running-config. Actually, wherever an RD is displayed,
its configured name should be dumped.
- bgp rfapi code
- bgp evpn multihoming code (partially done), since the logic is
missing to get the asnotation of 'struct bgp_evpn_es'.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd/bgp_debug.c')
-rw-r--r-- | bgpd/bgp_debug.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index f01c3e4f3..91156b9ed 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -2651,6 +2651,7 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi, char tag_buf[30]; char overlay_index_buf[INET6_ADDRSTRLEN + 14]; const struct prefix_evpn *evp; + int len = 0; /* ' with addpath ID ' 17 * max strlen of uint32 + 10 @@ -2704,11 +2705,15 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi, } } - if (prd) - snprintfrr(str, size, "RD %pRD %pFX%s%s%s %s %s", prd, pu.p, + if (prd) { + len += snprintfrr(str + len, size - len, "RD "); + len += snprintfrr(str + len, size - len, + BGP_RD_AS_FORMAT(bgp_get_asnotation(NULL)), + prd); + snprintfrr(str + len, size - len, " %pFX%s%s%s %s %s", pu.p, overlay_index_buf, tag_buf, pathid_buf, afi2str(afi), safi2str(safi)); - else if (safi == SAFI_FLOWSPEC) { + } else if (safi == SAFI_FLOWSPEC) { char return_string[BGP_FLOWSPEC_NLRI_STRING_MAX]; const struct prefix_fs *fs = pu.fs; |