Skip to content

Commit

Permalink
bgpd: Adapt write_network for SAFI_RTC
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Sohn <github@asohn.de>
  • Loading branch information
Sohn123 authored and louis-6wind committed Dec 2, 2024
1 parent e01221e commit 56c1e69
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -16313,7 +16313,28 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,

p = bgp_dest_get_prefix(dest);

vty_out(vty, " network %pFX", p);
if (safi == SAFI_RTC) {
/* Only prefixes with a length of more than 48 have the
* type and subtype field set. If those aren't set
* ecommunity_ecom2str returns just UNK:
*/
if (p->prefixlen >= 48) {
struct ecommunity *ecom =
ecommunity_parse((unsigned char *)&p->u.prefix_rtc
.route_target,
8, false);
char *b = ecommunity_ecom2str(ecom, ECOMMUNITY_FORMAT_ROUTE_MAP,
ECOMMUNITY_ROUTE_TARGET);

vty_out(vty, " rt %s", b);
ecommunity_unintern(&ecom);
XFREE(MTYPE_ECOMMUNITY_STR, b);
} else
vty_out(vty, " rt 0:0");

vty_out(vty, "/%d", p->prefixlen);
} else
vty_out(vty, " network %pFX", p);

if (bgp_static->label_index != BGP_INVALID_LABEL_INDEX)
vty_out(vty, " label-index %u",
Expand Down

0 comments on commit 56c1e69

Please sign in to comment.