Skip to content

Commit

Permalink
Merge pull request #15545 from donaldsharp/bgp_attr_dump
Browse files Browse the repository at this point in the history
bgpd: Add some missing data to `show bgp attribute-info`
  • Loading branch information
ton31337 authored Mar 15, 2024
2 parents 4b512f2 + bc26580 commit 387a035
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bgpd/bgp_aspath.c
Original file line number Diff line number Diff line change
Expand Up @@ -2249,7 +2249,7 @@ void aspath_finish(void)
/* return and as path value */
const char *aspath_print(struct aspath *as)
{
return (as ? as->str : NULL);
return as ? as->str : "(null)";
}

/* Printing functions */
Expand Down
11 changes: 9 additions & 2 deletions bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,9 +911,16 @@ static void attr_show_all_iterator(struct hash_bucket *bucket, struct vty *vty)

vty_out(vty,
"\tflags: %" PRIu64
" distance: %u med: %u local_pref: %u origin: %u weight: %u label: %u sid: %pI6\n",
" distance: %u med: %u local_pref: %u origin: %u weight: %u label: %u sid: %pI6 aigp_metric: %" PRIu64
"\n",
attr->flag, attr->distance, attr->med, attr->local_pref,
attr->origin, attr->weight, attr->label, sid);
attr->origin, attr->weight, attr->label, sid, attr->aigp_metric);
vty_out(vty,
"\taspath: %s Community: %s Extended Community: %s Large Community: %s\n",
aspath_print(attr->aspath),
community_str(attr->community, false, false),
ecommunity_str(attr->ecommunity),
lcommunity_str(attr->lcommunity, false, false));
}

void attr_show_all(struct vty *vty)
Expand Down
5 changes: 4 additions & 1 deletion bgpd/bgp_ecommunity.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,11 @@ struct ecommunity *ecommunity_dup(struct ecommunity *ecom)
}

/* Return string representation of ecommunities attribute. */
char *ecommunity_str(struct ecommunity *ecom)
const char *ecommunity_str(struct ecommunity *ecom)
{
if (!ecom)
return "(null)";

if (!ecom->str)
ecom->str =
ecommunity_ecom2str(ecom, ECOMMUNITY_FORMAT_DISPLAY, 0);
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_ecommunity.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ extern void ecommunity_strfree(char **s);
extern bool ecommunity_include(struct ecommunity *e1, struct ecommunity *e2);
extern bool ecommunity_match(const struct ecommunity *,
const struct ecommunity *);
extern char *ecommunity_str(struct ecommunity *ecom);
extern const char *ecommunity_str(struct ecommunity *ecom);
extern struct ecommunity_val *ecommunity_lookup(const struct ecommunity *,
uint8_t, uint8_t);

Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_updgrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ static unsigned int updgrp_hash_key_make(const void *p)
key = jhash_1word((peer->flags & PEER_FLAG_AIGP), key);

if (peer->soo[afi][safi]) {
char *soo_str = ecommunity_str(peer->soo[afi][safi]);
const char *soo_str = ecommunity_str(peer->soo[afi][safi]);

key = jhash_1word(jhash(soo_str, strlen(soo_str), SEED1), key);
}
Expand Down

0 comments on commit 387a035

Please sign in to comment.